Skip to main content
GameDev.net gamedev.net
🔒 Locked

blending

Started by Jehsup Jul 14, 2003 at 12:10 PM 3 replies 550+ views
Original Post
Jehsup
Jehsup
Hello, I am having trouble with blending on my models. My model is an airplane with transparencies for the props. I can get the alpha channel (black) on the props image to match the glClearColor , but this basically only turns the alpha portion of the image to my clear color and doesnt let the wing portion of the model come through the "transparent" portion of the texture. image settings: glTexImage2D(GL_TEXTURE_2D, 0,4, Width, Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, PixelBuffer); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); blend settings: glEnable( GL_BLEND ); glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA ); Then draw it: Is there a texture flag that I need to set differently ? I have tried turning culling off, setting the depth mask to false,etc. I have also tried setting the blend func to every conceivable combinination: Thanks in advance for any light you can shed on this. J
Redge
Redge
mmmh !

Don''t know why this doesn''t work, it should...

1/ Perhaps your video card doesn''t support transparency
2/ you say "Then draw it:"
are you sure there is nothing like glDisable(GL_BLEND); or other "blend parameter" between the posted code and the draw code ?
3/ glTexImage2D(GL_TEXTURE_2D, 0,4, Width, Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, PixelBuffer);
I think it should work but perhaps with GL_RGBA instead of 4 for the third parameter ?
glTexImage2D(GL_TEXTURE_2D, 0,GL_RGBA, Width, Height, 0, GL_RGBA, GL_UNSIGNED_BYTE, PixelBuffer);

Sorry, that''s all I can say, I see nothing more...
Redge
MazyNoc
MazyNoc
Transparent stuff should be drawn last, and sorted back to front.
Sander
Sander
You need 32-bit textures (that is: you need a texture with an alpha channel, like 32-bit TGA''s). MazyNoc is right: draw the tarsparent stuff lasts if you do blending.

There is a better way though: Use alpha testing for the propellors:

glAlphaFunc(GL_GREATER, 0.95f);
glEnable(GL_ALPHA_TEST);
Draw();
glDisable(GL_ALPHA_TEST);

Sander Maréchal
[Lone Wolves Game Development][RoboBlast][Articles][GD Emporium][Webdesign][E-mail]


GSACP: GameDev Society Against Crap Posting
To join: Put these lines in your signature and don''t post crap!
Jehsup
Jehsup
Thanks, All, the sorting worked for my blending problem, and thanks Sander, the alpha test is better for the prop. I appreciate the comments.

J

Topic Locked

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

Sign in to reply to this topic.