Add shadows, fi other stuff
This commit is contained in:
47
project/resources/shadowEffect.fx
Normal file
47
project/resources/shadowEffect.fx
Normal 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()));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user