-1

I am currently working on rendering a row of textured cubes using D3D12, and I have noticed that the front face of the cubes that should be occluded is being rendered and covering the cube. How can I fix this? I want the occluded front faces to not be visible.

Thank you.

enter image description here

enter image description here

DGAF
  • 71
  • 7
  • 2
    Please show a [mre] of the code you're using – Alan Birtles Jun 13 '23 at 06:18
  • Perhaps you have disabled back-facing culling when setting up rasterizer state or cube model has incorrect facing of triangles which leads to such an image given the lack of depth testing. – user7860670 Jun 13 '23 at 07:15

1 Answers1

2

I just checked my code and found that after successfully creating the DepthStencilView (DSV), I forgot to bind the DSVHandle to OMSetRenderTarget. After binding it, the occluded parts are no longer being rendered. Thank you, everyone, for your expertise.

    pD3D12CommandList->OMSetRenderTargets(1, &RTVHandle, false, &DSVHandle);

    pD3D12CommandList->ClearDepthStencilView(pDSVHeap->GetCPUDescriptorHandleForHeapStart(), D3D12_CLEAR_FLAG_DEPTH, 1.0f, 0, 0, nullptr);

DGAF
  • 71
  • 7