diff options
Diffstat (limited to 'shaders/terrain_fragment.glsl')
-rw-r--r-- | shaders/terrain_fragment.glsl | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/shaders/terrain_fragment.glsl b/shaders/terrain_fragment.glsl new file mode 100644 index 0000000..78417af --- /dev/null +++ b/shaders/terrain_fragment.glsl @@ -0,0 +1,22 @@ +#version 120 + +varying vec3 normal, light_pos; +varying float y; + +uniform sampler2D tex[3]; + +void main() { + vec3 n = normalize(normal); + float diffuse = max(dot(n, light_pos), 0.0); + + float f1 = clamp((y-15.0) / 3.0, 0.0, 1.0); + float f2 = clamp((y-2) / 3.0, 0.0, 1.0); + + vec4 t0 = texture2D(tex[0], gl_TexCoord[0].st); + vec4 t1 = texture2D(tex[1], gl_TexCoord[0].st); + vec4 t2 = texture2D(tex[2], gl_TexCoord[0].st); + + gl_FragColor = mix(mix(t2, t0, f2), t1, f1) * diffuse; +} + +/* vim: set syn=glsl: */ |