Multitex Terrain + Normalmapping - More than three textures?

Posted By: Benni003

Multitex Terrain + Normalmapping - More than three textures? - 03/23/14 10:47

Hi, I need a terrainshader with a masktexture as fogman wrote:
http://www.opserver.de/ubb7/ubbthreads.p...true#Post361297

Is it possible, to have more than three textures on this shader?
The textures are blend soft depending the rgb from the masktexture.
Should it not also be possible to do it in this way?:
Blend...
Tex1.. if r=10,g=0,b=0;
Tex2.. if r=20,g=0,b=0;
Tex3.. if r=30,g=0,b=0;
Tex4.. if r=40,g=0,b=0;
Tex5.. if r=50,g=0,b=0;
r,g,b means the color wink
At this way textures can't blend soft, I know. But is it possible to do like this?

I don't know how to programm a shader, it would be nice if someone have a small example for this.
Posted By: Slin

Re: Multitex Terrain + Normalmapping - More than three textures? - 03/23/14 19:28

Code:
some vertexshader(blubb)
{
pos = mul(matModelViewProj, vertpos);
texcoord = mul(matModel, vertpos).xz*tiling; //texture coordinate for the blended textures
maskcoord = vertexcoord0; //texture coordinates for the blend mask
}

other pixelshader(some)
{
mask = tex2D(masksampler, maskcoord);
if(mask.r < 0.1f)
   color = tex2D(tex0sampler, texcoord);
else if(mask.r < 0.2f)
   color = tex2D(tex1sampler, texcoord);
else if(mask.r < 0.3f)
   color = tex2D(tex2sampler, texcoord);
else if(mask.r < 0.4f)
   color = tex2D(tex3sampler, texcoord);
...
}



Just some ugly pseudo code, but should give you an idea on how easy one could realize something like that. If you want smooth blending you could maybe interleave the colors between the different channels or whatever. Or you can just use each textures alpha channel for its blend value, as one of the template effects already does it for endless textures.
BUT this whole approach also needs your own shading, also while the ifs probably arenīt that bad, it might be a better idea to only blend three or four textures and split the mesh into several parts, so you could have your paths use four textures blending to the grass to their sides which is then another model blending with some sand, flowers and rock or whatever.
A modern approach to the whole problematic would be virtual textures, which should be possible in some ways with DirectX9 I think, but I am not sure...
Posted By: sivan

Re: Multitex Terrain + Normalmapping - More than three textures? - 03/23/14 20:09

in my little editor I have a shader that uses 2 rgba blendmaps and 2 horizontal quad textures for tile textures (and a base colormap and an optional lightmap, and another 2 textures for shadowmapping), you can use it as a base. not really optimized, but can be extended to use 2 quad normal+specmap textures too. anyway, too many texture sampling seems to be a bit costy, I also consider a new approach to use more little terrains or terran models instead of one large terrain...
© 2024 lite-C Forums