Kav/Effects/HLSL/SimpleDepthEffect.fx

49 lines
958 B
HLSL

#include "Macros.fxh"
BEGIN_CONSTANTS
float4x4 ModelViewProjection _vs(c0) _cb(c0);
float near _vs(c4) _cb(c4);
float far _vs(c5) _cb(c5);
MATRIX_CONSTANTS
END_CONSTANTS
struct VertexShaderInput
{
float4 Position : POSITION;
};
struct VertexShaderOutput
{
float4 Position : SV_Position;
float Depth : TEXCOORD0;
};
VertexShaderOutput main_vs(VertexShaderInput input)
{
VertexShaderOutput output;
output.Position = mul(input.Position, ModelViewProjection);
output.Depth = output.Position.z / output.Position.w;
output.Depth = (output.Depth * 0.5) + 0.5;
return output;
}
float4 main_ps(VertexShaderOutput input) : SV_TARGET0
{
return float4(input.Depth, 0.0, 0.0, 0.0);
}
Technique SimpleDepth
{
Pass
{
VertexShader = compile vs_3_0 main_vs();
PixelShader = compile ps_3_0 main_ps();
}
}