Interface StencilState
interface StencilState {
compare?: GPUCompareFunction;
depthFailOp?: GPUStencilOperation;
failOp?: GPUStencilOperation;
passOp?: GPUStencilOperation;
readMask?: number;
writeMask?: number;
}
compare?: GPUCompareFunction;
depthFailOp?: GPUStencilOperation;
failOp?: GPUStencilOperation;
passOp?: GPUStencilOperation;
readMask?: number;
writeMask?: number;
}
Properties
Optional Readonlycompare
compare?: GPUCompareFunction
Stencil compare function, applied to front & back faces. Default "always".
Optional Readonlydepth Fail Op
depthFailOp?: GPUStencilOperation
Stencil operation when the stencil test passes but depth fails. Default "keep".
Optional Readonlyfail Op
failOp?: GPUStencilOperation
Stencil operation when the stencil test fails. Default "keep".
Optional Readonlypass Op
passOp?: GPUStencilOperation
Stencil operation when the stencil + depth tests both pass. Default "keep".
Optional Readonlyread Mask
readMask?: number
Stencil read mask. Default 0xFF.
Optional Readonlywrite Mask
writeMask?: number
Stencil write mask. Default 0xFF.
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 usescompare:"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. Assigningmaterial.stencilis inert until enableMaterialStencil is called (the opt-in that keeps stencil-free scenes byte-identical) — call it once beforeregisterScene.