Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Shader "Dungelot/Sprites/Diffuse"
- {
- Properties
- {
- [PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
- _Color ("Tint", Color) = (1,1,1,1)
- [MaterialToggle] PixelSnap ("Pixel snap", Float) = 0
- [HideInInspector] _RendererColor ("RendererColor", Color) = (1,1,1,1)
- [HideInInspector] _Flip ("Flip", Vector) = (1,1,1,1)
- [PerRendererData] _AlphaTex ("External Alpha", 2D) = "white" {}
- [PerRendererData] _EnableExternalAlpha ("Enable External Alpha", Float) = 0
- [Header(BLINK)]
- _BlinkColor ("Blink color", Color) = (1, 1, 1, 1)
- [Toggle]
- _BlinkToggle ("Blink toggle", Float) = 0
- _BlinkPower ("Blink power", Float) = 1
- [MaterialToggle] _BlinkBasic ("BlinkBasic", Float) = 1
- [Header(BLOOD)]
- [Toggle]_Blood ("IsBloody", Float) = 0
- _BloodProgress ("BloodyProgress", Float) = 0
- _BloodTolerance ("Blood Tolerance", Float) = 0.7
- _BloodMask ("Blood Mask", Color) = (0.2,0.7,0.2,1)
- [Header(BLINK)]
- _Tiling ("Tiling", Range(1, 500)) = 10
- _Direction ("Direction", Range(0, 1)) = 0
- _Move ("Move", Float) = 0
- _ColorBlink ("Blink Color", Color) = (1,1,1,1)
- _StripeThikness ("StripeThickness", Range(-100, 100)) = 0.5
- _Pixels ("Pixels", Vector) = (10,10,0,0)
- _FadeDistance ("Fade Distance", Float) = 16
- [MaterialToggle] _BlinkSelfColor ("Blink Self Color", Float) = 0
- [MaterialToggle] _BlinkSmooth ("Blink Smooth", Float) = 0
- [MaterialToggle] _Blink ("Is Blinking", Float) = 0
- }
- SubShader
- {
- Tags
- {
- "Queue"="Transparent"
- "IgnoreProjector"="True"
- "RenderType"="Transparent"
- "PreviewType"="Plane"
- "CanUseSpriteAtlas"="True"
- }
- Cull Off
- Lighting Off
- ZWrite Off
- // Blend One OneMinusSrcAlpha
- Blend SrcAlpha OneMinusSrcAlpha
- CGPROGRAM
- #pragma surface surf Lambert vertex:vert nofog nolightmap nodynlightmap keepalpha noinstancing
- #pragma multi_compile _ PIXELSNAP_ON
- #pragma multi_compile _ ETC1_EXTERNAL_ALPHA
- #include "UnitySprites.cginc"
- fixed4 _BlinkColor;
- fixed4 _BloodMask;
- fixed _BlinkToggle;
- fixed _Blood;
- fixed _BloodProgress;
- fixed _BloodTolerance;
- fixed _Blink;
- fixed _Tiling;
- fixed _Direction;
- fixed _Move;
- fixed _StripeThikness;
- fixed _FadeDistance;
- fixed _BlinkSelfColor;
- fixed _BlinkSmooth;
- fixed _BlinkPower;
- fixed _BlinkBasic;
- fixed3 _Pixels;
- fixed4 _ColorBlink;
- struct Input
- {
- float2 uv_MainTex;
- fixed4 color;
- };
- void vert (inout appdata_full v, out Input o)
- {
- v.vertex = UnityFlipSprite(v.vertex, _Flip);
- #if defined(PIXELSNAP_ON)
- v.vertex = UnityPixelSnap (v.vertex);
- #endif
- UNITY_INITIALIZE_OUTPUT(Input, o);
- o.color = v.color * _Color * _RendererColor;
- }
- void surf (Input IN, inout SurfaceOutput o)
- {
- fixed2 uv = IN.uv_MainTex;
- fixed4 c = SampleSpriteTexture (IN.uv_MainTex) * IN.color;
- fixed4 cMask = SampleSpriteTexture (IN.uv_MainTex) * fixed4(1,1,1,1);
- fixed4 color =cMask;
- if (_Blood==1){
- fixed4 colorBlood = color;
- colorBlood.rgb = lerp(colorBlood.rgb, float3(1,1,1) - dot(colorBlood.rgb, _BloodMask.rgb), 1);
- float noiseSample = colorBlood.r*_BloodProgress;
- if (noiseSample>=_BloodTolerance){
- c.rgb *= fixed3(1.25,0,0);
- }
- }
- if (_Blink==1){
- fixed3 colBlink = lerp(c.rgb*_ColorBlink,c.rgb,_BlinkSelfColor);
- fixed2 uvStripe = IN.uv_MainTex;
- fixed2 v = round(uvStripe * _Pixels.xy + 0.5) / _Pixels.xy;
- v.x+=_Move;
- fixed2 pos = lerp(v.x, v.y, _Direction) * _Tiling;
- // pos.x += _Move;
- fixed value = lerp ( frac(pos.x), floor(frac(pos.x)+_StripeThikness) , _BlinkSmooth) ;
- fixed alpha = 1 - _Move/_FadeDistance;
- // c.rgb = lerp(c.rgb,colBlink*5,value);
- c.rgb = lerp(c.rgb,lerp(c.rgb,colBlink*5, alpha), value );
- }
- o.Albedo = (_BlinkToggle==1? lerp(c.rgb*_BlinkColor.rgb*_BlinkPower, _BlinkColor.rgb, _BlinkBasic) : c.rgb) * c.a;
- o.Alpha = c.a;
- }
- ENDCG
- }
- Fallback "Transparent/VertexLit"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement