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

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.

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.

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.

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.

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.

[QUOTE=arekkusu;1248006]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.[/QUOTE]

Fixed the wiki. Thanks.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.