|
1 | 1 | Shader "Sprites/Pulse" { |
2 | 2 | Properties { |
3 | 3 | [PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {} |
4 | | - _Highlight ("Highlight", Color) = (1,1,1,1) |
5 | | - _Color ("Tint", Color) = (1,1,1,1) |
| 4 | + _Highlight ("Highlight", Color) = (1, 1, 1, 1) |
| 5 | + _Color ("Tint", Color) = (1, 1, 1, 1) |
6 | 6 | [MaterialToggle] PixelSnap ("Pixel snap", Float) = 0 |
7 | 7 | } |
8 | 8 |
|
9 | 9 | SubShader { |
10 | 10 | Tags { |
11 | | - "Queue"="Transparent" |
12 | | - "IgnoreProjector"="True" |
13 | | - "RenderType"="Transparent" |
14 | | - "PreviewType"="Plane" |
15 | | - "CanUseSpriteAtlas"="True" |
| 11 | + "Queue" = "Transparent" |
| 12 | + "IgnoreProjector" = "True" |
| 13 | + "RenderType" = "Transparent" |
| 14 | + "PreviewType" = "Plane" |
| 15 | + "CanUseSpriteAtlas" = "True" |
16 | 16 | } |
17 | 17 |
|
18 | 18 | Cull Off |
|
23 | 23 |
|
24 | 24 | Pass { |
25 | 25 | CGPROGRAM |
26 | | - #pragma vertex vert |
27 | | - #pragma fragment frag |
28 | | - #pragma multi_compile DUMMY PIXELSNAP_ON |
29 | | - #include "UnityCG.cginc" |
30 | | - |
31 | | - struct appdata_t { |
32 | | - float4 vertex : POSITION; |
33 | | - float4 color : COLOR; |
34 | | - float2 texcoord : TEXCOORD0; |
35 | | - }; |
36 | 26 |
|
37 | | - struct v2f { |
38 | | - float4 vertex : SV_POSITION; |
39 | | - fixed4 color : COLOR; |
40 | | - half2 texcoord : TEXCOORD0; |
41 | | - }; |
42 | | - |
43 | | - fixed4 _Color; |
44 | | - fixed4 _Highlight; |
| 27 | + #pragma vertex vert |
| 28 | + #pragma fragment frag |
| 29 | + #pragma multi_compile DUMMY PIXELSNAP_ON |
45 | 30 |
|
46 | | - v2f vert(appdata_t IN) { |
47 | | - v2f o; |
48 | | - o.vertex = UnityObjectToClipPos(IN.vertex); |
49 | | - o.texcoord = IN.texcoord; |
50 | | - o.color = IN.color * _Color; |
| 31 | + #include "UnityCG.cginc" |
51 | 32 |
|
52 | | - #ifdef PIXELSNAP_ON |
53 | | - o.vertex = UnityPixelSnap (o.vertex); |
54 | | - #endif |
| 33 | + fixed4 _Color; |
| 34 | + fixed4 _Highlight; |
| 35 | + sampler2D _MainTex; |
55 | 36 |
|
56 | | - return o; |
57 | | - } |
| 37 | + struct appdata { |
| 38 | + float4 vertex : POSITION; |
| 39 | + float4 color : COLOR; |
| 40 | + float2 uv : TEXCOORD0; |
| 41 | + }; |
58 | 42 |
|
59 | | - sampler2D _MainTex; |
| 43 | + struct v2f { |
| 44 | + float4 vertex : SV_POSITION; |
| 45 | + fixed4 color : COLOR; |
| 46 | + half2 uv : TEXCOORD0; |
| 47 | + }; |
| 48 | + |
| 49 | + v2f vert(appdata v) { |
| 50 | + v2f o; |
| 51 | + o.vertex = UnityObjectToClipPos(v.vertex); |
| 52 | + o.uv = v.uv; |
| 53 | + o.color = v.color * _Color; |
| 54 | + |
| 55 | + #ifdef PIXELSNAP_ON |
| 56 | + o.vertex = UnityPixelSnap(o.vertex); |
| 57 | + #endif |
| 58 | + |
| 59 | + return o; |
| 60 | + } |
| 61 | + |
| 62 | + fixed4 frag(v2f i) : COLOR { |
| 63 | + half4 texcol = tex2D(_MainTex, i.uv); |
| 64 | + texcol.rgb = lerp(texcol.rgb, _Highlight, (1 - min(1, pow(abs(sin(_Time[0] * 40) * 2), 2))) * _Highlight.a); |
| 65 | + texcol = texcol * i.color; |
| 66 | + return texcol; |
| 67 | + } |
60 | 68 |
|
61 | | - fixed4 frag(v2f IN) : COLOR { |
62 | | - half4 texcol = tex2D (_MainTex, IN.texcoord); |
63 | | - texcol.rgb = lerp(texcol.rgb, _Highlight, (1 - min(1, pow(abs(sin(_Time[0] * 40) * 2), 2))) * _Highlight.a); |
64 | | - texcol = texcol * IN.color; |
65 | | - return texcol; |
66 | | - } |
67 | 69 | ENDCG |
68 | 70 | } |
69 | 71 | } |
|
0 commit comments