-
-
-
-
-
-
- float sun_theta = dot( normal, w.sun_dir );
-
- float softness_min = 0.5;
- float softness = softness_min + w.sunset_phase * (1.0-softness_min);
- float light_min = 0.0 * w.day_phase;
- float light_direct = light_min + smoothstep( -softness, softness, sun_theta ) * (1.0-light_min);
- light_direct *= clamp(w.sun_dir.y * 4.0 + 1.0,0.0,1.0) * shadow;
-
- float light_bounce = 0.5 + 0.5 * dot( -normal, w.sun_dir );
- light_bounce *= light_bounce * max( w.sun_dir.y, 0.0 );
-
- vec3 light_colour = SUN_COLOUR*w.day_phase + (SUNSET_COLOUR*w.sunset_phase + 0.1);
- vec3 dark_colour = mix( AMBIENT_COLOUR, SUNSET_AMBIENT, w.sunset_phase );
-
- float spec = newlight_specular( normal, w.sun_dir, halfview, 2.0 )
- * 0.2 * shadow * w.day_phase;
-
- return mix(dark_colour, light_colour, light_direct) +
- spec +
- dark_colour * light_bounce;
-}
-
-void scene_state( float world_time, out world_info w )
-{
- w.time = world_time;
- w.time_of_day = fract( w.time );
- w.day_phase = cos( w.time_of_day * PI * 2.0 ) * 0.5 + 0.5;
- w.sunset_phase = cos( w.time_of_day * PI * 4.0 + PI ) * 0.5 + 0.5;
- w.sunset_phase = pow( w.sunset_phase, 6.0 );
-
- float a = w.time_of_day * PI * 2.0;
- w.sun_dir = normalize( vec3( sin( a ), cos( a ), 0.2) );