为什么glPolygonOffset与多边形的斜率有关
我正在使用 OpenGL 进行阴影贴图。将深度与阴影贴图进行比较时存在 z-fighting 问题。我可以使用 glPolygonOffset 解决这个问题。我知道这个函数有助于稍微推动(或拉动)多边形,从而解决深度冲突问题。 但我对 glPolygonOffset 函数有疑问。我不清楚为什么多边形的斜率与偏移量有关。
来自此处:
需要因子参数来确保对于观看者来说几乎边缘的填充图元的正确结果。在这种情况下,由两个共面基元生成的同一像素的 Z 值之间的差异可能与 X 或 Y 中的最大 Z 斜率一样大。对于几乎边缘上的基元,该 Z 斜率将很大,并且几乎不存在对于正面基元。通过因子参数,您可以将这种类型的变量差异添加到生成的深度偏移中。
这里我不知道为什么“两个共面基元生成的同一像素的 Z 值之间的差异可能与 X 或 Y 中的最大 Z 斜率一样大”。
I am doing shadow mapping using OpenGL. There is a z-fighting problem when comparing the depth with the shadow map. I can solve the problem using glPolygonOffset. I know this function helps push(or pull) the polygon a little bit so that the z-fighting problem is solved.
But I have a question about the function glPolygonOffset. I do not know clearly why the slope of the polygon is related to the offset.
From here:
The factor parameter is required to ensure correct results for filled primitives that are nearly edge-on to the viewer. In this case, the difference between Z values for the same pixel generated by two coplanar primitives can be as great as the maximum Z slope in X or Y. This Z slope will be large for nearly edge-on primitives, and almost non-existent for face-on primitives. The factor parameter lets you add this type of variable difference into the resulting depth offset.
Here I do not know why "the difference between Z values for the same pixel generated by two coplanar primitives can be as great as the maximum Z slope in X or Y."
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果多边形具有 Z 斜率,则像素左边缘和右边缘之间的 z 坐标存在差异。
因此,要将某些内容放在前面,您必须确保它位于前面,无论 z 坐标在像素中的哪个位置计算。
If the polygons have Z slope, then there's a difference in the z-coordinate between the left and right edge of the pixel.
So to put something in front, you have to make sure that it's in front no matter where in the pixel the z-coordinate is calculated.