summaryrefslogtreecommitdiff
path: root/shaders/terrain_fragment.glsl
blob: 78417af4a71b34ead15acd5a92a8f206d78534da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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: */