PDA

View Full Version : Multitexturing Question..



lud2k
01-20-2006, 09:50 AM
Hello everybody :)

I have a little question about multitexturing..
When you add a texture over an other, more the color of the second picture is white less the color is visible..
I would like the white color of the texture to be totaly transparent and the other color to be totally visible.. (I tried to do a tga picture and put it with glTexEnvf (GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_REPLACE) but it doesn't seem to understand transparent colors.. )
Any idea how i can do this ?

A little screenshot of the problem..
http://lud2k.hd.free.fr/Travail/help.jpg
I want the central part not to be transparent :( ...

Thanks a lot,
Ludovic

dorbie
01-20-2006, 10:52 AM
I think you're looking for a DECAL texenv (no need for a combiner mode).

You have several options you should experiment with various combiner modes or try to understand what the arithmetic is you need and look for that in the available modes, possibly adjusting content for the right overall result.

lud2k
01-20-2006, 11:12 AM
yeahh :-)

thanks a lot dorbie, it's working perfect. I've put:

if (type == 1) {
glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
} else {
glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
glTexEnvf (GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_MODULATE);
}

lud2k
01-20-2006, 11:55 AM
little new problem...
when i turn of lights.. everything is dark but not the texture. the texture don't change with lights :(
How can i fix this ?

dorbie
01-20-2006, 12:03 PM
Hmm, you'll have to do the modulate using primary color with the last unit.

You use crossbar for this.

The first texenv has the first texture and second texture in and the decal call, I'm not sure which goes in arg 0 and arg 1, experiment.

The second texture unit takes PREVIOUS result and PRIMARY_COLOR as the inputs and uses a MODULATE texenv.

This will decal then apply vertex lighting but remember any vertex color will be applied regardless of texture.

lud2k
01-21-2006, 01:30 AM
I've been searching how to do it but i didn't find anything.

I'm using 3 textures. the first one is the ground, the second is the ground detail (to make it more realistic) and the third is the path (where i used DECAL as you said).

Do you know where i can find a tutorial on it or can you show me what functions or a small example on how to do it ?

Thanks,
Ludovic.

dorbie
01-21-2006, 10:42 AM
Because you have 3 textures you just need to combine them first and move the vertex color modulation to the end, the key is you use crossbar to modulate using the light source color with the last unit and the PREVIOUS color.

So, take your working decal code and remove the early color modulation, i.e. ignore vertex lighting, then take a later texture unit and use PREVIOUS color and the PRIMARY_COLOR to modulate the texture result with lighting:

http://oss.sgi.com/projects/ogl-sample/registry/ARB/texture_env_crossbar.txt

In this process you should be able to eliminate the earlier texture unit you performed the vertex color MODULATE on, doing the detail texture modulate there instead, so you're not adding a unit just moving the modulate to the end of the process. Crossbar gives you the power to do this by allowing you to feed the vertex color into the last unit directly instead of passing it through the texture unit daisy chain.