#define UseBumpmapping #define DiffuseFromBuffer #ifdef UseBumpmapping varying vec3 tsLightDir; varying vec3 tsEyeDir; //varying vec3 tsHalfDir; #endif uniform vec3 wsLightDir; uniform vec3 wsEyePos; uniform sampler2DRect _buffer; uniform sampler2D seafloor_BM; uniform sampler2D grassblend; uniform sampler2D grass_BM; uniform sampler2D rockblend; uniform sampler2D rock_BM; uniform sampler2D adamblend; uniform sampler2D adamante_BM; uniform sampler2D shoreblend; uniform sampler2D gravelshore_BM; uniform sampler2D dirtyblend; uniform sampler2D dirtspots_BM; const float specularExponent = 8; // Optimized function generated by the GLSL handler // This function uses the utility functions below to do things like texture reading and lighting vec4 CalculateColor(); #ifdef UseBumpmapping vec3 reflect(vec3 N, vec3 L) { return 2.0*N*dot(N, L) - L; } vec4 CalcFinal(vec4 diffuse, vec4 texValue) { vec3 normal = normalize(texValue.xyz * vec3(2.0) - vec3(1.0)); float diffuseFactor = max(0.0, -dot(tsLightDir, normal)); vec3 R = reflect(normal, tsLightDir); float specularFactor = clamp(pow(dot(R, tsEyeDir), specularExponent), 0.0, 1.0); vec4 r = gl_LightSource[0].diffuse * diffuse * diffuseFactor; r += gl_LightSource[0].specular * specularFactor * texValue.a; r += gl_LightSource[0].ambient; return r; } #endif // Shader entry point void main() { gl_FragColor=CalculateColor(); } vec4 CalculateColor() { vec4 color; float curalpha; color = texture2D(seafloor_BM, gl_TexCoord[0].st); curalpha = texture2D(grassblend, gl_TexCoord[1].st).a; color = mix(color, texture2D(grass_BM, gl_TexCoord[2].st), curalpha); curalpha = texture2D(rockblend, gl_TexCoord[1].st).a; color = mix(color, texture2D(rock_BM, gl_TexCoord[3].st), curalpha); curalpha = texture2D(adamblend, gl_TexCoord[1].st).a; color = mix(color, texture2D(adamante_BM, gl_TexCoord[4].st), curalpha); curalpha = texture2D(shoreblend, gl_TexCoord[1].st).a; color = mix(color, texture2D(gravelshore_BM, gl_TexCoord[0].st), curalpha); curalpha = texture2D(dirtyblend, gl_TexCoord[1].st).a; color = mix(color, texture2D(dirtspots_BM, gl_TexCoord[0].st), curalpha); return CalcFinal(ReadDiffuseColor(), color);}