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
| Shader "Custom/CharacterDissolve" { Properties { [Header(Base)] [NoScaleOffset]_MainTex("MainTex",2D) = "white"{} _Color ("Color",Color) = (0,0,0,0)
[Space(10)] [Header(Dissolve)] _DissolveTex("DissolveTex(R)",2D) = "white"{} [NoScaleOffset]_DissolveRampTex("DissolveRampTex(RGB)",2D)= "white"{} _DissolveIntensity("DissolveIntensity", Range(0.01, 1)) = 0.1 _DissolveThreshold("DissolveThreshold",Range(-0.1, 1)) = -0.1 }
SubShader { Tags { "RenderType"="Opaque" }
pass { CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc"
sampler2D _MainTex; fixed4 _Color; sampler2D _DissolveTex;float4 _DissolveTex_ST; sampler _DissolveRampTex; fixed _DissolveIntensity; fixed _DissolveThreshold;
struct appdata { float4 vertex :POSITION; float4 uv :TEXCOORD; };
struct v2f { float4 pos :SV_POSITION; float4 uv :TEXCOORD; float4 worldPos:TEXCOORD1; };
v2f vert(appdata v) { v2f o; o.pos = UnityObjectToClipPos(v.vertex); o.uv.xy = v.uv.xy; o.uv.zw = TRANSFORM_TEX(v.uv, _DissolveTex); o.worldPos = mul(unity_ObjectToWorld, v.vertex);
return o; }
fixed4 frag(v2f i) : SV_TARGET { fixed4 outColor; fixed4 tex = tex2D(_MainTex, i.uv.xy); outColor = tex * _Color;
fixed4 dissolveTex = tex2D(_DissolveTex, i.uv.zw); fixed dissolveFac = dissolveTex.r - _DissolveThreshold;
clip(dissolveFac); fixed dissolveValue = saturate(dissolveFac / _DissolveIntensity); fixed4 rampTex = tex1D(_DissolveRampTex, dissolveValue); outColor.rgb = lerp(outColor.rgb, rampTex.rgb, step(0.01, rampTex.r));
return outColor; }
ENDCG } }
Fallback "Legacy Shaders/VertexLit" }
|