SpriteShadows.cginc 982 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #ifndef SPRITE_SHADOWS_INCLUDED
  2. #define SPRITE_SHADOWS_INCLUDED
  3. #include "ShaderShared.cginc"
  4. ////////////////////////////////////////
  5. // Vertex structs
  6. //
  7. struct vertexInput
  8. {
  9. float4 vertex : POSITION;
  10. float4 texcoord : TEXCOORD0;
  11. };
  12. struct vertexOutput
  13. {
  14. V2F_SHADOW_CASTER;
  15. float4 texcoordAndAlpha : TEXCOORD1;
  16. };
  17. ////////////////////////////////////////
  18. // Vertex program
  19. //
  20. vertexOutput vert(vertexInput v, float4 vertexColor : COLOR)
  21. {
  22. vertexOutput o;
  23. TRANSFER_SHADOW_CASTER(o)
  24. o.texcoordAndAlpha.xy = calculateTextureCoord(v.texcoord);
  25. o.texcoordAndAlpha.z = 0;
  26. o.texcoordAndAlpha.a = vertexColor.a;
  27. return o;
  28. }
  29. ////////////////////////////////////////
  30. // Fragment program
  31. //
  32. uniform fixed _ShadowAlphaCutoff;
  33. fixed4 frag(vertexOutput IN) : SV_Target
  34. {
  35. fixed4 texureColor = calculateTexturePixel(IN.texcoordAndAlpha.xy);
  36. clip(texureColor.a * IN.texcoordAndAlpha.a - _ShadowAlphaCutoff);
  37. SHADOW_CASTER_FRAGMENT(IN)
  38. }
  39. #endif // SPRITE_SHADOWS_INCLUDED