StencilEmulation
final class StencilEmulation
Package: dev.joid.lib.bridge.render.state · Module: core · Source: StencilEmulation.java
Stencil test and update done in the fragment shader, for a backend whose targets have no stencil buffer.
Description
Section titled “Description”StencilEmulation turns the StencilState of the render state into what a shader translated with a stencil pass needs: whether to test, whether to write, and the values of its uniforms.
Draw the WRITE pass with the pipeline of PipelineKey.stencil and the stencil fragment of the ShaderTranslation, then the draw itself.
No backend of JOID uses it: OpenGL and Vulkan have a stencil buffer on the window.
Learn more
Section titled “Learn more”Creation
Section titled “Creation”| Returns | Signature | Summary |
|---|---|---|
StencilEmulation | from(RenderState state, boolean screen) factory | Reads the stencil of a render state. |
Methods
Section titled “Methods”| Returns | Signature | Summary |
|---|---|---|
void | write(UniformBlock block) | Writes the stencil uniforms of GlslShaderTranslator (STENCIL_TEST, STENCIL_FUNCTION, STENCIL_REFERENCE, STENCIL_MASK, STENCIL_FAIL and STENCIL_PASS) into the block of the shader. |
boolean | isTest() | If true, the draw tests the stencil: the target is the window and the stencil of the state is on. |
boolean | isWrite() | If true, the draw also changes the stencil, so it needs the WRITE pass first: the test is on and the fail or the pass operation is not KEEP. |
int | getMask() | Returns the mask of the state, reduced to 8 bits. |
int | getReference() | Returns the reference of the state, reduced to 8 bits. |
StencilFunction | getFunction() | Returns the comparison of the state. |
StencilOperation | getFail() | Returns the operation when the comparison fails. |
StencilOperation | getPass() | Returns the operation when the comparison passes; the emulation has no depth-fail case. |
Creation details
Section titled “Creation details”StencilEmulation from(RenderState state, boolean screen) factory
Reads the stencil of a render state.
Pass screen as true when the target is the window: off screen, nothing is tested nor written, as the core never uses a stencil in a framebuffer.
Method details
Section titled “Method details”void write(UniformBlock block)
Writes the stencil uniforms of GlslShaderTranslator (STENCIL_TEST, STENCIL_FUNCTION, STENCIL_REFERENCE, STENCIL_MASK, STENCIL_FAIL and STENCIL_PASS) into the block of the shader.
Call it before the block is sent for a draw; it throws IllegalArgumentException on a shader translated without stencil emulation.
isTest
Section titled “isTest”boolean isTest()
If true, the draw tests the stencil: the target is the window and the stencil of the state is on.
isWrite
Section titled “isWrite”boolean isWrite()
If true, the draw also changes the stencil, so it needs the WRITE pass first: the test is on and the fail or the pass operation is not KEEP.
getMask
Section titled “getMask”int getMask()
Returns the mask of the state, reduced to 8 bits.
getReference
Section titled “getReference”int getReference()
Returns the reference of the state, reduced to 8 bits.
getFunction
Section titled “getFunction”StencilFunction getFunction()
Returns the comparison of the state.
getFail
Section titled “getFail”StencilOperation getFail()
Returns the operation when the comparison fails.
getPass
Section titled “getPass”StencilOperation getPass()
Returns the operation when the comparison passes; the emulation has no depth-fail case.
fluent returns the instance, typed for chaining · factory creates an instance · signal also accepts a value that follows signals, as a signal, an expression or a lambda (When does JOID compute this value again?) · hook called by JOID, override it · abstract you implement it · default interface method with a body · static called on the class · protected visible to subclasses
