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
34
35
36
|
#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 foggify(vec3 player_pos, vec3 pos);
void main() {
vec3 n = normalize(normal);
float diffuse = max(dot(n, light_pos), 0.5);
float f1 = clamp((pos.y-60.0) / 3.0, 0.0, 1.0);
float f2 = clamp((pos.y-33) / 3.0, 0.0, 1.0);
vec4 grass = texture2D(tex[0], gl_TexCoord[0].st);
vec4 rock = texture2D(tex[1], gl_TexCoord[0].st);
vec4 soil = texture2D(tex[2], gl_TexCoord[0].st);
gl_FragColor = mix(mix(soil, grass, f2), rock, 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);
}
foggify(player_pos, pos);
}
/* vim: set syn=glsl: */
|