Skip to main content
gamedev.net
🔒 Locked

Texture Transparency!

Started by golgoth 5 replies 1.1k views
Original Post
golgoth
golgoth
hi all! it must be an easy solution for this one... i just want an opacity on a texture map... to allow the underlying color of the primitive to show through... no need to use alpha channel... only a level of opacity on the texture where i can still see the mesh underneath 100% opac. the gl fac they came up with: use glTexEnv(), and set the texture environment mode to GL_BLEND. In this case, you'd want to leave the texture environment color to its default value of (0,0,0,0). well, so far with those 2 lines: glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND); glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, l_texture->GetBlendColor()); im getting kind of inverse color of the texture... the alpha value doesnt seam to do anything... what am i missing here? thx
Matsy
Matsy

If your color is working... on the map... but the alpha is not working with the background I think putting this in there might help a bit.

glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

I hope this helps...
golgoth
golgoth
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

will affect the vertices... i only want the texture to be tranceparent!

hope we dont need multipass to do this...

Matsy
Matsy
OK... I re-read the post. So basically your not doing alpha blend... ooops...

What part of the color looks messed up. The color inside the (0,0,0,0) or outside?

I hope im understanding this right...
golgoth
golgoth
actualy if a pass a color lets say 0,0,0,0.5 or 1,1,1,0.5 (im not sure)

i want my texture to be 50% transparent

if we do 1,1,1,1

will see the textuire 100%

if we do 0,0,0,0 the texture will be invisible but will still see the mesh 100%!

a texture opacity basicly!
cwhite
cwhite
I don't know of any simple ways to do this, but I do know that it can be done in just a few lines of code with multi-texturing or with a fragment program. I would recommend biting the bullet and learning how to use multi-texturing. It'll only take up one evening of screwing around with the OpenGL extension registry to figure it out and it will be a worthwhile skill to have. Another option would be to learn GLSL. This would take a lot more of your time, but the benefits are much greater (you can texture much more flexibly with a fragment program than with register combiners).
golgoth
golgoth
after experiencing alot with combiners... i got this to work:

glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, l_texture->GetAlpha());
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
glTexEnvf(GL_TEXTURE_ENV, GL_COMBINE_RGB_ARB, GL_INTERPOLATE);

works pretty good actualy... but for some reson i doubt its the right way to do it!

GLSL... any good place you can refer to start with?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.