Created
July 19, 2014 09:08
-
-
Save demonixis/e111048bd58a1f1155f3 to your computer and use it in GitHub Desktop.
A shadow map shader to use in a XNA/MonoGame application.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float4x4 World; | |
float4x4 View; | |
float4x4 Projection; | |
struct VertexShaderInput | |
{ | |
float4 Position : POSITION0; | |
}; | |
struct VertexShaderOutput | |
{ | |
float4 Position : POSITION0; | |
float2 depth:TEXCOORD0; | |
}; | |
VertexShaderOutput VertexShaderFunction(VertexShaderInput input) | |
{ | |
VertexShaderOutput output; | |
float4 worldPosition = mul(input.Position, World); | |
float4 viewPosition = mul(worldPosition, View); | |
output.Position = mul(viewPosition, Projection); | |
output.depth = output.Position.zw; | |
return output; | |
} | |
float4 PixelShaderFunction(VertexShaderOutput input) : COLOR0 | |
{ | |
return input.depth.x /input.depth.y; | |
} | |
technique Technique1 | |
{ | |
pass Pass1 | |
{ | |
#if SM4 | |
VertexShader = compile vs_4_0_level_9_3 VertexShaderFunction(); | |
PixelShader = compile ps_4_0_level_9_3 PixelShaderFunction(); | |
#else | |
VertexShader = compile vs_3_0 VertexShaderFunction(); | |
PixelShader = compile ps_3_0 PixelShaderFunction(); | |
#endif | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment