gpt4 book ai didi

opengl - opengl中的背面多边形

转载 作者:行者123 更新时间:2023-12-02 09:13:43 26 4
gpt4 key购买 nike

在 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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com