TEXTURE(3G)

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

πŸ’– 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 the gsampler2DRect and sampler2DRectShadow ones have no bias?? 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 from gsamplerCubeArrayShadow. 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 compare is present, it's used as Dsub, and the array layer comes from P.w. that's the fourth component. the w. 🫑
  • when compare is not present, the last component of P is used as Dsub, and the array layer comes from the second to last component of P.
  • and just so you know β€” for 1D shadow lookups, the second component of P is 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 Β© 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