使用 glTexParamteri(GL_Texture_2D, GL_TEXTURE_MAG_FILTER, ...) 和 glTexParamteri(GL_Texture_2D, GL_TEXTURE_MIN_FILTER, ...) 配置 OpenGL 时,OpenGL 如何决定在使用纹理(...)访问着色器中的纹理时使用哪个过滤器?
我唯一的猜测是它正在计算像素占用空间,但由于您可以在片段或顶点着色器中访问纹理,因此它无法知道什么纹理被投影到哪个基元上。
最佳答案
My only guess it's that it is calculating the pixel footprint
是的,这就是它的作用。它将通过计算纹理坐标相对于窗口空间 x
和 y
方向的导数来近似纹理空间中的像素足迹,并且它将通过 < em>2x2 像素四边形中的有限差分,就像 dFdx
and dFdy
GLSL functions 一样在工作中。它将使用两个偏导向量中较长的一个作为大小,并根据该值计算细节级别值。
but since you could access the texture in either the fragment or vertex shader it can't know on which primitive what texture is projected.
正确,这就是 GLSL specification, (Version 4.60) 的原因在 8.9 纹理函数 的开头说明了以下内容:
Texture lookup functions are available in all shading stages. However, automatic level of detail is computed only for fragment shaders. Other shaders operate as though the base level of detail were computed as zero
关于opengl - 在着色器中访问时,OpenGL如何决定使用MAG_FILTER和MIN_Filter?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49087945/