GL_SAMPLEID(3G)

πŸ’… GL_SAMPLEID (3G) β€” the manual, bestie edition ✨

okay so real talk, we're in the 3G manual and the header on this thing literally says GL_SAMPLEID(3G) with a [FIXME: manual] in the middle, so like… that's the vibe we're working with 🫢

🌸 NAME 🌸

gl_SampleID β€” the variable that holds the index of the sample you're currently processing, no cap πŸŽ€

✨ DECLARATION ✨

in int gl_SampleID ;

πŸ’– DESCRIPTION πŸ’–

So gl_SampleID is a fragment language input variable, and it contains the index of the sample that's currently being processed. Iconic. It lives in the range 0 to gl_NumSamples() - 1, where gl_NumSamples() is the total number of samples in each fragment for the current framebuffer β€” which means it's 1 if you're rendering to a non-multisample buffer πŸ¦‹

⚠️ heads up bestie: any static use of this variable in a fragment shader causes the entire shader to be evaluated per-sample rather than per-fragment. the whole thing. not a drill 😭

When you're rendering to a non-multisample buffer, or if multisample rasterization is disabled, gl_SampleID will always be zero. and just so we're clear β€” gl_NumSamples() is the sample count of the framebuffer regardless of whether multisample rasterization is enabled or not. two separate things, don't mix them up πŸ’€

πŸ”₯ VERSION SUPPORT πŸ”₯

the table energy, but make it a list β€” this is which OpenGL Shading Language Version numbers actually have gl_SampleID:

  • 1.10 β€” nope πŸ™ˆ
  • 1.20 β€” nope
  • 1.30 β€” nope
  • 1.40 β€” nope
  • 1.50 β€” nope
  • 3.30 β€” nope
  • 4.00 β€” βœ”οΈ yes queen πŸ‘‘
  • 4.10 β€” βœ”οΈ
  • 4.20 β€” βœ”οΈ
  • 4.30 β€” βœ”οΈ
  • 4.40 β€” βœ”οΈ
  • 4.50 β€” βœ”οΈ

so like, 4.00 and up only. everything before that is giving "not invited to the party" πŸ’…

🌈 SEE ALSO 🌈

  • gl_SamplePosition()
  • gl_NumSamples()

go read those too, iykyk πŸ’œ

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, bestie! and for the cute sign-off: this one came from [FIXME: source] and it's dated 08/09/2021 β€” so it's a lil vintage, but she still slays β­πŸŒΈπŸ’–

πŸ“¦ where this page comes from