GL_SAMPLEMASK(3G)

πŸ’… NAME

gl_SampleMask β€” bestie, this one specifies the sample coverage mask for the current fragment ✨

(also hi, you're reading the GL_SAMPLEMASK(3G) page, welcome 🫢)


πŸŽ€ DECLARATION

out int gl_SampleMask[] ;

that's literally it. that's the whole declaration. icon.


✨ DESCRIPTION

okay so gl_SampleMask is a fragment language output array πŸ”₯ and its whole job is setting the sample mask for the fragment being processed. simple as that.

here's the tea though πŸ‘€ β€” coverage for the current fragment becomes the logical AND of the coverage mask and the output gl_SampleMask. so like, if you set a bit in gl_SampleMask to zero, that corresponding sample gets treated as uncovered for the purposes of multisample fragment operations. bye sample πŸ’€

but listen: setting sample mask bits back to one will never enable samples not covered by the original primitive. that's a one-way street, no take-backs, no cap πŸ™…β€β™€οΈ

the indexing, bestie: bit B of mask gl_SampleMask[M] corresponds to sample 32 * M + B. write that down πŸ“

this array must be sized in the fragment shader β€” either implicitly or explicitly β€” to be the same size as the implementation-dependent maximum sample-mask (as an array of 32-bit elements), determined by the maximum number of samples. okay so it's giving "size it right or perish" πŸ’…

and now the spicy parts 🌢️:

  • If the fragment shader statically assigns a value to gl_SampleMask, the sample mask will be undefined for any array elements of any fragment shader invocation that fails to assign a value. (yes, undefined. we don't love that for you 😭)
  • If a shader does not statically assign a value to gl_SampleMask, the sample mask has no effect on the processing of a fragment. nothing. zero. it's just vibes.
  • If the fragment shader is being evaluated at any frequency other than per-fragment, bits within the sample mask not corresponding to the current fragment shader invocation are ignored. πŸ™ˆ

🌈 VERSION SUPPORT

the version support table, but make it a vibe check πŸ‘‘ β€” variable name gl_SampleMask, versus OpenGL Shading Language Version:

  • 1.10 β€” - (nope)
  • 1.20 β€” - (nope)
  • 1.30 β€” - (nope)
  • 1.40 β€” - (nope)
  • 1.50 β€” - (nope)
  • 3.30 β€” - (still nope)
  • 4.00 β€” βœ” (ATE πŸ’…)
  • 4.10 β€” βœ”
  • 4.20 β€” βœ”
  • 4.30 β€” βœ”
  • 4.40 β€” βœ”
  • 4.50 β€” βœ”

so basically 4.00 and onward, she's booked and busy πŸ¦‹ periodt.


🌸 SEE ALSO

go read these next, bestie, they're all in the family 🫢

  • gl_SampleMaskIn()
  • gl_SampleID()
  • gl_SamplePosition()
  • gl_FragCoord()

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


🧚 mwah, that's the whole page! it came from [FIXME: source] and it's dated 08/09/2021, so if you're citing it in your essay, that's the receipt πŸŽ€ stay slay, go read gl_SampleMaskIn() next, bye bestie! πŸ’–βœ¨
πŸ“¦ where this page comes from