Jump to content
  • Advertisement
Sign in to follow this  
abolfoooud2

Blending and transperancy in OGL

This topic is 4673 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 facing a small problem when applying the transperancy technique. i have to spheres of radius 10, one in the front at position 0,0,0 and the otehr on the back at 0,0,-40. the front one is set to have the alpha value to 0.5 and the back one to have it as 1. i am enabling the blending using: glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); the blending works fine when i draw the back sphere first then the front one. but when i have the drawing in the reverse order, ie the front then the back, the back sphere disappears?!!! shouldnt it stay there since the front sphere is half transperatn???? note that i have glEnable(GL_DEPTH_TEST); any suggestions??? Abolfooud

Share this post


Link to post
Share on other sites
Advertisement
If you enable GL_DEPTH_TEST, then parts of surfaces behind previously drawn surfaces will not be rendered. To get alpha blending to work properly you'll need to sort the surfaces you render and put them in the pipe back to front. GL won't magically handle it for you.

Share this post


Link to post
Share on other sites
aaaah OK, i got the idea
i thought that even if the object is transperant and drawn first, all objects drawn later will be affected by its transperancy but not hidden.

thanx

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!