opengl - 在着色器中访问时,OpenGL如何决定使用MAG_FILTER和MIN_Filter?

标签 opengl glsl mipmaps

使用 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

是的,这就是它的作用。它将通过计算纹理坐标相对于窗口空间 xy 方向的导数来近似纹理空间中的像素足迹,并且它将通过 < 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/

相关文章:

c++ - 找出 OpenGL 中 C++ 类的步幅

math - 3d 中纹理坐标的透视校正

opengl - 如何渲染带纹理的四边形以便淡化不同的角?

opengl - 如何在 OpenGL 中动态启用/禁用纹理 mip-map?

java - 如何将 GUI 组件放入 OpenGL 屏幕中

opengl - 关于 OpenGL 布局 std140 统一 block 中的数组

performance - 是什么导致了 GLSL 着色器的性能突破点?

OpenGL 计算阶段与其他阶段

c++ - OpenGL 纹理缩小伪像

java - 为什么 mipmapping 几乎没有给我带来任何性能提升?