Blending and transperancy in OGL

Started by
3 comments, last by abolfoooud2 18 years, 7 months ago
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
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.
glDepthMask(false)
glDepthMask(false)
glEnable( GL_DEPTH_TEST );
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

This topic is closed to new replies.

Advertisement