Note that there are some explanatory texts on larger screens.

plurals
  1. POOpenGL ES 2.0 texture2D bias/lod
    primarykey
    data
    text
    <p>I am using the OpenGL ES 2.0 GLSL functionality to manipulate images. What I want to achieve is to select a specific Level Of Detail (LOD) when fetching a sample from a texture from within a fragment shader. Apparently <code>texture2DLod()</code> is not supported for fragment shaders in OpenGL ES 2.0 (but there is an extension <a href="http://www.khronos.org/registry/gles/extensions/EXT/EXT_shader_texture_lod.txt" rel="nofollow noreferrer"><code>GL_EXT_shader_texture_lod</code></a> that can optionally provide it.)</p> <p>However, the default <code>texture2D()</code> function provides a third optional parameter bias. As far as I understand, this parameter is supposed to be an offset added to the current LOD.</p> <p>In my tests I'm drawing a quad the size of the screen and I'm magnifying a texture by scaling the sample coordinates. I've enabled mipmapping for the texture using GL_LINEAR_MIPMAP_LINEAR as a minification filter. The result when sampling with a non-zero bias parameter on the ARM Mali-400 GPU can be seen in the image below.</p> <p>ISTM that some pixels are using the minification filter while others are using the magnification filter.</p> <p>How is this controlled? And how do I determine the initial LOD when using bias? Can it be adjusted from the vertex shader?</p> <p>A related question is the following one:</p> <p><a href="https://stackoverflow.com/questions/7367606/how-does-a-glsl-sampler-determine-the-minification-and-thus-the-mipmap-level-o">How does a GLSL sampler determine the minification, and thus the mipmap level, of a texture?</a></p> <p><img src="https://i.stack.imgur.com/kBNTh.png" alt="texture2D with bias parameter on ARM Mali-400"></p> <p>Update: I noticed that if I sample the texture so that it covers the screen, then it seems to do the proper mipmap look-up (even though it is magnified.) Now, if I add a small offset to the sample coordinates, then I will begin to see the banding that is seen in the above image (which is magnified even more.) If I don't use the bias parameter I will not see any banding at all.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload