medfall

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

commit a634fa00333eff9cb10a14718b0ebcaa41bdea3b
parent a2a972595e6ebf08c102134aa1e3c6fdba659098
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Wed Oct 12 19:25:17 +0300

Use quadratic lighting distance falloff

Diffstat:
terrain_manager.cc | 14+++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/terrain_manager.cc b/terrain_manager.cc @@ -90,7 +90,7 @@ static const GLchar * frag_src = GLSL( float light_sqdistance = dot( light_position - smooth_position, light_position - smooth_position ); vec3 light_direction = normalize( light_position - smooth_position ); float lambert_scale = dot( light_direction, normal ); - float distance_scale = 1.0 / sqrt( light_sqdistance ); + float distance_scale = 1.0 / light_sqdistance; c += vec3( light_colour * lambert_scale * distance_scale ) * ground; } @@ -100,7 +100,7 @@ static const GLchar * frag_src = GLSL( float depth = length( vpos ); float t = smoothstep( 700, 1250, depth ) * 0.6; - colour = vec4( ( 1.0 - t ) * c + t * fog, 1.0 ); + colour = vec4( mix( c, fog, t ), 1.0 ); } ); @@ -358,11 +358,11 @@ void terrain_render( TerrainManager * tm, glm::mat4 V, glm::mat4 VP, float sun ) /* start lighting */ float tbo1[ 15 ] = { - 500, 1500 + 500 * sin( glfwGetTime() + 3.14 * 1 / 5 ), 50, - 600, 1500 + 500 * sin( glfwGetTime() + 3.14 * 2 / 5 ), 50, - 700, 1500 + 500 * sin( glfwGetTime() + 3.14 * 3 / 5 ), 50, - 800, 1500 + 500 * sin( glfwGetTime() + 3.14 * 4 / 5 ), 50, - 900, 1500 + 500 * sin( glfwGetTime() + 3.14 * 5 / 5 ), 50, + 500, 1500 + 500 * sin( glfwGetTime() + 3.14 * 1 / 5 ), 15, + 600, 1500 + 500 * sin( glfwGetTime() + 3.14 * 2 / 5 ), 15, + 700, 1500 + 500 * sin( glfwGetTime() + 3.14 * 3 / 5 ), 15, + 800, 1500 + 500 * sin( glfwGetTime() + 3.14 * 4 / 5 ), 15, + 900, 1500 + 500 * sin( glfwGetTime() + 3.14 * 5 / 5 ), 15, }; glBindBuffer( GL_TEXTURE_BUFFER, tm->tbo_point_light_origins ); glBufferData( GL_TEXTURE_BUFFER, sizeof( tbo1 ), tbo1, GL_DYNAMIC_DRAW );