Shadow2D.hlsl 760 B

1234567891011121314151617181920212223242526272829
  1. #include "Uniforms.hlsl"
  2. #include "Samplers.hlsl"
  3. #include "Transform.hlsl"
  4. #include "ScreenPos.hlsl"
  5. #ifdef COMPILEPS
  6. uniform float4 cShadowAmbient;
  7. #endif
  8. void VS(float4 iPos : POSITION,
  9. out float2 oScreenPos : TEXCOORD0,
  10. out float4 oPos : OUTPOSITION)
  11. {
  12. float4x3 modelMatrix = iModelMatrix;
  13. float3 worldPos = GetWorldPos(modelMatrix);
  14. oPos = GetClipPos(worldPos);
  15. oScreenPos = GetScreenPosPreDiv(oPos);
  16. }
  17. void PS(float2 iScreenPos : TEXCOORD0, out float4 oColor : OUTCOLOR0)
  18. {
  19. float4 diffInput = Sample2D(DiffMap, iScreenPos);
  20. float4 lightInput = Sample2D(EmissiveMap, iScreenPos);
  21. oColor.rgb = (diffInput.rgb * (lightInput.rgb + cShadowAmbient.rgb) * (lightInput.a + cShadowAmbient.a));
  22. oColor.a = 1.0;
  23. }