Create a day cycle on city map

This commit is contained in:
MagicTINTIN 2023-03-21 19:55:12 +01:00
parent 243e757998
commit eaf480b473

View file

@ -56,7 +56,7 @@ float SDF_Sphere(vec3 p,float r){
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(0., 25., 0.)), 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),p.y); //infinity(p, vec(0.3, 0.2, 0.5))
}
vec4 Get_Impact(vec3 origin,vec3 dir){//must have length(dir)==1
@ -80,17 +80,21 @@ vec3 grad(vec3 p){
vec3 Get_Color(vec3 origin,vec3 dir){
vec4 impact = Get_Impact(origin,dir);
if(impact.w<0.) return vec3(.9,.5,.2)+.5*(dir.x*sin(Time)+dir.y*cos(Time))+.05*clamp(origin.y-10.,-10.,10.); //(.5,.8,.9)
vec3 normale=grad(impact.xyz);
//
vec3 sunPos=vec3(sin(Time),cos(Time),0);//vec3(3.*sin(Time*1.5),3.*cos(Time*3.),3.*cos(Time*1.5));
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 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,normalize(sunPos-impact.xyz));
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; //*
}