TEXTUREGRAD(3G)

πŸ“¦
version 1.0~svn33624 Β· 4 versions
, in ubuntu jammy, ubuntu noble

πŸ‘‘ TEXTUREGRAD(3G) πŸ‘‘

okay so bestie, this is the manual page for textureGrad β€” it lives in section 3G of the manual, and it's literally the GLSL function that does a texture lookup when you already know the gradients. no cap, it's giving "i have trust issues with the automatic derivative hardware" energy πŸ’…


🌸 NAME 🌸

textureGrad β€” perform a texture lookup with explicit gradients ✨


πŸŽ€ DECLARATION πŸŽ€

here's every single overload, exactly as written, don't @ me:

gvec4 textureGrad(gsampler1D sampler, float P, float dPdx, float dPdy);

gvec4 textureGrad(gsampler2D sampler, vec2 P, vec2 dPdx, vec2 dPdy);

gvec4 textureGrad(gsampler3D sampler, vec3 P, vec3 dPdx, vec3 dPdy);

gvec4 textureGrad(gsamplerCube sampler, vec3 P, vec3 dPdx, vec3 dPdy);

gvec4 textureGrad(gsampler2DRect sampler, vec2 P, vec2 dPdx, vec2 dPdy);

float textureGrad(gsampler2DRectShadow sampler, vec2 P, vec2 dPdx,
                  vec2 dPdy);

float textureGrad(sampler1DShadow sampler, vec3 P, float dPdx,
                  float dPdy);

float textureGrad(sampler2DShadow sampler, vec3 P, vec2 dPdx,
                  vec2 dPdy);

gvec4 textureGrad(gsampler1DArray sampler, vec2 P, float dPdx,
                  float dPdy);

gvec4 textureGrad(gsampler2DArray sampler, vec3 P, vec2 dPdx,
                  vec2 dPdy);

float textureGrad(sampler1DArrayShadow sampler, vec3 P, float dPdx,
                  float dPdy);

gvec4 textureGrad(gsamplerCubeArray sampler, vec4 P, vec3 dPdx,
                  vec3 dPdy);

like, twelve of them. twelve. the overload set said "cover every vibe" and then covered every vibe 🫢


πŸ¦‹ PARAMETERS πŸ¦‹

  • sampler β€” the sampler that the texture you're pulling texels from is bound to. like, which texture are we even talking about here bestie.
  • P β€” the texture coordinates where the sampling happens. the spot. the moment. the location πŸ’–
  • dPdx β€” the partial derivative of P with respect to window x. yes, you have to bring your own. no, the GPU won't do it for you.
  • dPdy β€” the partial derivative of P with respect to window y. same deal, other axis, iconic duo 🌈

πŸ’œ DESCRIPTION πŸ’œ

textureGrad does a texture lookup at coordinate P, from the texture bound to sampler, using explicit texture coordinate gradients β€” the ones you hand it in dPdx and dPdy. no guessing, no automatic derivative shenanigans, you're the main character and you provide the math yourself 😀

here's how the deltas get set, verbatim:

Ξ΄s Ξ΄x = Ξ΄P Ξ΄x   for a 1D texture,  Ξ΄P.s Ξ΄x   otherwise

Ξ΄s Ξ΄y = Ξ΄P Ξ΄y   for a 1D texture,  Ξ΄P.s Ξ΄y   otherwise

Ξ΄t Ξ΄x = 0.0   for a 1D texture,  Ξ΄P.t Ξ΄x otherwise

Ξ΄t Ξ΄y = 0.0   for a 1D texture,  Ξ΄P.t Ξ΄y   otherwise

Ξ΄r Ξ΄x = 0.0   for a 1D or 2D texture,  Ξ΄P.p Ξ΄x   otherwise

Ξ΄r Ξ΄y = 0.0   for a 1D or 2D texture,  Ξ΄P.p Ξ΄y   otherwise

and for the cube version specifically? the partial derivatives of P are assumed to be in the coordinate system used before the texture coordinates get projected onto the appropriate cube face. that's the whole note. remember it, it's important πŸ”₯


⭐ VERSION SUPPORT ⭐

which GLSL versions said "yes bestie" to which overload. βœ” means it's there, - means it's not even invited to the party:

  • textureGrad β€” 1.10: -, 1.20: -, 1.30: βœ”, 1.40: βœ”, 1.50: βœ”, 3.30: βœ”, 4.00: βœ”, 4.10: βœ”, 4.20: βœ”, 4.30: βœ”, 4.40: βœ”, 4.50: βœ”
  • textureGrad (gsampler2DRect{Shadow}) β€” 1.10: -, 1.20: -, 1.30: -, 1.40: βœ”, 1.50: βœ”, 3.30: βœ”, 4.00: βœ”, 4.10: βœ”, 4.20: βœ”, 4.30: βœ”, 4.40: βœ”, 4.50: βœ”
  • textureGrad (gsamplerCubeArray) β€” 1.10: -, 1.20: -, 1.30: -, 1.40: -, 1.50: -, 3.30: -, 4.00: βœ”, 4.10: βœ”, 4.20: βœ”, 4.30: βœ”, 4.40: βœ”, 4.50: βœ”

so like, the plain one showed up in 1.30, the rect shadow one rolled in at 1.40, and the cube array one was fashionably late to the 4.00 drop πŸ’€ lowkey relatable.


🧚 SEE ALSO 🧚

the whole friend group, go say hi:

texelFetch(), texelFetchOffset(), texture(), textureGather(), textureGatherOffset(), textureGatherOffsets(), textureGradOffset(), textureLod(), textureLodOffset(), textureOffset(), textureProj(), textureProjGrad(), textureProjGradOffset(), textureProjLod(), textureProjLodOffset(), textureProjOffset(), textureQueryLod(), textureSize()


Copyright Β© 2011-2014 Khronos Group. This material may be distributed subject to the terms and conditions set forth in the Open Publication License, v 1.0, 8 June 1999. http://opencontent.org/openpub/.

Copyright Β© 2011-2014 Khronos Group


okay that's the whole thing, go forth and pass gradients manually bestie, the GPU believes in you πŸ’–

and finally, the little sign-off down at the bottom of the page said source [FIXME: source], dated 01/03/2018, filed under TEXTUREGRAD(3G) β€” so that's the receipts, that's the lore, periodt βœ¨πŸŽ€

πŸ“¦ where this page comes from