Hello guys…
I am trying to implement a multitextured terrain…i successfully implemented it…but my problem is i don’t know which technique should i use for blending different textures for final fragment color computation…presently i m computing fragment colors based as addition of different texture colors depending upon terrain height…but this does not look gud…final result is not as pretty as i see on the internet…
I am attaching my results
and here is my fragment shader
vec3 sandColor = texture2D(sand,gl_TexCoord[0].st).rgb;
vec3 grassColor = texture2D(grass,gl_TexCoord[1].st).rgb;
vec3 iceColor = texture2D(ice,gl_TexCoord[2].st).rgb;
float lowerBound = abs(minHeight);
float maxHeight1 = maxHeight + lowerBound;
float height1 = height + lowerBound;
float heightRatio = height1/maxHeight1;
if(heightRatio <= .3)
gl_FragColor = vec4(grassColor, 1.0);
else if (heightRatio > .3 && heightRatio <= 0.6)
gl_FragColor = vec4(grassColor*0.5 + sandColor*0.5, 1.0);
else if (heightRatio > 0.6 && heightRatio <= 0.8)
gl_FragColor = vec4(grassColor * 0.2 + sandColor * 0.4 + iceColor * 0.4, 1.0);
else if(heightRatio > 0.8 && heightRatio < 0.9)
gl_FragColor = vec4(grassColor *0.0 + sandColor * 0.3 + iceColor * 0.7, 1.0);
else if(heightRatio >= 0.9)
gl_FragColor = vec4(iceColor, 1.0);