- uniform sampler2D layer0;
- uniform sampler2D layer1;
- uniform sampler2D layer2;
- uniform sampler2D alpha;
- varying vec3 normal;
- void main()
- {
- // compute terrain color
- vec3 tex0 = texture2D(layer0, gl_TexCoord[0].xy).rgb;
- vec3 tex1 = texture2D(layer1, gl_TexCoord[0].xy).rgb;
- vec3 tex2 = texture2D(layer2, gl_TexCoord[0].xy).rgb;
- vec3 a = texture2D(alpha, gl_TexCoord[1].xy).rgb;
- vec3 color = a.r*tex0 + a.g*tex1 + a.b*tex2;
- // compute diffuse lighting (directional lightsource only)
- float diffuse = max(dot(gl_LightSource[0].position.xyz, normal), 0.0);
- gl_FragColor = vec4(diffuse * color + gl_LightSource[0].ambient.xyz, 1.0);
- }