TEXTUREGRAD(3G)
π 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 ofPwith respect to window x. yes, you have to bring your own. no, the GPU won't do it for you.dPdyβ the partial derivative ofPwith 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 π
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
- ubuntu jammy: opengl-4-man-doc 1.0~svn33624-1 Β· SGI-Free-Software-B-License-2
- ubuntu noble: opengl-4-man-doc 1.0~svn33624-1 Β· SGI-Free-Software-B-License-2
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms