Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

////////////////////////////////////////////////////////////////////////////////

// Filename: depth.ps
////////////////////////////////////////////////////////////////////////////////

//////////////
// TYPEDEFS //
//////////////
struct PixelInputType
{
float4 position : SV_POSITION;
float4 depthPosition : TEXTURE0;
};

////////////////////////////////////////////////////////////////////////////////
// Pixel Shader
////////////////////////////////////////////////////////////////////////////////
float4 DepthPixelShader(PixelInputType input) : SV_TARGET
{
float depthValue;
float4 color;

// Get the depth value of the pixel by dividing the Z pixel depth by the
homogeneous W coordinate.
depthValue = input.depthPosition.z / input.depthPosition.w;

color = float4(depthValue, depthValue, depthValue, 1.0f);

return color;
}

You might also like