Oh yes sorry, here it is:
#version 330
out vec4 out_Color;
uniform sampler2D sandTexture;
uniform sampler2D grassTexture;
uniform sampler2D rockTexture;
uniform float TerrainHeight;
//From vertex shader
in vec2 texCoord;
in vec3 normal;
in vec3 position;
vec4 texColor = vec4(0);
float shade;
void main(void)
{
const vec3 light = vec3(0.5, 1, 0.5);
shade = dot(light, normalize(normal));
const float fRange1 = 0.01f;
const float fRange2 = 0.1f;
const float fRange3 = 0.5f;
const float fRange4 = 0.9f;
float fScale = position.y/TerrainHeight;
if(fScale >= 0.0 && fScale <= fRange1)
texColor = texture(sandTexture, texCoord);
else if(fScale <= fRange2)
{
fScale -= fRange1;
fScale /= (fRange2-fRange1);
float fScale2 = fScale;
fScale = 1.0-fScale;
texColor += texture(sandTexture, texCoord)*fScale;
texColor += texture(grassTexture, texCoord)*fScale2;
}
else if(fScale <= fRange3)
texColor = texture(grassTexture, texCoord);
else if(fScale <= fRange4)
{
fScale -= fRange3;
fScale /= (fRange4-fRange3);
float fScale2 = fScale;
fScale = 1.0-fScale;
texColor += texture(grassTexture, texCoord)*fScale;
texColor += texture(rockTexture, texCoord)*fScale2;
}
else
texColor = texture(rockTexture, texCoord);
out_Color = texColor * shade;
}
Basically its the same as the fragment shader in the tutorial