Shader "Custom/DissolveShader" { Properties { _MainTex ("Texture", 2D) = "white" {} _Color ("Color", Color) = (1,1,1,1) _DissolveAmount ("Dissolve Amount", Range(0, 1)) = 0 _DissolveSpeed ("Dissolve Speed", Range(0, 1)) = 0.5 _NoiseScale ("Noise Scale", Range(0, 1)) = 0.1 } SubShader { Tags {"Queue"="Transparent" "RenderType"="Opaque"} Pass { CGPROGRAM #pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" struct appdata { float4 vertex : POSITION; float2 uv : TEXCOORD0; }; struct v2f { float2 uv : TEXCOORD0; float4 vertex : SV_POSITION; }; sampler2D _MainTex; float4 _MainTex_ST; float4 _Color; float _DissolveAmount; float _DissolveSpeed; float _NoiseScale; v2f vert (appdata v) { v2f o; o.vertex = UnityObjectToClipPos(v.vertex); o.uv = TRANSFORM_TEX(v.uv, _MainTex); return o; } float4 frag (v2f i) : SV_Target { float4 col = tex2D(_MainTex, i.uv) * _Color; float dissolveValue = _DissolveAmount + _Time.y * _DissolveSpeed; float noiseValue = 1.0 - tex2D(_MainTex, i.uv * _NoiseScale + _Time.y * _DissolveSpeed).r; dissolveValue = max(0, min(1, dissolveValue + noiseValue)); col.a *= dissolveValue; return col; } ENDCG } } FallBack "Diffuse" }