DirectX 11模板缓冲区问题

时间:2019-06-29 09:40:47

标签: directx-11 stencil-buffer

我正试图再次跳入D3D世界,现在玩DX11。我有一个模板缓冲区示例的简单问题。在一般的模板工作,但我不想在我的场景(粉红色矩形)上绘制蒙版,只是剩下的东西:

Before stencil
After stencil
模具状态为:
遮罩创建:

depthStencilStateDescMask.DepthEnable = FALSE;
depthStencilStateDescMask.StencilEnable = TRUE;
depthStencilStateDescMask.StencilReadMask = 1;
depthStencilStateDescMask.StencilWriteMask= 1;
depthStencilStateDescMask.BackFace.StencilFunc = D3D11_COMPARISON_FUNC::D3D11_COMPARISON_ALWAYS;
depthStencilStateDescMask.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP::D3D11_STENCIL_OP_ZERO;
depthStencilStateDescMask.BackFace.StencilFailOp = D3D11_STENCIL_OP::D3D11_STENCIL_OP_ZERO;
depthStencilStateDescMask.BackFace.StencilPassOp = D3D11_STENCIL_OP::D3D11_STENCIL_OP_INCR_SAT;
depthStencilStateDescMask.FrontFace.StencilFunc = D3D11_COMPARISON_FUNC::D3D11_COMPARISON_ALWAYS;
depthStencilStateDescMask.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP::D3D11_STENCIL_OP_ZERO;
depthStencilStateDescMask.FrontFace.StencilFailOp = D3D11_STENCIL_OP::D3D11_STENCIL_OP_ZERO;
depthStencilStateDescMask.FrontFace.StencilPassOp = D3D11_STENCIL_OP::D3D11_STENCIL_OP_INCR_SAT;

应用遮罩:

depthStencilStateDescApply.DepthEnable = FALSE;
depthStencilStateDescApply.StencilEnable = TRUE;
depthStencilStateDescApply.StencilReadMask = 1;
depthStencilStateDescApply.StencilWriteMask = 1;
depthStencilStateDescApply.BackFace.StencilFunc = D3D11_COMPARISON_FUNC::D3D11_COMPARISON_LESS;
depthStencilStateDescApply.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP::D3D11_STENCIL_OP_ZERO;
depthStencilStateDescApply.BackFace.StencilFailOp = D3D11_STENCIL_OP::D3D11_STENCIL_OP_ZERO;
depthStencilStateDescApply.BackFace.StencilPassOp = D3D11_STENCIL_OP::D3D11_STENCIL_OP_KEEP;
depthStencilStateDescApply.FrontFace.StencilFunc = D3D11_COMPARISON_FUNC::D3D11_COMPARISON_LESS;
depthStencilStateDescApply.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP::D3D11_STENCIL_OP_ZERO;
depthStencilStateDescApply.FrontFace.StencilFailOp = D3D11_STENCIL_OP::D3D11_STENCIL_OP_ZERO;
depthStencilStateDescApply.FrontFace.StencilPassOp = D3D11_STENCIL_OP::D3D11_STENCIL_OP_KEEP;

这是错误的模具设置还是其他(融合)的东西?也许这已经被淹没了(找不到可用的东西)?

0 个答案:

没有答案