启用 Alpha 混合时几何形状不正确
我有一个测试应用程序,通过 Alpha 混合实现启用透明度。该应用程序是使用 SlimDX 用 C# 构建的。然而,在我的一个应用了 Alpha 混合的对象上,我得到了一种奇怪的“缺失三角形”效果(见下文)。
该物体几乎是一个圆柱体。
我想知道是否有在 3D 计算机图形和/或 alpha 混合使用方面更有经验的人能够为我指明正确的方向,以便我可以理解这个结果 - 并希望将其删除。
编辑
我尝试使用顺序无关的混合着色器,得到了相同的结果。看起来好像像素/片段由于深度测试失败而被丢弃。这对我来说没有任何意义。
I have a test application with enabled transparency achieved through alpha blending. The application is built in C# using SlimDX. However, on one of my objects that has alpha blending applied, I am getting a strange 'missing triangle' effect (see below).
The object is almost a cylinder.
I wondered if anyone more experienced in 3D computer graphics and/or the use of alpha blending might be able to point me in the right direction so I might understand this result - and hopefully remove it.
EDIT
I have tried to use an order independent blending shader and I get the same result. It would appear as though the pixels/fragments are being discarded due to failing the depth test. This does not make any sense to me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要选择一个与顺序无关的混合函数,或者尝试沿视图轴对三角形进行排序(这是不可能的)。请参阅此处原因。
编辑:
问题在于 Z 缓冲区阻止 OpenGL 绘制已绘制内容后面的像素。一般来说,这非常方便,但是当前面的东西是半透明的时,你需要看到后面的东西。
要获得正确的几何图形:
You need to select a blending function that is order independent or try to sort you triangles along the view axis (which is impossible). See why here.
EDIT:
The problem is that the Z buffer prevents OpenGL from drawing pixels that are behind things that have already been drawn. Generally, that's pretty convenient, but when the thing in front is translucent, you need to see the things that are behind it.
To get a correct looking geometry: