How to determine what level of mipmap was used when sampling the texture in the shader of the GLSL fragment?
I understand that I can manually set a specific level of texture mipmap using the textureLod(...) method:
uniform sampler2D myTexture; void main() { float mipmapLevel = 1; vec2 textureCoord = vec2(0.5, 0.5); gl_FragColor = textureLod(myTexture, textureCoord, mipmapLevel); }
Or I could automatically select the mipmap level using texture(...) , for example
uniform sampler2D myTexture; void main() { vec2 textureCoord = vec2(0.5, 0.5); gl_FragColor = texture(myTexture, textureCoord); }
I prefer the latter, because I trust the judgment of the driver regarding the corresponding mipmap level more than myself.
But I would like to know what level of mipmap was used in the automatic sampling process to help me rationally try neighboring pixels. Is there a way in GLSL to access information about what level of mipmap was used to automatically select a texture?
source share