OpenGL transparency/translucency

眉间皱痕 提交于 2019-12-12 11:35:19

问题


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?


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/6352908/opengl-transparency-translucency

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!