Sign in to follow this  
abolfoooud2

Blending and transperancy in OGL

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this