Add shadows, fi other stuff

This commit is contained in:
2025-01-17 18:13:36 +01:00
parent 12cbbb4dcb
commit f413bf886b
37 changed files with 6379 additions and 31 deletions

View File

@@ -0,0 +1,47 @@
float4x4 gLightWorldViewProj : WorldViewProjection;
float4x4 gWorldViewProj: WorldViewProjection; //For compatibility sake
struct VS_Input {
float3 Position : POSITION;
float2 TexCoord : TEXCOORD;
float3 Normal : NORMAL;
float3 Tangent : TANGENT;
};
struct VS_Output
{
float4 Position : SV_POSITION;
};
VS_Output VS_Shadow(VS_Input input)
{
VS_Output output;
// Transform vertex position to light's clip space
output.Position = mul(float4(input.Position, 1.0f), gLightWorldViewProj);
return output;
}
float4 PS_Shadow(VS_Output input) : SV_TARGET
{
// Output depth information (Z/W in clip space)
// // gl_FragDepth = gl_FragCoord.z;
return float4(input.Position.z / input.Position.w, 0.0f, 0.0f, input.Position.z / input.Position.w);
}
// Rasterizer state for front face culling
RasterizerState FrontFaceCull
{
FrontCounterClockwise = FALSE;
CullMode = FRONT;
};
// Technique for rendering shadow map
technique11 DefaultTechnique
{
pass P0
{
//Set FrontFaceCulling
SetRasterizerState(FrontFaceCull);
SetVertexShader(CompileShader(vs_5_0, VS_Shadow()));
SetPixelShader(CompileShader(ps_5_0, PS_Shadow()));
}
}