HighLight.shader 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. Shader "DashGame/HighLight"
  2. {
  3. Properties
  4. {
  5. [PerRendererData] _MainTex("Sprite Texture", 2D) = "white" {}
  6. _Scale("Scale", float) = 0.02
  7. _Color("Tint", Color) = (1,1,1,1)
  8. [MaterialToggle] PixelSnap("Pixel snap", Float) = 0
  9. }
  10. SubShader
  11. {
  12. Tags
  13. {
  14. "Queue" = "Transparent"
  15. "IgnoreProjector" = "True"
  16. "RenderType" = "Transparent"
  17. "PreviewType" = "Plane"
  18. "CanUseSpriteAtlas" = "True"
  19. }
  20. Cull Off
  21. Lighting Off
  22. ZWrite Off
  23. Pass
  24. {
  25. Blend SrcAlpha OneMinusSrcAlpha
  26. CGPROGRAM
  27. #pragma vertex vert
  28. #pragma fragment frag
  29. #pragma target 2.0
  30. #pragma multi_compile _ PIXELSNAP_ON
  31. #pragma multi_compile _ ETC1_EXTERNAL_ALPHA
  32. #include "UnityCG.cginc"
  33. struct appdata_t
  34. {
  35. float4 vertex : POSITION;
  36. float4 color : COLOR;
  37. float2 texcoord : TEXCOORD0;
  38. };
  39. struct v2f
  40. {
  41. fixed4 color : COLOR;
  42. float4 vertex : SV_POSITION;
  43. float2 texcoord : TEXCOORD0;
  44. };
  45. float _Scale;
  46. fixed4 _Color;
  47. v2f vert(appdata_t IN)
  48. {
  49. v2f OUT;
  50. OUT.vertex = UnityObjectToClipPos(IN.vertex);
  51. OUT.texcoord = IN.texcoord;
  52. OUT.color = IN.color * _Color;
  53. return OUT;
  54. }
  55. sampler2D _MainTex;
  56. fixed4 SampleSpriteTexture(float2 uv)
  57. {
  58. fixed4 color = tex2D(_MainTex, uv);
  59. return color;
  60. }
  61. fixed4 frag(v2f IN) : SV_Target
  62. {
  63. fixed4 c = SampleSpriteTexture(IN.texcoord) * IN.color;
  64. if (c.a == 0)
  65. {
  66. fixed4 c1 = SampleSpriteTexture(IN.texcoord + float2(0, _Scale));
  67. fixed4 c2 = SampleSpriteTexture(IN.texcoord + float2(_Scale, 0));
  68. fixed4 c3 = SampleSpriteTexture(IN.texcoord + float2(0, -_Scale));
  69. fixed4 c4 = SampleSpriteTexture(IN.texcoord + float2(-_Scale, 0));
  70. if (c1.a > 0 || c2.a > 0 || c3.a > 0 || c4.a > 0)
  71. {
  72. c.rgba = fixed4(1,0,0,1);
  73. }
  74. }
  75. else if (c.a < 1)
  76. {
  77. c.rgba = fixed4(1, 0, 0, 1);
  78. }
  79. return c;
  80. }
  81. ENDCG
  82. }
  83. }
  84. }