Hi,
In my terrain engine, i’m tryng to apply a diferent detail map, depending on the height of the terrain.
In this case, if the heigth is below 65, i want to use a sand texture, if it is above i want to use a grass texture.
This is my shader :
uniform sampler2D myPaintMap;
uniform sampler2D Detail1;
uniform sampler2D Detail2;
uniform sampler2D hMap;
vec4 theMap;
void main (void)
{
vec4 paintmap = texture2D(myPaintMap, vec2(gl_TexCoord[0]));
vec4 sand = texture2D(Detail1, vec2(gl_TexCoord[1]));
vec4 grass = texture2D(Detail2, vec2(gl_TexCoord[2]));
vec4 heightmap = texture2D(hMap, vec2(gl_TexCoord[3]));
float paint_color = (heightmap.x + heightmap.y + heightmap.z) / 3.0;
theMap = grass;
if(paint_color < 65.0) theMap = sand;
gl_FragColor = 0.5*(paintmap + theMap);
}
paintmap is the color map, detail1 is the sand texture, detail2 is the grass texture, and hMap is the heightmap.
Using this shader i get both detail maps spread in the landscape but all in wrong positions.
It seems that i’m getting the color wrong from the heightmap.
I tried using a 8bit greyscale image for the heightmap, and using a 24bit rgb image, but they both don’t work.
What am i doing wrong ?
Am i getting the color(height) of the heightmap correctly ?
thanks,
Bruno