API

Interface StencilState

Optional stencil-test state baked into a material's main-pass pipeline. Shared by every concrete material kind (Standard, PBR, Shader) so none has to depend on another. Lets one material WRITE the stencil buffer where it draws (a mask) and another DISCARD fragments where the stencil was written — with NO dynamic stencil reference: a writer uses compare:"always" + passOp:"increment-clamp" (stencil 0→1 where it draws); a tester uses compare:"equal" (passes only where the stencil is still 0, i.e. NOT written), since the render pass's default stencil reference is 0. Only takes effect on a stencil-capable depth target (the main color pass); ignored on depth-only/shadow targets. Assigning material.stencil is inert until enableMaterialStencil is called (the opt-in that keeps stencil-free scenes byte-identical) — call it once before registerScene.

interface StencilState {
    compare?: GPUCompareFunction;
    depthFailOp?: GPUStencilOperation;
    failOp?: GPUStencilOperation;
    passOp?: GPUStencilOperation;
    readMask?: number;
    writeMask?: number;
}
Index
compare?: GPUCompareFunction

Stencil compare function, applied to front & back faces. Default "always".

depthFailOp?: GPUStencilOperation

Stencil operation when the stencil test passes but depth fails. Default "keep".

failOp?: GPUStencilOperation

Stencil operation when the stencil test fails. Default "keep".

passOp?: GPUStencilOperation

Stencil operation when the stencil + depth tests both pass. Default "keep".

readMask?: number

Stencil read mask. Default 0xFF.

writeMask?: number

Stencil write mask. Default 0xFF.