Skip to main content
2 of 2
fixed typos, added code markdown, added HLSL tag
Pikalek
  • 13.4k
  • 5
  • 49
  • 54

What is the proper way to write a pixel shader that only outputs depth?

I have an effect that I want to only write to depth.
commandList->OMSetRenderTargets(0, nullptr, FALSE, &m_mainDepthStencilDescriptorHandle.getCpuHandle());

Pixel shader looks like this

struct VS_OUTPUT
{
    float4 position: SV_POSITION;
};

float4 main(VS_OUTPUT input) : SV_TARGET
{
    return float4(0.0f, 0.0f, 0.0f, 0.0f);
}

I do not use the SV_TARGET I am only interested in depth writing. What is the proper way to tell HLSL about it?