Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.67 KB | None | 0 0
  1. Shader "Dungelot/Sprites/Diffuse"
  2. {
  3. Properties
  4. {
  5. [PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
  6. _Color ("Tint", Color) = (1,1,1,1)
  7. [MaterialToggle] PixelSnap ("Pixel snap", Float) = 0
  8. [HideInInspector] _RendererColor ("RendererColor", Color) = (1,1,1,1)
  9. [HideInInspector] _Flip ("Flip", Vector) = (1,1,1,1)
  10. [PerRendererData] _AlphaTex ("External Alpha", 2D) = "white" {}
  11. [PerRendererData] _EnableExternalAlpha ("Enable External Alpha", Float) = 0
  12.  
  13. [Header(BLINK)]
  14. _BlinkColor ("Blink color", Color) = (1, 1, 1, 1)
  15. [Toggle]
  16. _BlinkToggle ("Blink toggle", Float) = 0
  17. _BlinkPower ("Blink power", Float) = 1
  18. [MaterialToggle] _BlinkBasic ("BlinkBasic", Float) = 1
  19.  
  20. [Header(BLOOD)]
  21. [Toggle]_Blood ("IsBloody", Float) = 0
  22. _BloodProgress ("BloodyProgress", Float) = 0
  23. _BloodTolerance ("Blood Tolerance", Float) = 0.7
  24. _BloodMask ("Blood Mask", Color) = (0.2,0.7,0.2,1)
  25.  
  26. [Header(BLINK)]
  27. _Tiling ("Tiling", Range(1, 500)) = 10
  28. _Direction ("Direction", Range(0, 1)) = 0
  29. _Move ("Move", Float) = 0
  30. _ColorBlink ("Blink Color", Color) = (1,1,1,1)
  31. _StripeThikness ("StripeThickness", Range(-100, 100)) = 0.5
  32. _Pixels ("Pixels", Vector) = (10,10,0,0)
  33. _FadeDistance ("Fade Distance", Float) = 16
  34. [MaterialToggle] _BlinkSelfColor ("Blink Self Color", Float) = 0
  35. [MaterialToggle] _BlinkSmooth ("Blink Smooth", Float) = 0
  36. [MaterialToggle] _Blink ("Is Blinking", Float) = 0
  37.  
  38.  
  39. }
  40.  
  41. SubShader
  42. {
  43. Tags
  44. {
  45. "Queue"="Transparent"
  46. "IgnoreProjector"="True"
  47. "RenderType"="Transparent"
  48. "PreviewType"="Plane"
  49. "CanUseSpriteAtlas"="True"
  50. }
  51.  
  52. Cull Off
  53. Lighting Off
  54. ZWrite Off
  55. // Blend One OneMinusSrcAlpha
  56. Blend SrcAlpha OneMinusSrcAlpha
  57.  
  58. CGPROGRAM
  59. #pragma surface surf Lambert vertex:vert nofog nolightmap nodynlightmap keepalpha noinstancing
  60. #pragma multi_compile _ PIXELSNAP_ON
  61. #pragma multi_compile _ ETC1_EXTERNAL_ALPHA
  62. #include "UnitySprites.cginc"
  63.  
  64.  
  65. fixed4 _BlinkColor;
  66. fixed4 _BloodMask;
  67.  
  68.  
  69. fixed _BlinkToggle;
  70. fixed _Blood;
  71. fixed _BloodProgress;
  72. fixed _BloodTolerance;
  73.  
  74. fixed _Blink;
  75. fixed _Tiling;
  76. fixed _Direction;
  77. fixed _Move;
  78. fixed _StripeThikness;
  79. fixed _FadeDistance;
  80. fixed _BlinkSelfColor;
  81. fixed _BlinkSmooth;
  82.  
  83. fixed _BlinkPower;
  84. fixed _BlinkBasic;
  85. fixed3 _Pixels;
  86. fixed4 _ColorBlink;
  87.  
  88. struct Input
  89. {
  90. float2 uv_MainTex;
  91.  
  92. fixed4 color;
  93. };
  94.  
  95. void vert (inout appdata_full v, out Input o)
  96. {
  97. v.vertex = UnityFlipSprite(v.vertex, _Flip);
  98.  
  99. #if defined(PIXELSNAP_ON)
  100. v.vertex = UnityPixelSnap (v.vertex);
  101. #endif
  102.  
  103. UNITY_INITIALIZE_OUTPUT(Input, o);
  104. o.color = v.color * _Color * _RendererColor;
  105. }
  106.  
  107. void surf (Input IN, inout SurfaceOutput o)
  108. {
  109.  
  110. fixed2 uv = IN.uv_MainTex;
  111. fixed4 c = SampleSpriteTexture (IN.uv_MainTex) * IN.color;
  112. fixed4 cMask = SampleSpriteTexture (IN.uv_MainTex) * fixed4(1,1,1,1);
  113. fixed4 color =cMask;
  114.  
  115. if (_Blood==1){
  116. fixed4 colorBlood = color;
  117. colorBlood.rgb = lerp(colorBlood.rgb, float3(1,1,1) - dot(colorBlood.rgb, _BloodMask.rgb), 1);
  118.  
  119. float noiseSample = colorBlood.r*_BloodProgress;
  120. if (noiseSample>=_BloodTolerance){
  121. c.rgb *= fixed3(1.25,0,0);
  122. }
  123.  
  124.  
  125. }
  126. if (_Blink==1){
  127. fixed3 colBlink = lerp(c.rgb*_ColorBlink,c.rgb,_BlinkSelfColor);
  128. fixed2 uvStripe = IN.uv_MainTex;
  129. fixed2 v = round(uvStripe * _Pixels.xy + 0.5) / _Pixels.xy;
  130. v.x+=_Move;
  131. fixed2 pos = lerp(v.x, v.y, _Direction) * _Tiling;
  132. // pos.x += _Move;
  133. fixed value = lerp ( frac(pos.x), floor(frac(pos.x)+_StripeThikness) , _BlinkSmooth) ;
  134. fixed alpha = 1 - _Move/_FadeDistance;
  135. // c.rgb = lerp(c.rgb,colBlink*5,value);
  136. c.rgb = lerp(c.rgb,lerp(c.rgb,colBlink*5, alpha), value );
  137. }
  138. o.Albedo = (_BlinkToggle==1? lerp(c.rgb*_BlinkColor.rgb*_BlinkPower, _BlinkColor.rgb, _BlinkBasic) : c.rgb) * c.a;
  139. o.Alpha = c.a;
  140. }
  141. ENDCG
  142. }
  143.  
  144. Fallback "Transparent/VertexLit"
  145. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement