On this page
Dissolve
Blending over Time moves one weight across a surface. A dissolve moves the weight across space instead: a noise mask gives every pixel its own threshold, and a single progress value eats the surface from the weakest pixels first. It is the standard way game characters disappear, die, and reassemble, and the whole effect is one comparison.
half mask = SAMPLE_TEXTURE2D(_NoiseTex, sampler_NoiseTex, IN.uv).r;
half gone = step(_Progress, mask); // this pixel is no longer here
A threshold that travels¶
The trick is to replace the one weight with a grid of them. A noise texture is a map of random values, one per pixel, and each value is the moment at which that pixel will die. Progress starts at 0 and climbs to 1, and every pixel whose noise value is already below the progress is gone:
half mask = SAMPLE_TEXTURE2D(_NoiseTex, sampler_NoiseTex, IN.uv).r;
half alive = step(_Progress, mask);
Because the thresholds are random, the disintegration is organic. The surface eats from every weak point at once, the silhouette crumbles into itself, and the edge never retreats in a straight line. And because the whole thing is driven by one scalar, any system can feed it directly: a health bar, a quest completion, a held button, a timeline value. The same few lines scale from a character death to a UI flourish.
The edge does the selling¶
A hard cut is legible, but it is flat. The classic look has a hot rim along the cut: pixels whose threshold just passed glow instead of vanishing, and the line of disintegration carries energy. The band is a second comparison, one edge width behind the cut:
half alive = smoothstep(_Progress, _Progress + 0.001, mask);
half edge = smoothstep(_Progress - _EdgeWidth, _Progress, mask) * (1.0 - alive);
half3 color = base * alive + _EdgeColor.rgb * edge * _EdgeGlow;
The edge width is a span of noise values, not a span of pixels, and that is the knob that styles the effect. A narrow width gives a thin, incandescent spark along the cut. A wide one gives a fat halo of molten color. The glow multiplier past 1 pushes the band into bloom territory, so on a bright background the rim reads as light, not paint.
The noise asset is the real art direction here, and the same lines look completely different with a different one. Fine static crumbles the surface into dust. A low frequency swirl peels it off in sheets that follow the swirl. A directional grain erodes it from one side, which is how a lot of “energy discharge” effects work: the noise is the shape of the story, and the shader just enforces the rule.
What the shader does¶
The shader dissolves a texture from a noise mask, with a progress property, an edge width, an edge glow, and a mode toggle between manual and auto (auto loops the dissolve over a duration). The hot ring traces the moving cut line, and the edge width grows the rim from a thin spark to a fat halo.
Illustrative schematic: Pixels die in noise order; the hot ring traces the cut line.
One texture, one noise mask, a progress value with an auto loop, and a hot edge.
Shader "DecompiledArt/Textures/Time/Dissolve/Dissolve"
{
Properties
{
_MainTex("Texture", 2D) = "white" {}
_NoiseTex("Noise Mask (Repeat)", 2D) = "white" {}
[MainColor] _BaseColor("Base Color", Color) = (0.3, 0.6, 1.0, 1)
_EdgeColor("Edge Color", Color) = (1.0, 0.45, 0.12, 1)
_Progress("Progress", Range(0, 1)) = 0.55
_EdgeWidth("Edge Width", Range(0, 0.2)) = 0.06
_EdgeGlow("Edge Glow", Range(0, 3)) = 1.5
[Enum(Manual,0,Auto,1)] _Mode("Mode", Float) = 1
_Duration("Auto Duration (seconds)", Range(1, 20)) = 6
}
SubShader
{
Tags { "RenderType" = "Transparent" "RenderPipeline" = "UniversalPipeline" "Queue" = "Transparent" }
Pass
{
Name "Dissolve"
Tags { "LightMode" = "UniversalForward" }
Blend SrcAlpha OneMinusSrcAlpha
ZWrite Off
HLSLPROGRAM
#pragma vertex Vert
#pragma fragment Frag
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
TEXTURE2D(_MainTex); SAMPLER(sampler_MainTex);
TEXTURE2D(_NoiseTex); SAMPLER(sampler_NoiseTex);
struct Attributes
{
float4 positionOS : POSITION;
float2 uv : TEXCOORD0;
};
struct Varyings
{
float4 positionCS : SV_POSITION;
float2 uv : TEXCOORD0;
};
CBUFFER_START(UnityPerMaterial)
half4 _BaseColor;
half4 _EdgeColor;
half _Progress;
half _EdgeWidth;
half _EdgeGlow;
half _Mode;
float _Duration;
CBUFFER_END
Varyings Vert(Attributes IN)
{
Varyings OUT;
OUT.positionCS = TransformObjectToHClip(IN.positionOS.xyz);
OUT.uv = IN.uv;
return OUT;
}
half4 Frag(Varyings IN) : SV_Target
{
// Auto mode uses the same wrapped time rule as the rest of
// the Time library: a bounded phase, so the loop never overflows.
half progress = _Mode < 0.5h ? _Progress : frac(_Time.y / _Duration);
// Every pixel owns a threshold; below the progress it is gone.
half mask = SAMPLE_TEXTURE2D(_NoiseTex, sampler_NoiseTex, IN.uv).r;
half alive = smoothstep(progress, progress + 0.001, mask);
half edge = smoothstep(progress - _EdgeWidth, progress, mask) * (1.0 - alive);
half3 base = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, IN.uv).rgb;
half3 color = base * alive + _EdgeColor.rgb * edge * _EdgeGlow;
return half4(color * _BaseColor.rgb, alive * _BaseColor.a);
}
ENDHLSL
}
}
FallBack Off
}
🔗 Related Chapters¶
Blending over Time • Time Overflow • UVs & Time
Related functions: Smoothstep • Step
❤️ Support Shader Story¶
If this article helped you, consider supporting the project on Patreon: you’ll get access to the related source files and reference cheat-sheets.
Your support helps keep this library open and free for everyone.