GLSL built-in function
textureProjLodOffset()
Projected lookup combining explicit LOD and constant offset.
Demo version: GLSL ES 3.00 / WebGL 2Demo stage: Fragment
Syntax
gvec4 textureProjLodOffset(gsampler2D sampler, vec3 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 components sampled at the explicit mip after projective division and a constant texel offset.
Live example
Edit the code and the preview updates as you type.
What textureProjLodOffset does
Projected lookup combining explicit LOD and constant offset.
Read the preview
textureProjLodOffset combines division by 0.8, slider-selected LOD and ivec2(1,0). Set the offset to ivec2(0,0) to compare the same projected mip with no texel displacement.
Core call
textureProjLodOffset(u_texture,vec3(uv,0.8),u_parameter*6.0,ivec2(1,0)).rgb;
The offset is a compile-time constant; LOD may be changed by a uniform.
Experiment
Replace u_parameter*6.0 with 5.0 and the offset with ivec2(-1,0). The coarse fixture remains blurred, but its lookup shifts to the opposite neighboring texel.