Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the role of mask parameter in glStencilFunc

Tags:

opengl

glsl

In the function

glStencilFunc(GLenum func, GLint ref, GLuint mask)

what is the role of mask , we are sending the ref value and the buffer content is being compared to the ref value than why do we need to send mask value ?

what i read about the mask value is "mask that is ANDed with both the reference value and the stored stencil value" but why do we need that?

like image 675
sumit kang Avatar asked Dec 22 '25 02:12

sumit kang


1 Answers

It all depends on what you're doing with the stencil. Some stencil operations treat the stencil value as just an integer, incrementing and/or decrementing the stencil value for some effect or purpose. Other operations use it as a bitmask, where each bit or group of bits in the stencil value represents something in particular. That is, from a semantic perspective, you have multiple values that just so happen to be stored in the same 8 bits of space.

The mask value is for cases like that. You might have 8 separate masking regions, and you want to render some geometry against one of the region. You use the mask parameter to specify which bit (that specifies a region) to mask off a piece of geometry.

like image 149
Nicol Bolas Avatar answered Dec 24 '25 10:12

Nicol Bolas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!