How does a GLSL sampler determine the minification, and thus the mipmap level, of a texture?

后端 未结 2 1168
离开以前
离开以前 2021-01-05 10:37

I am working with OpenGL ES (via WebGL), but I think this question is applicable to the full OpenGL profile as well.

Suppose I create an OpenGL texture with full mip

2条回答
  •  半阙折子戏
    2021-01-05 11:06

    You are allowed to compute texture coordinates arbitrarily, and the shader will act accordingly... within one restriction. Your computations cannot involve any conditional logic. They can involve varyings, uniforms, constants, values sampled from other textures, whatever you want. But the moment you slip so much as a ?: operator in there (let alone an if-statement), you're in trouble.

    And since you're in OpenGL ES land, you don't really have the tools to get yourself out of that trouble. Desktop GL 3.0 gives you the textureGrad set of functions, which allows you to compute gradients before reaching the conditional logic. But without that, there isn't much you can do.

提交回复
热议问题