+ total_light +=
+ scene_calculate_packed_light_patch( index_sample.x,
+ halfview, co, normal )
+ * light_mask;
+ total_light +=
+ scene_calculate_packed_light_patch( index_sample.y,
+ halfview, co, normal )
+ * light_mask;
+
+ // Take a section of the sky function to give us a matching fog colour
+
+ vec3 fog_colour = clearskies_ambient( -halfview );
+ float sun_theta = dot( -halfview, g_sun_dir.xyz );
+ float sun_size = max( 0.0, sun_theta * 0.5 + 0.5 );
+ float sun_shape = sun_size * max(g_sun_dir.y,0.0) * 0.5;
+
+ vec3 sun_colour = mix( vec3(1.0), g_sunset_colour.rgb, g_sunset_phase*0.5 );
+ sun_colour *= sun_shape;
+
+ fog_colour += sun_colour;
+ return scene_apply_fog( diffuse * total_light, fog_colour, fdist );
+}
+
+void main(){
+ depth_compare_dither();
+ compute_motion_vectors();
+
+ vec3 qnorm = aNorm;
+ vec3 diffuse = texture( uTexMain, aUv ).rgb;
+ vec3 composite = character_compute_lighting( diffuse, qnorm, aWorldCo, 1.0 );
+
+ float dist = distance( aWorldCo, uCamera ) - 0.08;
+ float opacity = clamp( dist*dist, 0.0, 1.0 );