OpenGL透明/半透明 [英] OpenGL transparency/translucency

查看:314
本文介绍了OpenGL透明/半透明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对openGL中的Alpha混合有疑问...

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

我已经尝试了一些用于绘制透明对象的东西...通过在绘制透明面之前禁用GL_DEPTH_TEST并在重新绘制透明面之后重新启用GL_DEPTH_TEST,我看到了一个不错的(理想)结果...

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

不过,我决定先在启用GL_DEPTH_TEST的情况下绘制立体面,然后在禁用GL_DEPTH_TEST的透明面后进行绘制...

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

因此,很明显,如果我在禁用GL_DEPTH_TEST的情况下绘制透明面,我会看到里面的透明面(例如一个立方体),然后

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

所以,我的问题是...这是正确的吗? OpenGL是否具有魔术"方式来自动排序不透明和透明的面?

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

推荐答案

尽管这不是理想的结果,但我先绘制不透明的面孔然后再绘制透明的面孔还是得到了不错的结果...

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

这篇关于OpenGL透明/半透明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆