commit e833e9edacb4dcab5bc1a9de1b506a574b3f9c3b parent ae1b939e6ee51296d7bc15fffaead14ec04d8889 Author: Michael Savage <mikejsavage@gmail.com> Date: Sat Nov 26 22:23:53 +0200 Fix sun direction in terrain shader Diffstat:
terrain_manager.cc | | | 4 | ++-- |
diff --git a/terrain_manager.cc b/terrain_manager.cc @@ -77,8 +77,8 @@ static const char * frag_src = GLSL( // sunlight + sky ambient lighting // TODO: use formula for area of a chord? float sun_visible_fraction = smoothstep( 0, 0.2, sun - horizon ); - vec3 sun_direction = normalize( vec3( 1, 1, -sun ) ); - float sunlight_lambert = max( 0, -dot( normal, sun_direction ) ); + vec3 sun_direction = normalize( vec3( -1, 0, sun ) ); + float sunlight_lambert = max( 0, dot( normal, sun_direction ) ); vec3 sunlight = sun_visible_fraction * sunlight_lambert * vec3( 0.9, 0.9, 0.5 ); vec3 ambient = vec3( 0.02, 0.02, 0.15 );