diff --git a/README.md b/README.md
index 258c87f..904eea0 100644
--- a/README.md
+++ b/README.md
@@ -54,5 +54,10 @@ Capture d'écran de la toute première version d'EnginPasTangible (v0.2.2)
### V0.2.5
-
-Rotation autour du centre contrôlée par la souris (v0.2.5)
\ No newline at end of file
+
+Rotation autour du centre contrôlée par la souris (v0.2.5)
+
+### V0.4.2
+
+
+Cycle jour nuit dans une scene avec des tours et déplacements clavier souris (v0.4.2)
\ No newline at end of file
diff --git a/main.c b/main.c
index b973eab..648983c 100644
--- a/main.c
+++ b/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
#include
@@ -7,8 +7,12 @@
#define STB_IMAGE_IMPLEMENTATION
#include "./Libraries/stb/stb_image.h"
#include "headers/shader.h"
-
-#define SCENE "shaders/couleurs.fs"
+/* SCENE LIST
+shaders/default.fs
+shaders/immeublesparisiens.fs
+*/
+#define SCENE "shaders/default.fs"
+//#define SCENE "shaders/immeublesparisiens.fs"
#define FULLSCREEN 0
#define EXPERIMENTAL_FEATURES 0
/* ## DEBUG MODE ##
@@ -20,7 +24,7 @@
*
* 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;
const GLFWvidmode* mode;
@@ -35,10 +39,11 @@ unsigned int VAO;
float currentTime, deltaTime, lastFrame,startTime;
float mousePosX,mousePosY;
+float speedlevel=4.;
float camPosX=2.5;
float camPosY=0.5;
float camPosZ=2.5;
-float speed=.02;
+float speed=.04;
float pan=0.;
float multiplicatorFov=1.;
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 stateControl = glfwGetKey(window, GLFW_KEY_LEFT_CONTROL);
if (stateShift == GLFW_PRESS) {
- speed=.08;
+ speed=.08*speedlevel;
multiplicatorFov=0.8;
}
else {
- speed=.02;
+ speed=.02*speedlevel;
multiplicatorFov=1.;
}
diff --git a/screenshots/EnginPasTangiblev0.4.2.gif b/screenshots/EnginPasTangiblev0.4.2.gif
new file mode 100644
index 0000000..ff1a898
Binary files /dev/null and b/screenshots/EnginPasTangiblev0.4.2.gif differ
diff --git a/shaders/default.fs b/shaders/default.fs
index c0869fa..b6b95e4 100644
--- a/shaders/default.fs
+++ b/shaders/default.fs
@@ -33,10 +33,9 @@ vec3 infinity(vec3 pos,vec3 box){
return mod(pos+.5*box,box)-.5*box;
}
-
-vec3 repeter(vec3 p, float size, vec3 repet)
+vec3 repeat(vec3 p, vec3 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 )
diff --git a/shaders/immeublesparisiens.fs b/shaders/immeublesparisiens.fs
index 8a538df..64f4a3a 100644
--- a/shaders/immeublesparisiens.fs
+++ b/shaders/immeublesparisiens.fs
@@ -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);
}
@@ -53,16 +53,21 @@ float SDF_Sphere(vec3 p,float 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){
//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 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
vec3 pos=origin;
float dist;
- for(int i=0;i<30;i++){
+ for(int i=0;i<260;i++){
dist=SDF_Global(pos);
pos+=dist*dir;
if(dist<=.01) return vec4(pos,1.);
@@ -80,10 +85,23 @@ vec3 grad(vec3 p){
vec3 Get_Color(vec3 origin,vec3 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 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){