TEXTURE(3G)
π TEXTURE(3G) π
okay bestie, pull up a chair, grab a boba, because we're doing the texture manual page from the 3G section and honestly?? it's giving main character energy β¨. this is the one that snatches texels out of a texture. yes. that's the whole job. let's get into it π«Ά
πΈ NAME πΈ
texture β retrieves texels from a texture
β¨ DECLARATION β¨
like, there are so many overloads here and every single one of them is iconic in its own way. no cap, here's the full lineup, exactly as written:
gvec4 texture(gsampler1D sampler, float P, [float bias]);
gvec4 texture(gsampler2D sampler, vec2 P, [float bias]);
gvec4 texture(gsampler3D sampler, vec3 P, [float bias]);
gvec4 texture(gsamplerCube sampler, vec3 P, [float bias]);
float texture(sampler1DShadow sampler, vec3 P, [float bias]);
float texture(sampler2DShadow sampler, vec3 P, [float bias]);
float texture(samplerCubeShadow sampler, vec3 P, [float bias]);
gvec4 texture(gsampler1DArray sampler, vec2 P, [float bias]);
gvec4 texture(gsampler2DArray sampler, vec3 P, [float bias]);
gvec4 texture(gsamplerCubeArray sampler, vec4 P, [float bias]);
float texture(sampler1DArrayShadow sampler, vec3 P, [float bias]);
float texture(gsampler2DArrayShadow sampler, vec4 P, [float bias]);
gvec4 texture(gsampler2DRect sampler, vec2 P);
float texture(sampler2DRectShadow sampler, vec3 P);
float texture(gsamplerCubeArrayShadow sampler, vec4 P, float compare);
notice how thegsampler2DRectandsampler2DRectShadowones have nobias?? that's not a typo bestie, that's canon. π
π PARAMETERS π
samplerβ the sampler that's holding onto the texture we're gonna steal texels from. it's literally the plug. πPβ the texture coordinates where we're sampling. this is where the vibe check happens.biasβ an optional bias that gets applied during level-of-detail computation. optional but lowkey important.compareβ the value that the fetched texel gets compared against when you're sampling fromgsamplerCubeArrayShadow. yes, specifically that one. no, not the others.
π¦ DESCRIPTION π¦
so texture samples texels from the texture bound to sampler, at texture coordinate P. and if you pass in that optional bias, it gets folded into the level-of-detail computation β which is the thing that decides which mipmap(s) we're pulling from. mipmap selection is a whole process and bias gets a vote. π³οΈ
now for the shadow forms, and this part is a little fiddly so pay attention bestie:
- when
compareis present, it's used asDsub, and the array layer comes fromP.w. that's the fourth component. the w. π«‘ - when
compareis not present, the last component ofPis used asDsub, and the array layer comes from the second to last component ofP. - and just so you know β for 1D shadow lookups, the second component of
Pis unused. it's just sitting there. unemployed. π
and for the non-shadow variants? the array layer comes from the last component of P. simple. clean. slay. β¨
π VERSION SUPPORT π
(the original is a big sparkly grid, but we're doing it as a list because tables are not the vibe here β every number is still exactly right, promise π)
the columns are OpenGL Shading Language versions: 1.10, 1.20, 1.30, 1.40, 1.50, 3.30, 4.00, 4.10, 4.20, 4.30, 4.40, 4.50. a - means nope, a β means yes bestie.
textureβ1.10:-,1.20:-,1.30:β,1.40:β,1.50:β,3.30:β,4.00:β,4.10:β,4.20:β,4.30:β,4.40:β,4.50:βtexture(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:βtexture(gsampler2DMS,gsampler2DMSArray) β1.10:-,1.20:-,1.30:-,1.40:-,1.50:β,3.30:β,4.00:β,4.10:β,4.20:β,4.30:β,4.40:β,4.50:βtexture(gsamplerCubeArray{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:β
π SEE ALSO π
the whole friend group, fr fr β go read these too, they're all part of the same era:
texelFetch()texelFetchOffset()textureGather()textureGatherOffset()textureGatherOffsets()textureGrad()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 page π and now the cute sign-off: this came from [FIXME: source], dated 01/03/2018, and it lives in the TEXTURE(3G) section of the manual. go forth and sample responsibly, bestie. mwah πβ¨π§
π¦ 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