/ShadowMap.fx
Created Jul 19, 2014
A shadow map shader to use in a XNA/MonoGame application.
| 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