渲染具有相同 z 顺序的透明 3D 形状(四边形)
我使用 OpenGL 渲染两个具有相同 z 值的四边形。当我启用深度时,我会得到以下图像,但是当它关闭时,我会得到我需要的一种水果而不是另一种水果。是否可以像我想要的那样绘制具有相等 z 的四边形?我的 OGL 设置:
glEnable(GL_BLEND); glEnable(GL_ALPHA_TEST); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
编辑 抱歉,我忘了提及我调用的左侧最上面的四边形首先渲染,
当我渲染具有不同 ZI 的四边形时,我使用正交 EDIT +1 得到相同的图像,如何修复它?
I render two quads with OpenGL with equal z. When I have DEPTH enabled I get following image, but when it is off I get what I need one fruit over another. Is it possible to draw quads with equal z, as I want? My OGL settings:
glEnable(GL_BLEND); glEnable(GL_ALPHA_TEST); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
EDIT sorry I forgot to mention that left topmost quad I call to render first, and I use orthographic
EDIT +1 when I render quads with different Z I get the same image, how to fix it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
z 缓冲区不关心透明度,因此您必须按四边形的大致深度对它们的绘制顺序进行排序。
我会将它们的深度更改为不同的(您可以使用正交投影使它们显示相同的大小),然后首先绘制进一步的四边形。
另外,即使没有透明度,在相同深度绘制两个多边形也不是一个好主意,因为 z-战斗。
The z-buffer doesn't care about transparency and so you have to sort the drawing order of your quads by their approximate depth.
I would change their depth to be different (you can use an orthographic projection to have them appear the same size) and then draw the further quad first.
Also, it is never a good idea to draw two polygons at the same depth even without transparency because of z-fighting.
我进行了实验,发现在渲染立方体时遇到了同样的问题,所以问题是由于顶点排序以及可能的背面剔除参数造成的。
I experimented and saw that I have same problem when I render cube, so the problem was because of vertices ordering, and possibly backface culling parameters.