4
votes

I have a question with alpha blending in openGL...

I've tried some stuff for drawing transparent objects... I've seen a nice (ideal) result by disabling GL_DEPTH_TEST before drawing the transparent faces and re-enable GL_DEPTH_TEST again back after drawing the transparent face...

Obviously I've noticed that depending on the order that I draw the different faces I got a result or another...

However I've decided simply to draw solid faces first with GL_DEPTH_TEST enabled and after the transparent faces with GL_DEPTH_TEST disabled...

So, obviously if I draw transparent faces with GL_DEPTH_TEST disabled I see transparent faces which are inside, (for example a cube), then

So, my question is... Is this correct? Does OpenGL have a "magic" way to order the opaque and transparent faces automaticly?

2
take a look at GL_ALPHA_TEST or Shaders. That should help you.Amir Zadeh

2 Answers

5
votes

Does OpenGL have a "magic" way to order the opaque and transparent faces automaticly?

No. You must sort transparent objects yourself. Or you can use an order-independent transparency algorithm. There are several available, but none of them are "magic" and most of them take up lots of performance.

0
votes

Despite it is not the ideal result I got nice results by drawing first opaque faces and then transparent faces...