Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 6 of 6

Thread: sampler specific LOD failure

  1. #1
    Junior Member Regular Contributor Kopelrativ's Avatar
    Join Date
    Apr 2011
    Posts
    214

    sampler specific LOD failure

    I have a texture drawn in a quad. The texture has mimaps attached to it. I access the texture the usual way, with
    Code :
    texture(sampler, coord);
    According to the specification, A third argument can be used for LOD (level of detail). But when I try that, I get no visible effect, no matter what value I try.

    There is also the textureLod() function, which takes LOD as argument. This gives the same result. I don't understand the difference between texture() and textureLod(). Shouldn't a specified LOD give a picture with lower resolution?

    To make certain there there really are mipmaps defined, I verified it by doing a glGetTexLevelParameter() for GL_TEXTURE_WIDTH on various levels. What I am really looking for, is a way to downsample a bitmap.

  2. #2
    Member Regular Contributor Nowhere-01's Avatar
    Join Date
    Feb 2011
    Location
    Novosibirsk
    Posts
    251
    do you have gl_linear_mipmap_linear set as texture minification filter? are you generating mipmaps? double-check it. if both answers are true, you should post some code.

  3. #3
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,948
    A third argument can be used for LOD (level of detail). But when I try that, I get no visible effect, no matter what value I try.
    The third parameter is the LOD bias. It's a number added (aka: biased) to the LOD selected by the regular texturing algorithm.

    I don't understand the difference between texture() and textureLod().
    The difference is stated on the site. `textureLOD` is for when you "want to prevent mipmapping altogether and just access from a single mipmap layer". `texture` is for "normal" texture accesses, which may involve mipmap filtering anisotropic filtering, etc. `textureLOD` only fetches from the given mipmap layer.

  4. #4
    Advanced Member Frequent Contributor arekkusu's Avatar
    Join Date
    Nov 2003
    Posts
    782
    Quote Originally Posted by Alfonse Reinheart View Post
    `textureLOD` is for when you "want to prevent mipmapping altogether
    It is more accurate to say that texture() implicitly calculates the LOD for you (based on ratio of texels to pixels.)
    texture(...bias) adds a floating point bias to that implicit LOD.
    textureLod(...lod) replaces the implicit LOD with the provided floating point LOD. But it does not disable mipmapping; you can provide 1.5 and trilinear filtering still samples from two levels.

    In any case, there is other interacting state that might result in not seeing any difference, like TEXTURE_MIN_FILTER, TEXTURE_MIN_LOD, TEXTURE_MAX_LOD, and TEXTURE_MAX_LEVEL. The default state should result in seeing each LOD. Also try providing false-colored levels to make it obvious which one is being sampled.

  5. #5
    Junior Member Regular Contributor Kopelrativ's Avatar
    Join Date
    Apr 2011
    Posts
    214
    Quote Originally Posted by Nowhere-01 View Post
    do you have gl_linear_mipmap_linear set as texture minification filter?
    Thanks, that nailed the problem! I thought the mipmaps would be accessible regardless of the minification filter.

    And thanks also for the other comments, now I understand a little better how this works and how it is supposed to be used.

  6. #6
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,948
    Quote Originally Posted by arekkusu View Post
    It is more accurate to say that texture() implicitly calculates the LOD for you (based on ratio of texels to pixels.)
    texture(...bias) adds a floating point bias to that implicit LOD.
    textureLod(...lod) replaces the implicit LOD with the provided floating point LOD. But it does not disable mipmapping; you can provide 1.5 and trilinear filtering still samples from two levels.
    Fixed the wiki. Thanks.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •