Merge branch 'master' of https://git.etud.insa-toulouse.fr/serviere/EnginPasTangible
This commit is contained in:
commit
e41102b796
5 changed files with 45 additions and 18 deletions
|
@ -54,5 +54,10 @@ Capture d'écran de la toute première version d'EnginPasTangible (v0.2.2)
|
||||||
|
|
||||||
### V0.2.5
|
### V0.2.5
|
||||||
|
|
||||||
<br>
|
<br>
|
||||||
Rotation autour du centre contrôlée par la souris (v0.2.5)
|
Rotation autour du centre contrôlée par la souris (v0.2.5)
|
||||||
|
|
||||||
|
### V0.4.2
|
||||||
|
|
||||||
|
<br>
|
||||||
|
Cycle jour nuit dans une scene avec des tours et déplacements clavier souris (v0.4.2)
|
19
main.c
19
main.c
|
@ -1,4 +1,4 @@
|
||||||
#define APPNAMEVERSION "EnginPasTangible (alpha 0.3.1)"
|
#define APPNAMEVERSION "EnginPasTangible (alpha 0.4.2)"
|
||||||
#include "./Libraries/glad/glad.h"
|
#include "./Libraries/glad/glad.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
@ -7,8 +7,12 @@
|
||||||
#define STB_IMAGE_IMPLEMENTATION
|
#define STB_IMAGE_IMPLEMENTATION
|
||||||
#include "./Libraries/stb/stb_image.h"
|
#include "./Libraries/stb/stb_image.h"
|
||||||
#include "headers/shader.h"
|
#include "headers/shader.h"
|
||||||
|
/* SCENE LIST
|
||||||
#define SCENE "shaders/couleurs.fs"
|
shaders/default.fs
|
||||||
|
shaders/immeublesparisiens.fs
|
||||||
|
*/
|
||||||
|
#define SCENE "shaders/default.fs"
|
||||||
|
//#define SCENE "shaders/immeublesparisiens.fs"
|
||||||
#define FULLSCREEN 0
|
#define FULLSCREEN 0
|
||||||
#define EXPERIMENTAL_FEATURES 0
|
#define EXPERIMENTAL_FEATURES 0
|
||||||
/* ## DEBUG MODE ##
|
/* ## DEBUG MODE ##
|
||||||
|
@ -20,7 +24,7 @@
|
||||||
*
|
*
|
||||||
* For instance if you want fps and position set the value to 2*3=6
|
* For instance if you want fps and position set the value to 2*3=6
|
||||||
*/
|
*/
|
||||||
#define DEBUG_MODE 1
|
#define DEBUG_MODE 2
|
||||||
|
|
||||||
GLuint screenWidth = 720, screenHeight = 480;
|
GLuint screenWidth = 720, screenHeight = 480;
|
||||||
const GLFWvidmode* mode;
|
const GLFWvidmode* mode;
|
||||||
|
@ -35,10 +39,11 @@ unsigned int VAO;
|
||||||
float currentTime, deltaTime, lastFrame,startTime;
|
float currentTime, deltaTime, lastFrame,startTime;
|
||||||
float mousePosX,mousePosY;
|
float mousePosX,mousePosY;
|
||||||
|
|
||||||
|
float speedlevel=4.;
|
||||||
float camPosX=2.5;
|
float camPosX=2.5;
|
||||||
float camPosY=0.5;
|
float camPosY=0.5;
|
||||||
float camPosZ=2.5;
|
float camPosZ=2.5;
|
||||||
float speed=.02;
|
float speed=.04;
|
||||||
float pan=0.;
|
float pan=0.;
|
||||||
float multiplicatorFov=1.;
|
float multiplicatorFov=1.;
|
||||||
float tilt=0.;
|
float tilt=0.;
|
||||||
|
@ -74,11 +79,11 @@ static void key_callback(GLFWwindow* window, int key, int scancode, int action,
|
||||||
int stateShift = glfwGetKey(window, GLFW_KEY_LEFT_SHIFT);
|
int stateShift = glfwGetKey(window, GLFW_KEY_LEFT_SHIFT);
|
||||||
int stateControl = glfwGetKey(window, GLFW_KEY_LEFT_CONTROL);
|
int stateControl = glfwGetKey(window, GLFW_KEY_LEFT_CONTROL);
|
||||||
if (stateShift == GLFW_PRESS) {
|
if (stateShift == GLFW_PRESS) {
|
||||||
speed=.08;
|
speed=.08*speedlevel;
|
||||||
multiplicatorFov=0.8;
|
multiplicatorFov=0.8;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
speed=.02;
|
speed=.02*speedlevel;
|
||||||
multiplicatorFov=1.;
|
multiplicatorFov=1.;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
BIN
screenshots/EnginPasTangiblev0.4.2.gif
Normal file
BIN
screenshots/EnginPasTangiblev0.4.2.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 4 MiB |
|
@ -33,10 +33,9 @@ vec3 infinity(vec3 pos,vec3 box){
|
||||||
return mod(pos+.5*box,box)-.5*box;
|
return mod(pos+.5*box,box)-.5*box;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vec3 repeat(vec3 p, vec3 size, vec3 repet)
|
||||||
vec3 repeter(vec3 p, float size, vec3 repet)
|
|
||||||
{
|
{
|
||||||
return p-size*clamp(round(p/size),-repet,repet);
|
return p-size*clamp(vec3(round(p.x/size.x),round(p.y/size.y),round(p.z/size.z)),-repet,repet);
|
||||||
}
|
}
|
||||||
|
|
||||||
float SDF_Box_Frame( vec3 p, vec3 b, float e )
|
float SDF_Box_Frame( vec3 p, vec3 b, float e )
|
||||||
|
|
|
@ -29,7 +29,7 @@ vec3 infinity(vec3 pos,vec3 box){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
vec3 repeter(vec3 p, vec3 size, vec3 repet)
|
vec3 repeat(vec3 p, vec3 size, vec3 repet)
|
||||||
{
|
{
|
||||||
return p-size*clamp(vec3(round(p.x/size.x),round(p.y/size.y),round(p.z/size.z)),-repet,repet);
|
return p-size*clamp(vec3(round(p.x/size.x),round(p.y/size.y),round(p.z/size.z)),-repet,repet);
|
||||||
}
|
}
|
||||||
|
@ -53,16 +53,21 @@ float SDF_Sphere(vec3 p,float r){
|
||||||
return length(p)-r;
|
return length(p)-r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float SDF_Box(vec3 p, vec3 t){
|
||||||
|
vec3 q=abs(p)-t;
|
||||||
|
return length(max(q,0.0))+ min(max(q.x,max(q.y,q.z)),0.0);
|
||||||
|
}
|
||||||
|
|
||||||
float SDF_Global(vec3 p){
|
float SDF_Global(vec3 p){
|
||||||
//return SDF_Box_Frame(rotate(p,vec3(0.,.2*Time,0.)),vec3(.5,.5,.5),.1);
|
//return SDF_Box_Frame(rotate(p,vec3(0.,.2*Time,0.)),vec3(.5,.5,.5),.1);
|
||||||
//return max(SDF_Sphere(p,.5),-SDF_Box_Frame(rotate(p,vec3(0.,.2*Time,0.)),vec3(1.,1.,1.),.3));//min(SDF_Box_Frame(p,vec3(.5,.5,.5),0.1),SDF_Circle(mod(p+vec3(.5),vec3(1.,1.,1.))-vec3(.5),.15));
|
//return max(SDF_Sphere(p,.5),-SDF_Box_Frame(rotate(p,vec3(0.,.2*Time,0.)),vec3(1.,1.,1.),.3));//min(SDF_Box_Frame(p,vec3(.5,.5,.5),0.1),SDF_Circle(mod(p+vec3(.5),vec3(1.,1.,1.))-vec3(.5),.15));
|
||||||
return min(SDF_Box_Frame(repeter(p, vec3(4.,2.,10.), vec3(2., 25., 5.)), vec3(1.,1.,1.),.1),p.y); //infinity(p, vec(0.3, 0.2, 0.5))
|
return min(SDF_Box_Frame(repeat(p, vec3(4.,2.,10.), vec3(2., 25., 4.)), vec3(1.,1.,1.),.1),SDF_Box(p,vec3(20.,0.1,50.))); //infinity(p, vec(0.3, 0.2, 0.5))
|
||||||
}
|
}
|
||||||
|
|
||||||
vec4 Get_Impact(vec3 origin,vec3 dir){//must have length(dir)==1
|
vec4 Get_Impact(vec3 origin,vec3 dir){//must have length(dir)==1
|
||||||
vec3 pos=origin;
|
vec3 pos=origin;
|
||||||
float dist;
|
float dist;
|
||||||
for(int i=0;i<30;i++){
|
for(int i=0;i<260;i++){
|
||||||
dist=SDF_Global(pos);
|
dist=SDF_Global(pos);
|
||||||
pos+=dist*dir;
|
pos+=dist*dir;
|
||||||
if(dist<=.01) return vec4(pos,1.);
|
if(dist<=.01) return vec4(pos,1.);
|
||||||
|
@ -80,10 +85,23 @@ vec3 grad(vec3 p){
|
||||||
|
|
||||||
vec3 Get_Color(vec3 origin,vec3 dir){
|
vec3 Get_Color(vec3 origin,vec3 dir){
|
||||||
vec4 impact = Get_Impact(origin,dir);
|
vec4 impact = Get_Impact(origin,dir);
|
||||||
if(impact.w<0.) return vec3(.5,.8,.9)+.5*dir.y+.05*clamp(origin.y-10.,-10.,10.);
|
|
||||||
|
//
|
||||||
|
vec3 sunPos=normalize(rotate(vec3(.1,1.,.0),vec3(.5*Time,.0,0)));//vec3(3.*sin(Time*1.5),3.*cos(Time*3.),3.*cos(Time*1.5));
|
||||||
|
//return vec3(clamp(0.,1.,dot(sunPos,normale)));//normale; ---impact.xyz
|
||||||
|
|
||||||
|
float dotdirsun = dot(sunPos, dir);
|
||||||
|
//if(impact.w<0.) return vec3(.3,.1+.7*dotdirsun,0.2+.8*dotdirsun)+.05*clamp(origin.y-10.,-10.,10.); //(.5,.8,.9)
|
||||||
|
if(impact.w<0.) return vec3(.4,.1+.6*sunPos.y,.8*sunPos.y)+dotdirsun;//+.05*clamp(origin.y-10.,-10.,10.); //(.5,.8,.9)
|
||||||
vec3 normale=grad(impact.xyz);
|
vec3 normale=grad(impact.xyz);
|
||||||
vec3 sunPos=vec3(3.,3.5,.5);//vec3(3.*sin(Time*1.5),3.*cos(Time*3.),3.*cos(Time*1.5));
|
|
||||||
return vec3(clamp(0.,1.,dot(sunPos-impact.xyz,normale)));//normale;
|
vec3 symetrique= dir-2.0*dot(dir,normale)*normale;
|
||||||
|
//vec4 reflexion = Get_Impact(impact.xyz+0.02*normale,normalize(symetrique));
|
||||||
|
//float g=reflexion.w<0.?1.5:1.;
|
||||||
|
//vec3 sunPos=vec3(0.,10.,.5);//vec3(3.,3.5,.5);//vec3(3.*sin(Time*1.5),3.*cos(Time*3.),3.*cos(Time*1.5));
|
||||||
|
vec4 ombre = Get_Impact(impact.xyz+0.02*normale,sunPos);
|
||||||
|
float f=ombre.w<0.?1.:.5;
|
||||||
|
return vec3(clamp(0.,1.,dot(sunPos,normale)))*f; //*
|
||||||
}
|
}
|
||||||
|
|
||||||
float Mandel(vec2 co){
|
float Mandel(vec2 co){
|
||||||
|
|
Loading…
Reference in a new issue