Проблема с трафаретным буфером DirectX 11 - PullRequest
0 голосов
/ 29 июня 2019

Я пытаюсь снова окунуться в мир D3D и теперь играю с DX11.У меня есть простая проблема с примером буфера трафарета.В общем, трафарет работает, но я бы не хотел рисовать маску на моей сцене (розовый прямоугольник), просто остальные вещи:

До трафарета
После трафарета
Состояния трафарета:
Создание маски:

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;

Это неправильная настройка трафарета или может быть что-то еще (смешивание)?Может быть, это уже ответили (не может найти ничего полезного)?

...