Kav/Effects/HLSL/SimpleDepthEffect.fx

49 lines
958 B
Plaintext
Raw Normal View History

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