Shadow2D-Shadow-Sprite.shader 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. Shader "Hidden/Shadow2DShadowSprite"
  2. {
  3. Properties
  4. {
  5. _MainTex ("Texture", 2D) = "white" {}
  6. [HideInInspector] _ShadowColorMask("__ShadowColorMask", Int) = 1
  7. }
  8. SubShader
  9. {
  10. Tags { "RenderType"="Transparent" }
  11. Cull Off
  12. BlendOp Add
  13. Blend One One, One One
  14. ZWrite Off
  15. ZTest Always
  16. Pass
  17. {
  18. //Bit 0: Composite Shadow Bit, Bit 1: Global Shadow Bit
  19. Stencil
  20. {
  21. Ref 0
  22. Comp Equal
  23. Pass Keep
  24. Fail Keep
  25. }
  26. ColorMask [_ShadowColorMask]
  27. HLSLPROGRAM
  28. #pragma vertex vert
  29. #pragma fragment frag
  30. #include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
  31. struct Attributes
  32. {
  33. float4 vertex : POSITION;
  34. float2 uv : TEXCOORD0;
  35. };
  36. struct Varyings
  37. {
  38. float2 uv : TEXCOORD0;
  39. float4 vertex : SV_POSITION;
  40. };
  41. sampler2D _MainTex;
  42. float4 _MainTex_ST;
  43. Varyings vert (Attributes v)
  44. {
  45. Varyings o;
  46. o.vertex = TransformObjectToHClip(v.vertex.xyz);
  47. o.uv = TRANSFORM_TEX(v.uv, _MainTex);
  48. return o;
  49. }
  50. half4 frag(Varyings i) : SV_Target
  51. {
  52. half4 main = tex2D(_MainTex, i.uv);
  53. half color = main.a;
  54. return half4(color, color, color, color);
  55. }
  56. ENDHLSL
  57. }
  58. }
  59. }