opengl中的背面多边形
在 OpenGL 中,您只能绘制背面多边形、只能绘制正面多边形或两者都绘制。如果渲染流形三角形网格,则清除帧缓冲区但不清除深度缓冲区,然后再次仅渲染背面多边形。期望看到什么?
我认为以下给我的答案是错误的:
您应该看到背面朝上 三角形。第一个渲染通道将 结果深度缓冲区具有 三角形的深度值是 正面。第二次渲染通道 你正在渲染背面 三角形,因此那些具有 最大深度值。每个三角形 被光栅化的会有它的深度 与当前深度相比的值 该像素的值。既然深度 缓冲区设置为所有最接近的深度 值(小值)但是 区分最远深度 值(大值)背面 将渲染三角形。”
但我认为答案是:
由于深度缓冲区未清除,并且仍然包含正面三角形的深度值,因此它会丢弃背面三角形,并且不显示任何内容。
哪个答案是正确的?
In OpenGL you can draw only back-facing polygons, only front facing polygons or both. If you render a manifold triangle mesh, then clear the frame-buffer but not the depth buffer, then again render only the back facing polygons. What do expect to see?
I think the following answer given to me is wrong:
You should see the back facing
triangles. The first render pass will
result in the depth buffer having the
depth values of the triangles that are
front facing. The second render pass
you are rendering the back facing
triangles, hence those that have the
greatest depth value. Every triangle
that is rasterized will have its depth
value compared to the current depth
value for that pixel. Since the depth
buffer is set to all the closest depth
values (small values) but is
discriminating on the farthest depth
values (large values) the back facing
triangles will be rendered."
But I think the answer is:
Since the depth buffer is not cleared, and still contains the depth values of the front facing triangles, it would throw out the back facing triangles, and display nothing.
Which answer is correct?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这取决于!假设网格是一个二维流形的对象(即拓扑等效于表面上任何点周围足够小的区域上的平面),并且第一遍渲染正面和背面的三角形或仅渲染正面的三角形,并且深度函数是 GL_LESS 或 GL_LEQUAL 那么第二段是正确的,因为正面三角形始终位于背面三角形的前面,因此总是会导致深度测试失败。
当然,如果您使用 GL_GREATER 或 GL_GEQUAL 作为深度函数,则反之亦然,因此第一段是正确的。
It depends! Assuming the mesh is of an object that is a 2-dimensional manifold (i.e. topologically equivalent to a plane over sufficiently small areas around any point on the surface) and the first pass renders front- and back-facing triangles or just front-facing ones, and the depth function is GL_LESS or GL_LEQUAL then the second paragraph is right, since the front-facing triangles are always in front of the back-facing triangles and hence will always cause the depth test to fail.
Of course, if you use GL_GREATER or GL_GEQUAL as your depth function, the reverse is true so the first paragraph is correct.
我认为第二段是错误的。
想象一下莫比斯带,它是一个封闭的流形。您可以清楚地看到一些靠近眼睛的背面三角形(白色,正面黑色)。在第二遍中,它们将通过深度测试并进行渲染:
I think the second paragraph is false.
Imagine a Moebius band which is a closed manifold. You can see clearly some back facing triangles (in white, front facing are in black) that are closer to the eye. In the second pass they will pass the depth test and be rendered: