Jump to content
  • Advertisement
Sign in to follow this  
Floating

OpenGL Textures and transparency. My texture's alpha values are not used!

This topic is 5470 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I am displaying a textured quad in transparency mode with glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA); however my texture never uses the provided alpha-values (it is an RGBA texture). However if I add: float rgba[]={1.0f,1.0f,1.0f,0.5f}; glMaterialfv(GL_FRONT_AND_BACK,GL_DIFFUSE,rgba); my texture is displayed in transparency (50% transparency). But I want parts of my texture to be completely transparent, other parts completely opaque. How can I tell opengl to use the alpha values of my texture? Thanks

Share this post


Link to post
Share on other sites
Advertisement
the internal mode parameter to glTexImage*, glCopyTextureImage* or gluBuild*Mipmaps must be either GL_RGBA, GL_LUMINANCE_ALPHA, GL_COMPRESSED_RGBA_ARB or GL_COMPRESSED_LUMINANCE_ALPHA_ARB to have the server store the alpha component of the texture.
You also have to pass the alpha value to glTexImage*, glCopyTextureImage* or gluBuild*Mipmaps by specifying format to be one of the upper.

Share this post


Link to post
Share on other sites
Using glMaterial implices also that you should use glLight etc, to light up your scene. Make sure that you use a opengl memory representation with alpha in it. Or you could try to set the alpha value with glColor and see what happens.

Share this post


Link to post
Share on other sites
I have a similar question. My game also sets up its textures using:

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

I want to be able to pass glColor4f before each vertex in ordet to get a fading effect on the texture. This is so I can implement texture splatting.

Anyway, When I load my texture (even if its GL_RGBA) It ignores whatever values I pass in glColor4f.

How do I get it where I can manipulare texture transparancy?

It would be very helpfull if someone could give me a quick code example. Thank you very much.

Share this post


Link to post
Share on other sites
*bump*

I think my question may have been overlooked as it is asked in someone elses post, but rather than double post I offer this BUMP :D

I have been fiddling with it some more and still havnt been able to get a texture to fade. This should be something so simple, does anyone have an idea about how to do this?

I want to be able to use glColor4f to vary the alpha per point in order ot achive "texture splatting".

thanks again!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!