48 lines
1.1 KiB
HLSL
48 lines
1.1 KiB
HLSL
#include "Macros.fxh"
|
|
|
|
BEGIN_CONSTANTS
|
|
|
|
float4x4 Model _vs(c0) _cb(c0);
|
|
float4x4 ModelViewProjection _vs(c4) _cb(c4);
|
|
|
|
float3 LightPosition _ps(c0) _cb(c8);
|
|
float FarPlane _ps(c1) _cb(c9);
|
|
|
|
END_CONSTANTS
|
|
|
|
struct VertexShaderInput
|
|
{
|
|
float4 Position : POSITION;
|
|
};
|
|
|
|
struct VertexShaderOutput
|
|
{
|
|
float4 Position : SV_Position;
|
|
float3 PositionWorld : TEXCOORD0;
|
|
};
|
|
|
|
VertexShaderOutput main_vs(VertexShaderInput input)
|
|
{
|
|
VertexShaderOutput output;
|
|
output.Position = mul(input.Position, ModelViewProjection);
|
|
output.Position.x *= -1; // otherwise cube map render will be horizontally flipped
|
|
output.PositionWorld = mul(input.Position, Model);
|
|
return output;
|
|
}
|
|
|
|
float4 main_ps(VertexShaderOutput input) : SV_TARGET0
|
|
{
|
|
float lightDistance = length(input.PositionWorld - LightPosition);
|
|
lightDistance /= FarPlane;
|
|
return float4(lightDistance, 0.0, 0.0, 0.0);
|
|
}
|
|
|
|
Technique SimpleDepth
|
|
{
|
|
Pass
|
|
{
|
|
VertexShader = compile vs_3_0 main_vs();
|
|
PixelShader = compile ps_3_0 main_ps();
|
|
}
|
|
}
|