0

I would like to access different levels of detail in my GLSL fragment program. I'm currently stuck with using legacy OpenGL, including GLSL 1.2. Unfortunately, I don't have control over that.

I see that the texture2DLod() method exists, but it appears it can only be used in a vertex program.

I have read this question, but they appear to be working with GLSL 1.4 or later. Unfortunately, I do not have that option.

Is there any way in a GLSL 1.2 fragment program to sample a specific mipmap level?

If there's no function for doing it directly, is it possible to send the mipmaps in as separate textures without doing 8 copies?

Community
  • 1
  • 1
user1118321
  • 25,567
  • 4
  • 55
  • 86

1 Answers1

1

It is not possible for a fragment shader (in GLSL 1.20) to access a specific texture mipmap. However, you can always change the base/max mipmap levels of a texture before you use it. By setting them both to the same level, you force any texture accesses from that texture to use a specific mipmap level.

Now, you can't make these separate textures (unless you're using NVIDIA hardware and have access to ARB_texture_view). So you'll have to live with changing the texture's base/max level every time you want to pick a new mipmap.

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
  • OK, thanks for the info! I did make an implementation where I actually copy each mipmap level to a texture and access it that way, but I'm not sure performance will be good enough in that case. This is kind of an odd thing to want to do, I suppose, but thought I'd give it a try. Thanks! – user1118321 Apr 02 '13 at 04:31