0 registered members (),
18,161
guests, and 5
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Multitex Terrain + Normalmapping - More than three textures?
#438908
03/23/14 10:47
03/23/14 10:47
|
Joined: Aug 2008
Posts: 394 Germany
Benni003
OP
Senior Member
|
OP
Senior Member
Joined: Aug 2008
Posts: 394
Germany
|
Hi, I need a terrainshader with a masktexture as fogman wrote: http://www.opserver.de/ubb7/ubbthreads.p...true#Post361297Is 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  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.
|
|
|
Re: Multitex Terrain + Normalmapping - More than three textures?
[Re: Benni003]
#438935
03/23/14 19:28
03/23/14 19:28
|
Joined: May 2005
Posts: 2,713 Lübeck
Slin
Expert
|
Expert
Joined: May 2005
Posts: 2,713
Lübeck
|
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...
|
|
|
|