0

I have a shader in glsl that is using a 3D texture to create some shading effects.

I am currently using texelFetch() but now need to use interpolated LOD levels to achieve the final effect.

The texture is declared like this:

uniform layout(binding=0) sampler3D diffuse_map;

And then I sample it like this using texelfetch():

vec4 val = texelFetch(normal_map, ivec3(((r)*0.5/cube_dim+vec3(0.5))*(voxel_resolution-1)),0);

The above works.

I then try to sample the same texture with textureLod as follows:

vec4 val = textureLod(normal_map, ivec3(((r)*0.5/cube_dim+vec3(0.5))*(voxel_resolution-1)),0);

I am guessing this fails because the coordinate system is different for textureLod, but then, what is the range for the coordinate for this function?

The documentation does not explicitly state it, and soemtimes the coordinate system is that of the texture, soemtimes is 0 to 1 and soemtimes it's -1 to 1

BDL
  • 21,052
  • 22
  • 49
  • 55
Makogan
  • 8,208
  • 7
  • 44
  • 112
  • 2
    The texture coordinates are in range [0, 1]. See [How do opengl texture coordinates work?](https://stackoverflow.com/questions/5532595/how-do-opengl-texture-coordinates-work) – Rabbid76 Jul 27 '18 at 06:38
  • They are not when using imageLoad/store nor texelFetch though – Makogan Jul 27 '18 at 07:07
  • 2
    Your question was about `textureLod`. Of course `texelFetch` uses pixel coordinates. But that is all well documented. – Rabbid76 Jul 27 '18 at 07:23
  • @Makogan: "*and soemtimes the coordinate system is that of the texture, soemtimes is 0 to 1 and soemtimes it's -1 to 1*" I don't know any function which accesses textures that take normalized *signed* values like that, where -1 maps to the left side and 1 to the right. You can use mirrored repeating sampling to create the effect of that, but that's not part of a texture accessing function. – Nicol Bolas Jul 27 '18 at 13:18

0 Answers0