Soft particles (depth-fade billboards)
Fade a particle sprite's opacity by how far it sits in front of the opaque scene depth, so smoke and fire blend into surfaces instead of cutting a hard line.
Also known as depth fade, depth-blended sprites
In the family Simulation & animation, particles & VFX
Where it runs
Built inOfficial add-onPluginNone foundNot researched
| Engine | Support | How |
|---|---|---|
| three.js r187 | Official add-on | import { softParticles } from 'three/addons/tsl/utils/SoftParticles.js' docs |
| Babylon.js 9.38.0 | None found | |
| Godot 4.7 | Built in | BaseMaterial3D.proximity_fade_enabled = true docs Depth-based fade against opaque geometry. |
| Unity | Official add-on | VFX Graph output > Use Soft Particle docs VFX Graph package. |
| Unreal 5.7 | Built in | Material graph: DepthFade expression on translucent particle materials docs |
| Blender 5.2 | None found | |
| WebGPU W3C | None found | |
| Metal | None found |
How it works
While drawing the quad, the fragment shader samples the scene depth buffer at its screen position and converts both that depth and the particle's own fragment depth to the same linear view-space measure. The difference is the thickness of empty space between the sprite and the surface behind it. The alpha is multiplied by a saturating function of that difference divided by a fade distance, often a smoothstep or a contrast curve. Where the sprite touches geometry the difference approaches zero and alpha goes to zero, hiding the intersection seam. The effect needs the opaque depth available as a texture while writing to a colour target with depth test off or read-only, so renderers copy depth or bind the depth attachment read-only. Refinements add a near-camera fade to avoid sprites clipping the near plane, and scale the fade distance by sprite size or density.
When to choose it
Reach for it when
- smoke sprites show a hard line where they hit the floor
- billboard fire cuts visibly through nearby walls
- particle quads need to fade out against scene geometry
- want sprites to blend softly into surfaces behind them
Choose it whenever billboard smoke, fire, dust or mist touches the ground or walls. Prefer Ray-marched Participating Media or Froxel Volumetric Fog when you need genuine thickness-based extinction and lighting, which soft particles only imitate at the edges. Prefer Particle systems plain rendering for effects that never meet geometry. It is a final shading step in GPU particle systems, and works with depth available from deferred or forward depth prepasses.
Field marks
- Particles inside large nearby volumes fade out entirely when the fade distance is too large relative to sprite size
- MSAA depth must be resolved or sampled per sample, otherwise edges show halos
- Reading and writing the same depth buffer without a copy is undefined on some platforms
- Only fades along the view ray, so sprite edges seen at grazing angles still intersect visibly
- Near-plane clipping hard-cuts big sprites unless a camera-distance fade is added
Presets
Soft Particles — hard billboard intersection clip (left) vs smooth depth-fade alpha (right)
{
"P_FADE_DIST": 0.48,
"P_SMOKE_DENS": 1.05,
"P_TURB_SPEED": 0.85,
"P_SPLIT": 0.48
}Show GLSL (148 lines)
const float P_FADE_DIST = 0.48; // P Depth Fade Range [0.05, 1.2, 0.02]
const float P_SMOKE_DENS = 1.05; // P Plume Opacity [0.3, 1.8, 0.05]
const float P_TURB_SPEED = 0.85; // P Rise Speed [0.0, 2.2, 0.05]
const float P_SPLIT = 0.48; // P Hard / Soft Split [0.0, 1.0, 0.02]
float hash21(vec2 p) {
p = fract(p * vec2(127.1, 311.7));
p += dot(p, p + 34.5);
return fract(p.x * p.y);
}
float noise2(vec2 p) {
vec2 i = floor(p);
vec2 f = fract(p);
f = f * f * (3.0 - 2.0 * f);
return mix(
mix(hash21(i), hash21(i + vec2(1.0, 0.0)), f.x),
mix(hash21(i + vec2(0.0, 1.0)), hash21(i + vec2(1.0, 1.0)), f.x),
f.y
);
}
float fbm(vec2 p) {
float s = 0.0;
float a = 0.5;
for (int i = 0; i < 4; i++) {
s += a * noise2(p);
p = p * 2.04 + vec2(13.1, 7.7);
a *= 0.5;
}
return s;
}
float sdBox(vec3 p, vec3 b) {
vec3 q = abs(p) - b;
return length(max(q, 0.0)) + min(max(q.x, max(q.y, q.z)), 0.0);
}
// Solid opaque scene: tiled floor, angled concrete wall, and central pillar intersecting smoke sprites
vec2 mapOpaque(vec3 p) {
vec2 res = vec2(p.y + 0.62, 1.0); // floor
float dWall = sdBox(p - vec3(0.0, 0.2, -0.78), vec3(2.4, 1.2, 0.14));
if (dWall < res.x) res = vec2(dWall, 2.0);
float dPillar = sdBox(p - vec3(-0.02, -0.05, 0.08), vec3(0.22, 0.72, 0.22)) - 0.02;
if (dPillar < res.x) res = vec2(dPillar, 3.0);
float dCrate = sdBox(p - vec3(0.68, -0.34, 0.22), vec3(0.28, 0.28, 0.28)) - 0.02;
if (dCrate < res.x) res = vec2(dCrate, 3.0);
return res;
}
vec3 calcNormal(vec3 p) {
vec2 e = vec2(0.0025, 0.0);
return normalize(vec3(
mapOpaque(p + e.xyy).x - mapOpaque(p - e.xyy).x,
mapOpaque(p + e.yxy).x - mapOpaque(p - e.yxy).x,
mapOpaque(p + e.yyx).x - mapOpaque(p - e.yyx).x
));
}
vec3 aces(vec3 x) {
x = max(x, 0.0);
return (x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14);
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
float screenX = fragCoord.x / max(iResolution.x, 1.0);
float split = clamp(P_SPLIT, 0.0, 1.0);
bool isSoft = screenX >= split;
float fadeDist = max(P_FADE_DIST, 0.02);
float smokeDens = clamp(P_SMOKE_DENS, 0.2, 2.0);
float tAnim = iTime * max(P_TURB_SPEED, 0.0);
vec3 ro = vec3(0.0, 0.24, 2.35);
vec3 rd = normalize(vec3(uv - vec2(0.0, 0.06), -1.55));
// 1. Render opaque scene depth buffer (zScene) and lit shading
float tScene = 0.0;
float matId = 0.0;
bool hit = false;
for (int i = 0; i < 64; i++) {
vec2 h = mapOpaque(ro + rd * tScene);
if (h.x < 0.002) { hit = true; matId = h.y; break; }
tScene += h.x;
if (tScene > 9.0) break;
}
vec3 col = mix(vec3(0.04, 0.06, 0.10), vec3(0.11, 0.15, 0.22), smoothstep(-0.4, 0.6, uv.y));
if (hit) {
vec3 p = ro + rd * tScene;
vec3 n = calcNormal(p);
vec3 lDir = normalize(vec3(0.52, 0.84, 0.45));
float diff = max(dot(n, lDir), 0.0);
float ao = clamp(0.42 + 0.58 * mapOpaque(p + n * 0.22).x / 0.22, 0.2, 1.0);
vec3 alb = vec3(0.32, 0.36, 0.42);
if (matId < 1.5) {
float chk = mod(floor(p.x * 2.5) + floor(p.z * 2.5), 2.0);
alb = mix(vec3(0.16, 0.19, 0.24), vec3(0.28, 0.32, 0.38), chk);
} else if (matId > 2.5) {
alb = vec3(0.42, 0.46, 0.52);
}
col = alb * (0.25 + 0.85 * diff) * ao;
} else {
tScene = 9.0;
}
// 2. Composite 10 back-to-front camera-facing smoke billboard sprites that cut through the floor & pillar
for (int i = 0; i < 10; i++) {
float fi = float(i);
float zPlane = -0.35 + fi * 0.11;
float tSprite = (zPlane - ro.z) / rd.z;
if (tSprite <= 0.05) continue;
// Depth difference between opaque scene and particle sprite
float deltaZ = tScene - tSprite;
if (deltaZ <= 0.0) continue; // behind opaque geometry
vec3 pHit = ro + rd * tSprite;
vec2 center = vec2(-0.55 + mod(fi * 0.37, 1.18), -0.44 + mod(fi * 0.19 + tAnim * 0.16, 0.72));
float rad = 0.44 + 0.06 * sin(fi * 2.1);
vec2 local = (pHit.xy - center) / rad;
float r2 = dot(local, local);
if (r2 >= 1.0) continue;
float puffNoise = fbm(local * 2.6 + vec2(fi * 3.1, -tAnim * 0.55));
float radial = pow(max(1.0 - r2, 0.0), 1.35);
float baseAlpha = clamp(radial * (0.45 + 0.95 * puffNoise) * 0.62 * smokeDens, 0.0, 0.92);
// Core technique: Hard depth-test clip (left) vs Soft Particle depth fade (right)
float depthFade = isSoft ? smoothstep(0.0, fadeDist, deltaZ) : 1.0;
float alpha = baseAlpha * depthFade;
// Subtle warm backlit smoke shading
float topLit = clamp(local.y * 0.5 + 0.55 + puffNoise * 0.25, 0.0, 1.0);
vec3 smokeCol = mix(vec3(0.28, 0.34, 0.44), vec3(0.98, 0.84, 0.68), topLit);
// Highlight the ugly hard intersection seam on left so the failure mode is crystal clear
if (!isSoft && deltaZ < 0.045) {
smokeCol = mix(smokeCol, vec3(1.0, 0.42, 0.28), 0.35);
}
col = mix(col, smokeCol, alpha);
}
// Split divider
float sep = smoothstep(0.0035, 0.0008, abs(screenX - split));
col = mix(col, vec3(0.95, 0.97, 1.0), sep);
fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);
}Attribution: MIT — written for this index.
Measured GPU weight & timing
| Preset | GPU | Weight / p50 / p95 | Method |
|---|---|---|---|
| soft-particles-live | Tesla T4 1920x1080 | 27.4× baseline (heavy) · 0.851 ms / 0.907 ms | opengl-timer-query · 36 frames · GPU Weight Atlas · Colab T4 sweep |
| soft-particles-live | NVIDIA L4 1920x1080 | 25.7× baseline (heavy) · 0.409 ms / 0.414 ms · 2.1× faster on L4 | opengl-timer-query · Cross-architecture validation |
| soft-particles-live | NVIDIA A100-SXM4-40GB 1920x1080 | 17.9× baseline (moderate) · 0.516 ms / 0.527 ms · 1.6× faster on A100 | opengl-timer-query · Cross-architecture validation |
Crosses
- Depth-feathered soft-particle mist emitted from PBF splash crests: Triggering buoyant, depth-faded soft-particle spray and sea-mist billboards directly from high-vorticity, low-neighbor PBF wave crests adds believable breaking-wave atmosphere without needing a full multi-million-particle whitewater solver.
- Depth-feathered soft-particle smoke wrapping live visual-hull silhouettes: Carving an instant multi-camera visual hull of a moving actor or sculpture supplies a real-time 3D proxy depth buffer that lets soft-particle mist, steam, or glowing dust wrap seamlessly around live bodies without hard billboard clipping lines.
- GPU particle systems: The instanced sprite fragment shader reads scene depth and fades alpha at intersections.
- Froxel Volumetric Fog: Soft-faded sprites sit inside the fog, and fog light scattering is applied on top for consistent atmosphere.
Sources
- primaryTristan Lorach. Soft Particles (NVIDIA SDK 10 white paper). developer.download.nvidia.com.Verified via live page · 2026-11-29