- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我很难理解 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.
我理解r
和unit
是什么。我不明白的是 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/
我最近在玩 glPolygonOffset( factor, units ) 并发现了一些有趣的东西。 我使用了 GL_POLYGON_OFFSET_FILL,并将因子和单位设置为负值,以便拉出填充的
我有以下代码: glEnable(GL_POLYGON_OFFSET_LINE); glPolygonOffset(1,1); // or 40,40 etc... doesnt help at al
我是一名优秀的程序员,十分优秀!