Multi-Texturing

Blitz3D Forums/Blitz3D Programming/Multi-Texturing

Jeremy Alessi(Posted 2003) [#1]
When multi-texturing something like a terrain (mesh based and created in Max) what's the best way to use a mask to differentiate between textures showing details from different ones in different places?


Jeremy Alessi(Posted 2003) [#2]
Come on I know someone knows this?


Sunteam Software(Posted 2003) [#3]
I think I don't understand your question :/

Do you mean you want masked areas to show through differing textures that are multi-texed together?

If so why mask them when you could use one of the blending methods?


Jeremy Alessi(Posted 2003) [#4]
That's what I thought. The terrain should be textured with two textures that have certain parts masked in the texture and then blend them together according to the textures, right? I've never done this sort of thing and now I'm working with an artist who is used to having a separate masking layer. Basically, I just want to know how other people are creating nice multi-textured terrains and importing them to .b3d format?


skidracer(Posted 2003) [#5]
This technique allows two textures on a surface with a selector mask and lightmap using 5 texture stages. It is an extension of Mark's original insaner demo that calculates the differnce map with alternative method.

I am currently using a modified version of this code that subtracts the median of each texture color from every pixel adding it to the lightmap giving more contrast.

The shader algorithm can be described as:

dest = [texture_difference] * [selector_mask] + [second_texture] + [adjust_mask] * [lightmap]


Jeremy Alessi(Posted 2003) [#6]
Thanks!


jhocking(Posted 2003) [#7]
Note that the code skidracer links to doesn't work on my system (450MHz PIII w/ATI Rage Fury Pro.) Specifically I only see a single rocky white texture. The insaner demo it is based on does work however.


Sweenie(Posted 2003) [#8]
Change the following line...
texture1=texture0;LoadTexture("MossyGround.bmp")
to this
texture1=LoadTexture("MossyGround.bmp")


jhocking(Posted 2003) [#9]
Still not right but closer. In this case I do see the mossy ground with a white path but everything is blended as opposed to a crisp mask.

I should point out that I've been doing some interesting mask-style effects using the second UV set (you can manipulate it in Ultimate Unwrap.) This may or may not be useful to you however; among other things, this doesn't work with heightmap based terrain (like Blitz's built in terrain system) since you need to have a pregenerated model whose UV coordinates you modify. I'll probably be writing a tutorial on how to do this and ask Brad to post it on www.unwrap3d.com

ADDITION: If you are going to use that code, make sure to add the flag for multitexturing to every CreateTexture call (there are two.) Otherwise there is ugly shimmering/pixel interference of the texture far away. In other words CreateTexture(w,h) becomes CreateTexture(w,h,8)


Jeremy Alessi(Posted 2003) [#10]
We are using pregenerated 3D model terrains. It would be good to know how to use Unwrap to accomplish good mult-texturing and masking.


jhocking(Posted 2003) [#11]
Well if/when I write the tutorial I'll mention it in the forum. In the meantime the gist is to create a sort of decal sheet image with transparency. Then you use the second UV set to place decals onto the terrain. This is an easy way to place small details like rocks and flowers or even larger stuff like dirt patches and paths (although for that last one you will probably also need to model the mesh in a way which facillitates the UVs.)

Another thing to consider for texturing terrain is detail mapping. To avoid an ugly tiled look for your ground covering (eg. grass) you use a simple image of several shades of green as the base color layer, stretched over the entire terrain surface. Then for detail you use a black and white image of grass or whatever, set to multiply blend, which is tiled over the terrain surface. This way you get non-repeating color information from the base texture but more detailed tiles from the multiply blended layer.