gpt4 book ai didi

c - glPolygonOffset中factor参数的含义和用法

转载 作者:太空狗 更新时间:2023-10-29 16:54:00 25 4
gpt4 key购买 nike

我很难理解 glPolygonOffset 函数中第一个参数的含义。

void glPolygonOffset(GLfloat  factor, GLfloat units);

The official documentation说那个因素

Specifies a scale factor that is used to create a variable depth offset for each polygon.

还有那个

each fragment's depth value will be offset after it is interpolated from the depth values of the appropriate vertices. The value of the offset is factor × DZ + r × units , where DZ is a measurement of the change in depth relative to the screen area of the polygon, and r is the smallest value that is guaranteed to produce a resolvable offset for a given implementation.

我理解runit 是什么。我不明白的是 DZ 是什么,即“测量多边形屏幕区域的深度值变化”是什么意思,以及为什么我需要将因子设置为0 以外的任何值。

如果我想让我的线框偏移,我只需要在深度值中添加/减去几个单位,不是吗? factor参数(以及文档中提到的DZ)的含义、用途和使用示例是什么?

最佳答案

我不得不承认这里有些无知,但我找到了this article这解释了它。他们说:

To achieve a nice rendering of the highlighted solid object without visual artifacts, you can either add a positive offset to the solid object (push it away from you) or a negative offset to the wireframe (pull it towards you). The big question is: "How much offset is enough?" Unfortunately, the offset required depends upon various factors, including the depth slope of each polygon and the width of the lines in the wireframe.

然后他们这样解释深度斜率:

The depth slope is the change in z (depth) values divided by the change in either x or y coordinates, as you traverse a polygon. The depth values are in window coordinates, clamped to the range [0, 1]. To estimate the maximum depth slope of a polygon (m in the offset equation), use this formula: m = max {|delV / delS|,|delV / delT|}. (where del is a partial derivative)

因此他们得出结论:

For polygons that are parallel to the near and far clipping planes, the depth slope is zero. [...] For polygons that are at a great angle to the clipping planes, the depth slope can be significantly greater than zero, and a larger offset may be needed. Small, non-zero values for factor, such as 0.75 or 1.0, are probably enough to generate distinct depth values and eliminate the unpleasant visual artifacts.

关于c - glPolygonOffset中factor参数的含义和用法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13431174/

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