1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160
| Shader "Unlit/TwoImageShader" { Properties { _MainTex ("Texture", 2D) = "white" {} _TwoTex ("TwoTexture", 2D) = "white" {} [HDR]_Color ("Color", Color) = (1,1,1,1) [hideinInspector] _MousePos ("MousePos", Vector) = (0,0,0,0) _Redius ("Redius", float) = 40 _Offset ("Offset", Range(0, 1)) = 0 _Pow ("Pow", Range(0, 2)) = 1 _ColorAmount ("ColorAmount", Range(0.5, 1)) = 0.5 } SubShader { Tags { "RenderType"="Transparent" "Queue"="Transparent"} Blend SrcAlpha OneMinusSrcAlpha
// Alpha0 Pass { CGPROGRAM
struct appdata { float4 vertex : POSITION; float2 uv : TEXCOORD0; };
struct v2f { float2 uv : TEXCOORD0; float4 vertex : SV_POSITION; };
sampler2D _MainTex; float4 _MainTex_ST; fixed4 _MousePos; float _Redius; float _Offset;
v2f vert (appdata v) { v2f o; o.vertex = UnityObjectToClipPos(v.vertex); o.uv = TRANSFORM_TEX(v.uv, _MainTex); return o; }
fixed4 frag (v2f i) : SV_Target { fixed4 col = tex2D(_MainTex, i.uv); float dis = distance(_MousePos.xy, i.vertex.xy); col.a = saturate(col.a - smoothstep(_Redius, 0, dis) + _Offset * sign(col.a-0.1)); return col; } ENDCG } // Image_2 Pass { CGPROGRAM
struct appdata { float4 vertex : POSITION; float2 uv : TEXCOORD0; };
struct v2f { float4 vertex : SV_POSITION; float2 uv : TEXCOORD0; };
fixed4 _MousePos; float _Redius; float _Offset; float _Pow; float _ColorAmount;
sampler2D _TwoTex; float4 _TwoTex_ST;
v2f vert (appdata v) { v2f o; o.vertex = UnityObjectToClipPos(v.vertex); o.uv = TRANSFORM_TEX(v.uv, _TwoTex); return o; }
fixed4 frag (v2f i) : SV_Target { fixed4 col = tex2D(_TwoTex, i.uv); float dis = distance(_MousePos.xy, i.vertex.xy); col.a = saturate(smoothstep(_Redius, 0, dis) - _Offset) * _ColorAmount; col.a = col.a * _Pow; return col; } ENDCG } // Color Pass { CGPROGRAM
struct appdata { float4 vertex : POSITION; float2 uv : TEXCOORD0; };
struct v2f { float4 vertex : SV_POSITION; float2 uv : TEXCOORD0; };
fixed4 _MousePos; float _Redius; float _Offset; float4 _Color; float _Pow; sampler2D _TwoTex; float4 _TwoTex_ST; float _ColorAmount;
v2f vert (appdata v) { v2f o; o.vertex = UnityObjectToClipPos(v.vertex); o.uv = TRANSFORM_TEX(v.uv, _TwoTex); return o; }
fixed4 frag (v2f i) : SV_Target { fixed4 col = _Color; float dis = distance(_MousePos.xy, i.vertex.xy); col.a = saturate(smoothstep(_Redius, 0, dis) - _Offset) * _ColorAmount; return col; } ENDCG } } }
|