glsl&变化值的透视校正 [英] glsl & perspective correction of varying values
问题描述
光栅化器是否使用透视校正对每个变化的顶点值(或在超出"顶点着色器的glsl值的较新版本中)进行插值?这个硬件依赖吗?
is every varying vertex value (or in newer versions of glsl values that go "out" of a vertex shader) interpolated by the rasterizer using perspective correction? is this hardware dependant?
发生剪切时,如何计算剪切顶点处的值?
when clipping occurs, how are the values at the clipping vertices calculated?
我尝试撤消透视校正,并注意剪切后的多边形的奇怪行为,我想更好地了解幕后情况.
I try to undo perspective correction and notice strange behaviour for polygons that are clipped and I would like to understand better what is going on behind the scenes.
推荐答案
Pre-GL 3.0,影响透视正确插值的唯一方法是使用提示.通常,glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)
将激活所有变化的透视校正插值,而glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST)
通常将其关闭.请注意,这些只是驱动程序提示,仅此而已;驾驶员没有没有以这种方式做出反应.
Pre-GL 3.0, the only way to affect perspective-correct interpolation is with a hint. Generally, glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST)
will activate perspective-correct interpolation on all varyings, while glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST)
will generally turn it off. Note that these are driver hints and nothing more; drivers don't have to react this way.
在GLSL 1.30+(OpenGL 3.0+)中,您可以强制以特定方式对每个输出/输入进行插值. 插值限定符 smooth
表示透视正确;如果您未指定限定符,则为默认设置. noperspective
意味着...显而易见.
In GLSL 1.30+ (OpenGL 3.0+), you have the ability to force each output/input to interpolate in a specific way. The interpolation qualifier smooth
means perspective-correct; this is the default if you don't specify a qualifier. noperspective
means... the obvious.
剪辑总是以某种方式进行,就像它没有被剪辑(或在硬件精度范围内足够接近)一样.因此,如果正确地对某个值进行透视插值,则为裁剪后的顶点生成的值也必须使用透视正确的插值.
Clipping is always done in such a way that it will work exactly as if it weren't clipped (or near enough within hardware precision). So if a value is interpolated perspective-correctly, then the value generated for the clipped vertex must also use perspective-correct interpolation.
这篇关于glsl&变化值的透视校正的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!