[x3d-public] X3D Stencil Buffer defined?
Michalis Kamburelis
michalis.kambi at gmail.com
Tue Mar 28 23:06:43 PDT 2017
1. What is a stencil buffer?
Stencil buffer is a special buffer on GPU (along the color, depth etc.
buffers) which can be used for masking. There is a special API to
operate on it, to
- increase/decrease values in the stencil buffer on the pixels where
you draw (so you can define a mask)
- specify to use the stencil buffer to filter out some drawing (so you
can use it for masking).
Stencil buffer is not directly settable / gettable from shaders. The
API is in OpenGL / Direct3D.
The usage is much broader than simple masking, due to a number of ways
how you can define a mask. In particular, the shadow volumes (probably
2nd most popular algorithm for implementing real-time shadows) use the
stencil buffer as a crucial GPU feature.
For more, see https://en.wikipedia.org/wiki/Stencil_buffer .
2. In X3D:
Nothing in the X3D specification talks about the stencil buffer,
because from the point of view of X3D it's an implementation-detail
whether you use stencil buffer. Using it requires a multi-pass
rendering, it is not as easy as "use this texture for masking". It's
possible to implement the whole standard X3D right now without stencil
buffer, as far as I know.
Castle Game Engine has simple extensions to use shadow volumes:
https://castle-engine.sourceforge.io/x3d_extensions_shadow_volumes.php
. This uses the stencil buffer internally. But it's completely hidden
from the X3D author, that simply says "cast shadows from these
lights".
Instant Reality has a StencilMode node that is probably the closest
you can get to "directly controlling the stencil buffer in X3D":
http://doc.instantreality.org/documentation/nodetype/StencilMode/
Regards,
Michalis
More information about the x3d-public
mailing list