含义和glPolygonOffset因素参数的用法 [英] Meaning and usage of the factor parameter in glPolygonOffset
问题描述
我难以理解的第一个参数的含义 glPolygonOffset
功能。
I am having difficulty understanding the meaning of the first parameter in glPolygonOffset
function.
void glPolygonOffset(GLfloat factor, GLfloat units);
的官方文档说系数
指定用于创建一个可变深度为每个多边形偏移的比例因子
Specifies a scale factor that is used to create a variable depth offset for each polygon.
和
它是从相应的顶点的深度值内插后的各片段的深度值将被抵消。偏移的值是因子×DZ + R×单元,其中DZ为相对于多边形的屏幕区域深度的变化的测定,而r是保证产生可解析为一个给定的偏移量的值最小实施
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.
我明白了什么研究
和单元
是。我不明白的是什么 DZ
是,即什么是由深度价值的多边形的屏幕面积变化的测量,为什么会意味着我以往任何时候都需要系数设置为0以外的任何
I understand what r
and unit
are. What I don't understand is what DZ
is, i.e. what is meant by the "measurement of the change in depth value to the screen area of the polygon" and why would I ever need to set factor to anything other than 0.
如果我希望我的线框,以抵消所有我需要的是添加/ substact几个单位/从深度值,不是吗?有什么因素参数的意义,目的和使用实例(和文件中提到的DZ)?
If i want my wireframe to be offset all I need is to add/substact a couple of units to/from the depth value, don't I? What's the meaning, purpose and usage example of the factor parameter (and the DZ mentioned in the document)?
推荐答案
我必须在这里承认一些无知,但我发现的这篇文章这也解释了它。他们说:
I have to admit some ignorance here, but I found this article which explains it. They say:
要实现突出固体物体的一个很好的渲染没有视觉假象,你可以添加一个正偏移到实体对象(推离你而去)或负偏移线框(向外拉出)。最大的问题是:多少偏移量是够了吗?不幸的是,要求的偏差取决于各种因素,包括每个多边形的深度斜率和在线框的线的宽度。
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.
他们然后解释深度坡度是这样的:
They then explain the depth slope this way:
深度斜率是由在x或y坐标的变化除以在Z(深度)值的变化,因为你遍历多边形。深度值是在窗口坐标,钳位到范围[0,1]。为了估计多边形(偏移式米)的最大深度坡度,使用这个公式:M = {最大值| delV /德尔斯|,| delV / DELT |}。 (其中,德尔是一个偏导数)
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)
因此,他们得出这样的结论:
So they conclude that:
有关的是平行于所述近端和远端剪切平面多边形,深度斜率为零。 [...]对于多边形是在一个大的角度向剪切平面,深度斜率可以比零显著更大,而较大的,可能需要偏移。小,无零因子,如0.75或1.0的值,可能足以产生不同深度的价值观和消除不愉快的视觉假象。
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.
这篇关于含义和glPolygonOffset因素参数的用法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!