medfall

A super great game engine
Log | Files | Refs

commit 2fe65bab1e760d7ab40e053789ac0b2b35d4fdba
parent 6e43cad1ee84b011d312f3f9942324531f60a0ad
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Fri May 19 02:14:25 +0300

Add ambient term to shadow shader

Diffstat:
shaders/shadowed_vertex_colours.glsl | 8++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/shaders/shadowed_vertex_colours.glsl b/shaders/shadowed_vertex_colours.glsl @@ -52,12 +52,13 @@ void main() { vec3 light_colour = vec3( 1.0, 1.0, 1.0 ); vec3 lightdir = normalize( v2f.position - light_pos ); + float ambient = 0.1; float lambert = max( 0, dot( -lightdir, normalize( v2f.normal ) ) ); vec3 light_ndc = v2f.light_space_position.xyz / v2f.light_space_position.w; vec3 light_norm = light_ndc * 0.5 + 0.5; float bias2 = max( bias * ( 1.0 + dot( lightdir, v2f.normal ) ), bias / 100 ); - float shadow = 0.1; + float shadow = 0; if( light_norm.z > 1.0 ) { shadow = 1.0; @@ -69,14 +70,13 @@ void main() { vec2 offset = vec2( x, y ) * inv_shadowmap_size; float shadow_depth = texture( shadowmap, light_norm.xy + offset ).r; if( light_norm.z - bias2 <= shadow_depth ) { - shadow += 0.1; + shadow += 1.0 / 9.0; } } } } - screen_colour = vec4( v2f.colour * light_colour * lambert * shadow, 1.0 ); - // screen_colour = screen_colour * 0 + vec4( ( v2f.normal + 1.0 ) / 2.0, 1 ); + screen_colour = vec4( v2f.colour * light_colour * ( ambient + ( 1 - ambient ) * ( lambert * shadow ) ), 1.0 ); } #endif