GLSL built-in function
textureProjOffset()
Projected lookup with a constant texel offset.
Demo version: GLSL ES 3.00 / WebGL 2Demo stage: Fragment
Syntax
gvec4 textureProjOffset(gsampler2D sampler, vec3 coord, ivec2 offset)Parameters
- sampler
- Bound fixture texture
- coord
- Lookup coordinate
- offset
- Compile-time constant texel offset
Return value
Four filtered components from projected texture coordinates shifted by a constant integer texel offset.
Live example
Edit the code and the preview updates as you type.
What textureProjOffset does
Projected lookup with a constant texel offset.
Read the preview
vec3(uv,0.8) stretches lookup coordinates and ivec2(3,0) nudges the result sideways. Set the divisor to 1.0 to see the horizontal offset on an otherwise unscaled grid.
Core call
textureProjOffset(u_texture,vec3(uv,0.8),ivec2(3,0)).rgb;
Projection division and integer texel offset are different coordinate operations.
Experiment
Change ivec2(3,0) to ivec2(0,-3). The constant offset now acts downward in texture coordinates while the projection division remains unchanged.