How to draw decals over a Skin

I’d like to blend a decal over a skin… I’ve 2 texture coords. one for the skin ‘ST0’, and one for the decal ‘ST1’ (the decal has an alpha channel, and is clamped in S,T to draw it just once and leave the rest of the skin unmodified)

This is what I’m doing… but it’s not working :_(

// the skin texture
glActiveTextureARB (GL_TEXTURE0_ARB);
glEnable (GL_TEXTURE_2D);
glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

// the decal blended over
glActiveTextureARB (GL_TEXTURE1_ARB);
glEnable (GL_TEXTURE_2D);
glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
glTexEnvi (GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_MODULATE);

glTexEnvi (GL_TEXTURE_ENV, GL_SOURCE0_RGB_ARB, GL_TEXTURE);
glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND0_RGB_ARB, GL_SRC_COLOR);
glTexEnvi (GL_TEXTURE_ENV, GL_SOURCE0_ALPHA_ARB, GL_TEXTURE);
glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND0_ALPHA_ARB, GL_SRC_ALPHA);

glTexEnvi (GL_TEXTURE_ENV, GL_SOURCE1_RGB_ARB, GL_PREVIOUS_ARB);
glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND1_RGB_ARB, GL_SRC_COLOR);
glTexEnvi (GL_TEXTURE_ENV, GL_SOURCE1_ALPHA_ARB, GL_TEXTURE);
glTexEnvi (GL_TEXTURE_ENV, GL_OPERAND1_ALPHA_ARB, GL_ONE_MINUS_SRC_ALPHA);

Anyone knows why it’s not working or how could be done?

_> Royconejo.

You could use glSubImage to modify the tatoo texture directly onto the skin, or you could place the tatoo directly on it and use glPolyOffset to make it in front.

use the combine extension theres a interpolate method there
whichll give u tex0alpha + tex1(1-alpha)

Hi.
If your card supports GL_EXT_texture_env_combine, you can use one of my tools for experiment with the extension.

You can find it at http://nervus.go.ro/resources
just download the executables(the link to the examples is broken), unpack it, and then run visualtc.exe.
The program is very easy to use, and it generates even the code to be copy pasted into your program…
enjoy.

if you need more info, e-mail me.
my address is nervus@go.ro

Thanks!

I’ve tried GL_DECAL and it works fine… the next thing I’d like to do is store those decals arranged in a larger texture cache, and then using the texture matrix modify the model’s UVs to get the correct decal… but there is another way to do it? if I use this method, how can I get the borders of the decal clamped? (as if I was using a single decal texture and GL_CLAMP)?

Thanks in advance.

[This message has been edited by royconejo (edited 01-30-2002).]