OpenGL:渲染两个相交的透明平面:不可能吗? [英] OpenGL: Rendering two transparent planes intersecting each other: impossible or not?

查看:118
本文介绍了OpenGL:渲染两个相交的透明平面:不可能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很难解决这个问题,似乎无法渲染.

I ran to this problem hard, it seems impossible to render.

如何解决这个问题?我希望OpenGL像在下面这张图片的右侧一样呈现它:

How can one solve this problem? I want the OpenGL render it like it looks at the right side of this image below:

推荐答案

您需要在禁用深度测试并使用与顺序无关的混合公式的同时渲染平面.

You need to render your planes while disabling the depth test and using an order independent blending formula.

如果背面有一些不透明的几何图形,请绘制这些几何图形,将深度缓冲区设置为只读而不是禁用深度测试,然后渲染透明的几何图形.

If you have some opaque geometries on the back, draw those ones, put the depth buffer to read only instead of disabling the depth test, and render the transparent ones.

还有一些用于解决该常见问题的高级技术,例如深度剥皮.

There are also advanced techniques dealing with that common problem, like depth peeling.

编辑

您可以使用以下方式将深度缓冲区设为只读: glDepthMask(GL_FALSE) .

You can put the depth buffer in read only using: glDepthMask(GL_FALSE).

这是一篇很好的文章,解释了为什么不能达到完美的透明度:透明度排序.还请参见具有双深度剥离功能的订单独立透明性这篇文章涵盖了两种方法(一种方法非常简单,单遍),用于具有精确(或近似)顺序无关的透明度.

Here is a good article explaining why you can't achieve the perfect transparency: Transparency Sorting. Also give a look at Order Independent Transparency with Dual Depth Peeling article which covers two methods (one is quite straightforward and single pass) used to have exact (or approximate) order independant transparency.

我忘了提及 Alpha to Coverage .

这篇关于OpenGL:渲染两个相交的透明平面:不可能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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