GLSL built-in function
textureLodOffset()
Adds a constant texel offset to explicit-LOD sampling.
Demo version: GLSL ES 3.00 / WebGL 2Demo stage: Fragment
Syntax
gvec4 textureLodOffset(gsampler2D sampler, vec2 coord, float lod, ivec2 offset)Parameters
- sampler
- Bound fixture texture
- coord
- Lookup coordinate
- lod
- Mip level; zero is full resolution
- offset
- Compile-time constant texel offset
Return value
Four filtered components at the explicit mip level, with coord shifted by a constant offset measured in that mip's texels.
Live example
Edit the code and the preview updates as you type.
What textureLodOffset does
Adds a constant texel offset to explicit-LOD sampling.
Read the preview
ivec2(2,0) offsets the lookup in texels of the chosen mip. Try LOD 0.0 and then 6.0 in place of u_parameter*6.0: the same two-texel offset covers a much larger image fraction at the coarse level.
Core call
textureLodOffset(u_texture,uv,u_parameter*6.0,ivec2(2,0)).rgb;
A texel offset covers a different source-image distance at different mip levels.
Experiment
Keep LOD at 0.0 and change ivec2(2,0) to ivec2(0,2). The small shift moves from the horizontal to the vertical direction while full-resolution detail stays intact.