medfall

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

commit c30ccc7846685421e995a397693a5ab27f1098b2
parent 46cf69c3629346d405a27dae2714f42aed869ed6
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Sat Sep 10 18:26:10 -0700

Draw dynamic lights before fog

Diffstat:
terrain_manager.cc | 16+++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/terrain_manager.cc b/terrain_manager.cc @@ -68,12 +68,6 @@ static const GLchar * frag_src = GLSL( // float light = max( 0.2, l * ( d * 0 + 1 ) ); float light = max( 0.2, l * d ); - vec3 fog = vec3( 0.6, 0.6, 0.6 ); - - float depth = length( pos ); - float t = smoothstep( 700, 1250, depth ) * 0.6; - - colour = vec4( ( 1.0 - t ) * ground * light + t * fog, 1.0 ); // colour *= 0; // colour = vec4( horizon, horizon, horizon, 1.0 ); @@ -84,6 +78,7 @@ static const GLchar * frag_src = GLSL( // int a = int( smooth_position.x ) / 10; // if( a % 2 == 0 ) colour.g = 1; + vec3 c = ground * light; // place some lights for( int i = 0; i < 5; i++ ) { vec3 light_position = texelFetch( point_light_origins, i ).xyz; @@ -92,8 +87,15 @@ static const GLchar * frag_src = GLSL( vec3 light_direction = normalize( light_position - smooth_position ); float lambert_scale = dot( light_direction, normal ); float distance_scale = 1.0 / sqrt( light_sqdistance ); - colour += vec4( light_colour * lambert_scale * distance_scale, 0.0 ); + c += vec3( light_colour * lambert_scale * distance_scale ); } + + vec3 fog = vec3( 0.6, 0.6, 0.6 ); + + float depth = length( pos ); + float t = smoothstep( 700, 1250, depth ) * 0.6; + + colour = vec4( ( 1.0 - t ) * c + t * fog, 1.0 ); } );