GLSL built-in function
textureProjGradOffset()
Projected gradient lookup with a constant offset.
Demo version: GLSL ES 3.00 / WebGL 2Demo stage: Fragment
Syntax
gvec4 textureProjGradOffset(gsampler2D sampler, vec3 coord, vec2 dx, vec2 dy, ivec2 offset)Parameters
- sampler
- Bound fixture texture
- coord
- Lookup coordinate
- dx
- Coordinate gradient along screen x
- dy
- Coordinate gradient along screen y
- offset
- Compile-time constant texel offset
Return value
Four components from projected coordinates plus a constant texel offset, filtered using explicit gradients.
Live example
Edit the code and the preview updates as you type.
What textureProjGradOffset does
Projected gradient lookup with a constant offset.
Read the preview
The projection divisor 0.8 and offset ivec2(1,0) both affect where this blurred grid is read. Set the offset to ivec2(0,0) to isolate the projected lookup.
Core call
textureProjGradOffset(u_texture,vec3(uv,0.8),vec2(.03,0),vec2(0,.03),ivec2(1,0)).rgb;
Do not include the projection q component in the two-dimensional gradient arguments.
Experiment
Use .003 instead of .03 for both gradients, keeping the offset and divisor. The image gains detail while retaining the same projection and constant offset arguments.