SoftMask.shader 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. Shader "Hidden/UI Default (Soft Masked)"
  2. {
  3. // This is a shader that replaces the Unity's Default UI shader. It has all capabilities
  4. // of the Default UI and also supports Soft Mask. It is a bit complicated because it
  5. // reflects changes of the Default UI shader between Unity versions. If you're searching
  6. // for an example of how to add Soft Mask support, you may check CustomWithSoftMask.shader
  7. // that's included in the package.
  8. Properties
  9. {
  10. [PerRendererData] _MainTex("Sprite Texture", 2D) = "white" {}
  11. _Color("Tint", Color) = (1,1,1,1)
  12. [PerRendererData] _SoftMask("Mask", 2D) = "white" {}
  13. _StencilComp("Stencil Comparison", Float) = 8
  14. _Stencil("Stencil ID", Float) = 0
  15. _StencilOp("Stencil Operation", Float) = 0
  16. _StencilWriteMask("Stencil Write Mask", Float) = 255
  17. _StencilReadMask("Stencil Read Mask", Float) = 255
  18. _ColorMask("Color Mask", Float) = 15
  19. [Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip("Use Alpha Clip", Float) = 0
  20. }
  21. SubShader
  22. {
  23. Tags
  24. {
  25. "Queue" = "Transparent"
  26. "IgnoreProjector" = "True"
  27. "RenderType" = "Transparent"
  28. "PreviewType" = "Plane"
  29. "CanUseSpriteAtlas" = "True"
  30. }
  31. Stencil
  32. {
  33. Ref[_Stencil]
  34. Comp[_StencilComp]
  35. Pass[_StencilOp]
  36. ReadMask[_StencilReadMask]
  37. WriteMask[_StencilWriteMask]
  38. }
  39. Cull Off
  40. Lighting Off
  41. ZWrite Off
  42. ZTest[unity_GUIZTestMode]
  43. Blend SrcAlpha OneMinusSrcAlpha
  44. ColorMask[_ColorMask]
  45. Pass
  46. {
  47. Name "Default"
  48. CGPROGRAM
  49. #pragma vertex vert
  50. #pragma fragment frag
  51. #pragma target 2.0
  52. #if UNITY_VERSION >= 201720
  53. #pragma multi_compile __ UNITY_UI_CLIP_RECT
  54. #endif
  55. #pragma multi_compile __ UNITY_UI_ALPHACLIP
  56. #pragma multi_compile __ SOFTMASK_SIMPLE SOFTMASK_SLICED SOFTMASK_TILED
  57. #include "SoftMaskTemplate.cginc"
  58. ENDCG
  59. }
  60. }
  61. }
  62. // UNITY_SHADER_NO_UPGRADE