Search code examples
objective-cmetalmetalkit

What is the equivalent in metal of glEnable(GL_STENCIL_TEST)?


What is the equivalent in metal of glEnable(GL_STENCIL_TEST)? The Stencil Test is a per-sample operation performed after the Fragment Shader. The fragment's stencil value is tested against the value in the current stencil buffer; if the test fails, the fragment is culled.


Solution

  • Use a depth-stencil state object created from a descriptor whose frontFaceStencil and/or backFaceStencil are set to descriptors with a stencilCompareFunction other than MTLCompareFunctionAlways.