GLSL built-in function
textureProjGrad()
Projected lookup with explicit texture-coordinate gradients.
Demo version: GLSL ES 3.00 / WebGL 2Demo stage: Fragment
Syntax
gvec4 textureProjGrad(gsampler2D sampler, vec3 coord, vec2 dx, vec2 dy)Parameters
- sampler
- Bound fixture texture
- coord
- Lookup coordinate
- dx
- Coordinate gradient along screen x
- dy
- Coordinate gradient along screen y
Return value
Four sampled components after projective division, filtered with the explicitly supplied gradients.
Live example
Edit the code and the preview updates as you type.
What textureProjGrad does
Projected lookup with explicit texture-coordinate gradients.
Read the preview
vec3(uv,0.8) expands the image coordinates while .03 gradients control blur independently. Set the divisor to 1.0 to remove projection scaling but keep that blur.
Core call
textureProjGrad(u_texture,vec3(uv,0.8),vec2(.03,0),vec2(0,.03)).rgb;
Gradient dimensions match the texture coordinates after projection.
Experiment
Reduce the two .03 gradient entries to .003 in textureProjGrad. The projected grid sharpens without changing the 0.8 division or the position of its clamped borders.