CharactorShaderCullOff.shader 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. Shader "Custom/CharactorShaderCullOff"
  2. {
  3. Properties
  4. {
  5. _MainTex ("Base (RGB)", 2D) = "white" {}
  6. _AlphaTex ("Base (RGB)", 2D) = "white" {}
  7. _RandomTex ("Base (RGB)", 2D) = "white" {}
  8. _RimColor ("Rim Color", Color) = (1, 0, 0, 1)
  9. _Color("_Color", Color) = (0.5,0.5,0.5,1)
  10. _Rampage("_Rampage", Float) = 0
  11. _Frezz("_Frezz", Range(0, 1)) = 0
  12. }
  13. SubShader
  14. {
  15. Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
  16. Pass
  17. {
  18. cull off
  19. Blend SrcAlpha OneMinusSrcAlpha
  20. CGPROGRAM
  21. // Upgrade NOTE: excluded shader from DX11 and Xbox360; has structs without semantics (struct v2f members pos1)
  22. // #pragma exclude_renderers d3d11 xbox360
  23. #pragma target 2.0
  24. #pragma vertex vert
  25. #pragma fragment frag
  26. #include "UnityCG.cginc"
  27. struct appdata
  28. {
  29. float4 vertex : POSITION;
  30. float3 normal : NORMAL;
  31. float2 texcoord : TEXCOORD0;
  32. };
  33. struct v2f
  34. {
  35. half4 pos : SV_POSITION;
  36. half2 uv : TEXCOORD0;
  37. fixed3 color : COLOR;
  38. };
  39. uniform fixed4 _RimColor;
  40. uniform fixed _Rampage;
  41. uniform fixed _Frezz;
  42. v2f vert(appdata_base v)
  43. {
  44. v2f o;
  45. o.pos = UnityObjectToClipPos(v.vertex);
  46. if (_Rampage == 1)
  47. {
  48. fixed3 viewDir = normalize(ObjSpaceViewDir(v.vertex));
  49. fixed dotProduct = 1 - dot(v.normal, viewDir);
  50. o.color = smoothstep(0, 1, dotProduct);
  51. o.color *= _RimColor;
  52. }
  53. float3 normal = mul(SCALED_NORMAL, (float3x3)unity_WorldToObject);
  54. fixed dotProduct = dot(normal, fixed3(0, 1, 0)) / 2;
  55. if (dotProduct <= 0)
  56. {
  57. dotProduct = 0;
  58. }
  59. o.color += dotProduct.xxx;
  60. o.uv = v.texcoord.xy;
  61. return o;
  62. }
  63. uniform sampler2D _MainTex;
  64. uniform sampler2D _AlphaTex;
  65. uniform sampler2D _RandomTex;
  66. uniform fixed4 _Color;
  67. fixed4 frag(v2f i) : COLOR
  68. {
  69. fixed4 texcol = tex2D(_MainTex, i.uv);
  70. fixed4 alpha = tex2D(_AlphaTex, i.uv);
  71. float ClipTex = tex2D(_RandomTex, i.uv).r;
  72. float ClipAmount = (_Frezz - ClipTex) / 2 + 0.5;
  73. if (ClipAmount < 0)
  74. {
  75. ClipAmount = 0;
  76. }
  77. if (ClipAmount > 1)
  78. {
  79. ClipAmount = 1;
  80. }
  81. if (_Rampage == 1)
  82. {
  83. texcol.rgb += i.color;
  84. }
  85. texcol = texcol * ClipAmount + alpha * (1 - ClipAmount);
  86. texcol.a = alpha.a;
  87. clip(texcol.a - 0.5);
  88. texcol *= _Color;
  89. return texcol;
  90. }
  91. ENDCG
  92. }
  93. }
  94. FallBack "Legacy Shaders/Transparent/Cutout/VertexLit"
  95. }