AlphaTest.shader 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
  2. Shader "Custom/DoubleTransparent" {
  3. Properties{
  4. _MainTex("Main Text", 2D) = "white" {}
  5. [HDR]_Color ("Color Tint", Color) = (1, 1, 1, 1)
  6. _Magnitude ("Distortion Magnitude", Float) = 1
  7. _Frequency ("Distortion Frequency", Float) = 1
  8. _InvWaveLength ("Distortion Inverse Wave Length", Float) = 10
  9. _Speed ("Speed", Float) = 0.5
  10. _AlphaScale("AlphaScale",Range(0,1))=1
  11. }
  12. SubShader{
  13. Tags { "Queue" = "Transparent+1" "DisableBatching"="True"}
  14. Pass
  15. {
  16. Blend SrcAlpha OneMinusSrcAlpha
  17. Cull Off
  18. ZWrite Off
  19. CGPROGRAM
  20. #pragma vertex vert
  21. #pragma fragment frag
  22. #include "UnityCG.cginc"
  23. sampler2D _MainTex;
  24. float4 _MainTex_ST;
  25. fixed4 _Color;
  26. float _Magnitude;
  27. float _Frequency;
  28. float _InvWaveLength;
  29. float _Speed;
  30. float _AlphaScale;
  31. struct appdata
  32. {
  33. float4 vertex : POSITION;
  34. float4 texcoord : TEXCOORD0;
  35. };
  36. struct v2f
  37. {
  38. float4 pos : SV_POSITION;
  39. float2 uv: TEXCOORD1;
  40. };
  41. v2f vert(appdata v)
  42. {
  43. v2f o;
  44. float4 offset;
  45. offset.xzw = float3(0.0, 0.0, 0.0);
  46. offset.y = sin(_Frequency * _Time.y + v.vertex.x * _InvWaveLength + v.vertex.y * _InvWaveLength + v.vertex.z * _InvWaveLength) * _Magnitude;
  47. o.pos = UnityObjectToClipPos(v.vertex + offset);
  48. o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
  49. o.uv += float2(0.0, _Time.y * _Speed);
  50. return o;
  51. }
  52. float4 frag(v2f i) : SV_Target
  53. {
  54. fixed4 c = tex2D(_MainTex, i.uv);
  55. c.rgb *= _Color.rgb;
  56. c.a *=_AlphaScale;
  57. return c;
  58. }
  59. ENDCG
  60. }
  61. Pass {
  62. Tags { "LightMode" = "ShadowCaster" }
  63. CGPROGRAM
  64. #pragma vertex vert
  65. #pragma fragment frag
  66. #pragma multi_compile_shadowcaster
  67. #include "UnityCG.cginc"
  68. float _Magnitude;
  69. float _Frequency;
  70. float _InvWaveLength;
  71. float _Speed;
  72. struct v2f {
  73. V2F_SHADOW_CASTER;
  74. };
  75. v2f vert(appdata_base v) {
  76. v2f o;
  77. float4 offset;
  78. offset.xzw = float3(0.0, 0.0, 0.0);
  79. offset.y = sin(_Frequency * _Time.y + v.vertex.x * _InvWaveLength + v.vertex.y * _InvWaveLength + v.vertex.z * _InvWaveLength) * _Magnitude;
  80. v.vertex = v.vertex + offset;
  81. TRANSFER_SHADOW_CASTER_NORMALOFFSET(o)
  82. return o;
  83. }
  84. fixed4 frag(v2f i) : SV_Target {
  85. SHADOW_CASTER_FRAGMENT(i)
  86. }
  87. ENDCG
  88. }
  89. }
  90. }