Need some help with layering a material file for terrain.

The place for artists, modellers, level designers et al to discuss their approaches for creating content for OGRE.
Post Reply
Steamforger
Gnoblar
Posts: 19
Joined: Fri Oct 21, 2005 11:32 pm

Need some help with layering a material file for terrain.

Post by Steamforger »

Maybe there is a better way to do it, but what i'm trying to accomplish is the following.
Start with a cracked dirt texture. The mask out some grass in some areas all over it. Then on top of that, there is a canyon/rift going through a part of the map. I want to layer a different texture onto the canyon. And then finally, have a detail texture that darkens the map in the valleys.

So far i've been able to accomplish the whole thing, except for when i try to create the canyon texture. It just winds up looking grey/white.
Essentially what i want, is a layer, upon a layer, upon a layer, etc. Each one alpha'd/masked out to what i need it for.
Here is the material file i've built. Maybe someone can point out what i'm doing wrong.
material Material_Terrain_01
{
receive_shadows on

{
technique
{
pass
{
texture_unit
{
texture W_Terrain_01_Base_Dirt_Cracked_01.tga
scale 0.05 0.05
}
texture_unit
{
texture W_Terrain_01_Alpha_Grass_01.tga
colour_op alpha_blend
scale 0.1 0.1
}
texture_unit
{
texture W_Terrain_01_Layer_Grass_01.tga
colour_op_ex blend_current_alpha src_texture src_current
scale 0.03 0.03
}



texture_unit
{
texture W_Terrain_01_Alpha_Canyon_Edge_Rocks.tga
colour_op alpha_blend
scale 1 1
}
texture_unit
{
texture W_Terrain_01_Layer_Canyon_Edge_Rocks.tga
colour_op_ex blend_current_alpha src_texture src_current
scale 0.03 0.03
}




texture_unit
{
texture W_Terrain_01_Layer_Detail_01.tga
colour_op alpha_blend
colour_op modulate
scale 1 1
}
}

// lighting pass
pass
{
ambient 1 1 1
diffuse 1 1 1

depth_func equal
scene_blend zero src_colour
}
}
}
}
This brings up another question for me. In this setup, i have created a separate texture to control the alpha/mask. Is there a way i can just use the alpha channel on the tga? If so how?
Thanks!
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 538

Post by Kojack »

Which gfx card are you using? Your material is using 6 textures in one pass, and quite a few cards (geforce 4's etc) can only handle 4 textures at once.
Steamforger
Gnoblar
Posts: 19
Joined: Fri Oct 21, 2005 11:32 pm

Post by Steamforger »

Radeon 9800
Thats fine if i can only layer 4 times, if i could compress the alpha masking into any of the textures.
Is there a way to use the alpha channel to mask out using my example above?
User avatar
xavier
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 9481
Joined: Fri Feb 18, 2005 2:03 am
Location: Dublin, CA, US
x 22

Post by xavier »

Ogre will break up the passes into multiple if the card cannot support the number of texture units you request. Of course, it's always better to do things manually in advance than to rely on a heuristic or systematic method at runtime.

To your second question:
That is what the alpha channel is for, unless you have multiple meanings for it. You can always use a single texture as 4 data channels if you have various mask meanings for them, but you are looking at programmable shaders at that point to take advantage of that.
User avatar
haffax
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 4823
Joined: Fri Jun 18, 2004 1:40 pm
Location: Berlin, Germany
x 8
Contact:

Post by haffax »

xavier wrote:Ogre will break up the passes into multiple if the card cannot support the number of texture units you request.
Ogre can't do this for most of the colour_op_ex operations, only the four colour_op blend modes are supported for pass splitting and if you don't provide a colour_op_multipass_fallback, then colour_op modulate is used, which is not appropriate here.

This is one thing wrong with your material. Another one is, that you don't disable lighting in your first pass. Lighting is done in the extra pass.
Colour_op alpha_blend only works in your case, if the alpha texture is alpha only and the other channels are all set to 0. Were I have to admit, that I don't am sure, if the alpha from the texture is then the current_alpha in the next texture_unit. To use the alpha from this texture and the current colour is far more obvious IMO.

Here is a working sample material from our project: http://svn.berlios.de/viewcvs/dsa-hl/mo ... iew=markup
team-pantheon programmer
creators of Rastullahs Lockenpracht
Post Reply