opengl - opengl中的背面多边形

标签 opengl rendering culling

在 OpenGL 中,您只能绘制背面多边形、正面多边形或两者。如果渲染流形三角形网格,则清除帧缓冲区但不清除深度缓冲区,然后再次仅渲染背面多边形。期望看到什么?

我认为以下给我的答案是错误的:

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

但我认为答案是:

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.

哪个答案是正确的?

最佳答案

这要看情况!假设网格是一个二维流形的对象(即拓扑等效于表面上任何点周围足够小的区域上的平面),并且第一遍渲染正面和背面的三角形或仅渲染正面的三角形,并且深度函数是 GL_LESS 或 GL_LEQUAL 那么第二段是正确的,因为前面的三角形总是在后面的三角形前面,因此总是会导致深度测试失败。

当然,如果您使用 GL_GREATER 或 GL_GEQUAL 作为深度函数,则反之亦然,因此第一段是正确的。

关于opengl - opengl中的背面多边形,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4465667/

相关文章:

algorithm - 与 3d 应用程序的渲染器相比,为什么游戏渲染器如此之快?

c# - Windows 窗体启动时出现尴尬的 "Resizes"

Android OpenGL ES 渲染复杂对象不正确

opengl - 八叉树遮挡

opengl-3 - 使用着色器时高效的截锥体剔除

opengl - 仅使用模板测试进行遮挡查询

c++ - 在内存网格上应用 Assimp 后处理

c++ - OpenGL glMatrixMode 帮助

c++ - 你能制作自己的渲染管线吗?

jquery - iOS 7 Safari jquery text() 没有被渲染