1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
#version 120
varying vec3 normal, light_pos, pos;
uniform sampler2D tex[3];
uniform sampler2D marktex;
uniform vec3 selpos, player_pos;
uniform bool show_sel;
void main() {
vec3 n = normalize(normal);
float diffuse = max(dot(n, light_pos), 0.5);
float f1 = clamp((pos.y-15.0) / 3.0, 0.0, 1.0);
float f2 = clamp((pos.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;
/* selection marker */
if(show_sel &&
pos.x >= selpos.x-1 && pos.x <= selpos.x+1 &&
pos.z >= selpos.z-1 && pos.z <= selpos.z+1) {
vec2 st = vec2((pos.x + 1 - selpos.x) / 2, (pos.z + 1 - selpos.z) / 2);
gl_FragColor += texture2D(marktex, st);
}
gl_FragColor = mix(gl_FragColor, gl_Fog.color, pow(length(player_pos - pos)/100, 5));
}
/* vim: set syn=glsl: */
|