adding smooth sky colors

This commit is contained in:
Victor Lasserre 2023-03-21 14:11:04 +01:00
parent 89c0b0b920
commit e982c764a7
2 changed files with 11 additions and 6 deletions

6
main.c
View file

@ -18,7 +18,7 @@
*
* For instance if you want fps and position set the value to 2*3=6
*/
#define DEBUG_MODE 5
#define DEBUG_MODE 1
GLuint screenWidth = 720, screenHeight = 480;
const GLFWvidmode* mode;
@ -45,8 +45,8 @@ float ex[3] = {0};
float ey[3] = {0};
float fovValue=1.0;
//283=3.14/2 * 180
const int maxYmouse = 283;
//281=3.13/2 * 180
const int maxYmouse = 281;
// more precision means less speed
float camPrecision = 2.;

View file

@ -38,12 +38,17 @@ float SDF_Box_Frame( vec3 p, vec3 b, float e )
length(max(vec3(q.x,q.y,p.z),0.0))+min(max(q.x,max(q.y,p.z)),0.0));
}
float SDF_Circle(vec3 p,float r){
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);//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,1.),-SDF_Box_Frame(rotate(p,vec3(1.*Time,2.0*Time,3.*Time)),vec3(.8,.8,.8),.2));
}
vec4 Get_Impact(vec3 origin,vec3 dir){//must have length(dir)==1
@ -67,7 +72,7 @@ vec3 grad(vec3 p){
vec3 Get_Color(vec3 origin,vec3 dir){
vec4 impact = Get_Impact(origin,dir);
if(impact.w<0.) return (impact.y+1.)*.05*vec3(.5,.7,1.);
if(impact.w<0.) return vec3(.5,.8,.9)+.5*dir.y+.05*clamp(origin.y-10.,-10.,10.);//(impact.y+1.)*.05*vec3(.5,.7,1.);
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;