Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (AndrewAMD), 1,310 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
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 Offline OP
Senior Member
Benni003  Offline 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#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.

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 Offline
Expert
Slin  Offline
Expert

Joined: May 2005
Posts: 2,713
Lübeck
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...

Re: Multitex Terrain + Normalmapping - More than three textures? [Re: Slin] #438937
03/23/14 20:09
03/23/14 20:09
Joined: Mar 2011
Posts: 3,150
Budapest
sivan Offline
Expert
sivan  Offline
Expert

Joined: Mar 2011
Posts: 3,150
Budapest
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...


Free world editor for 3D Gamestudio: MapBuilder Editor

Moderated by  Blink, Hummel, Superku 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1