medfall

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

commit 58aa3fd22d2a55905474a34cdc3b23ee150bca29
parent 2c0f2fa836eadf1609b31d46bb10f34457afda25
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Sat Aug  1 23:21:07 +0200

Add dumpy fog

Diffstat:
heightmap.cc | 9++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/heightmap.cc b/heightmap.cc @@ -21,6 +21,7 @@ const GLchar * const vert_src = GLSL( in float lit; out vec3 n; + out float depth; out float l; uniform mat4 vp; @@ -29,11 +30,13 @@ const GLchar * const vert_src = GLSL( n = normal; l = lit; gl_Position = vp * vec4( position, 1.0 ); + depth = gl_Position.z; } ); const GLchar * frag_src = GLSL( in vec3 n; + in float depth; in float l; out vec4 colour; @@ -52,7 +55,11 @@ const GLchar * frag_src = GLSL( float d = max( 0, -dot( n, sun ) ); float light = max( 0.2, l * d ); - colour = vec4( ground * light, 1.0 ); + vec3 fog = vec3( 0.6, 0.6, 0.6 ); + + float t = smoothstep( 400, 600, depth ); + + colour = vec4( ( 1.0 - t ) * ground * light + t * fog, 1.0 ); } );