Position Based Fluids × Soft particles (depth-fade billboards)
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.
Open in StudioReproduced45.3× · 1.40 ms
Verified proof

Split-screen WebGL2 proof comparing a breaking PBF fluid wave with hard-clipped spray billboards that slice sharply into the seawall and water surface (left) against vorticity-triggered PBF splash mist softly depth-feathered against solid and fluid linear depth with sunset scattering (right).
Chromium Headless ANGLE/SwiftShader WebGL2 · 512x512 · eliminates hard billboard clipping seams along seawall and wave intersections via linear depth-feathered soft-particle PBF crest spray
Show GLSL proof (165 lines)
const float P_FADE_DEPTH = 0.42; // P Soft Fade Distance [0.08, 0.9, 0.02]
const float P_SPRAY_DENS = 0.95; // P Crest Spray Alpha [0.2, 1.6, 0.05]
const float P_WAVE_SPEED = 1.00; // P Wave Velocity [0.2, 1.8, 0.05]
const float P_SUN_GLOW = 1.10; // P Mist Backscatter [0.3, 2.0, 0.05]
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 vnoise(vec2 p) {
vec2 i = floor(p);
vec2 f = fract(p);
vec2 u = f * f * (3.0 - 2.0 * f);
return mix(
mix(hash21(i), hash21(i + vec2(1.0, 0.0)), u.x),
mix(hash21(i + vec2(0.0, 1.0)), hash21(i + vec2(1.0, 1.0)), u.x),
u.y
);
}
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);
}
// Breaking PBF wave surface + coastal stone seawall pier
vec2 mapOpaque(vec3 p, float t) {
// Angled stone seawall on right side
float pier = sdBox(p - vec3(1.18, -0.10, -0.20), vec3(0.58, 0.85, 1.65)) - 0.04;
// Breaking PBF fluid body surging into the pier
float tt = t * P_WAVE_SPEED;
float crestX = 0.42 + 0.14 * sin(tt * 1.4);
float waveProfile = 0.42 * exp(-pow((p.x - crestX) * 1.45, 2.0));
float curl = 0.14 * sin(p.z * 2.4 + tt * 2.2) * waveProfile;
float ripples = 0.035 * sin(p.x * 9.0 - tt * 4.0) * cos(p.z * 7.0 + tt * 2.5);
float waterY = -0.38 + waveProfile + curl + ripples;
float dWater = p.y - waterY;
if (pier < dWater) return vec2(pier, 1.0);
return vec2(dWater, 2.0);
}
vec3 calcNormal(vec3 p, float t) {
vec2 e = vec2(0.005, -0.005);
return normalize(
e.xyy * mapOpaque(p + e.xyy, t).x +
e.yyx * mapOpaque(p + e.yyx, t).x +
e.yxy * mapOpaque(p + e.yxy, t).x +
e.xxx * mapOpaque(p + e.xxx, t).x
);
}
vec3 acesTone(vec3 x) {
return clamp((x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14), 0.0, 1.0);
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 res = max(iResolution.xy, vec2(1.0));
vec2 uvN = fragCoord / res;
float splitX = iMouse.z > 0.0 ? clamp(iMouse.x / res.x, 0.05, 0.95) : 0.5;
bool useSoft = uvN.x > splitX;
vec2 p = (fragCoord - 0.5 * res) / res.y;
float t = iTime;
vec3 ro = vec3(-0.35, 0.45, 2.75);
vec3 ta = vec3(0.32, 0.02, -0.15);
vec3 fw = normalize(ta - ro);
vec3 ri = normalize(cross(vec3(0.0, 1.0, 0.0), fw));
vec3 up = cross(fw, ri);
vec3 rd = normalize(fw * 1.55 + ri * p.x + up * p.y);
vec3 sunDir = normalize(vec3(-0.55, 0.36, -0.75));
float skyH = clamp(rd.y * 1.3 + 0.22, 0.0, 1.0);
vec3 sky = mix(vec3(0.92, 0.54, 0.34), vec3(0.10, 0.22, 0.42), pow(skyH, 0.72));
sky += vec3(1.8, 1.05, 0.52) * pow(max(dot(rd, sunDir), 0.0), 24.0) * 0.75;
// Pass 1: Trace opaque seawall & PBF fluid body to populate linear sceneDepth
float sceneDepth = 14.0;
float hitMat = -1.0;
float d = 0.2;
for (int i = 0; i < 60; i++) {
vec2 h = mapOpaque(ro + rd * d, t);
if (h.x < 0.004) { sceneDepth = d; hitMat = h.y; break; }
d += max(h.x * 0.68, 0.02);
if (d > 14.0) break;
}
vec3 col = sky;
if (hitMat > 0.0) {
vec3 wp = ro + rd * sceneDepth;
vec3 N = calcNormal(wp, t);
vec3 V = -rd;
float ndl = max(dot(N, sunDir), 0.0);
if (hitMat < 1.5) {
// Weathered stone seawall pier
float masonry = 0.82 + 0.18 * vnoise(wp.zy * 9.0 + wp.x * 4.0);
float wetLine = smoothstep(0.18, -0.18, wp.y);
vec3 stone = mix(vec3(0.46, 0.44, 0.42), vec3(0.18, 0.20, 0.22), wetLine * 0.65) * masonry;
float spec = pow(max(dot(N, normalize(sunDir + V)), 0.0), 32.0) * wetLine * 0.45;
col = stone * (vec3(0.22, 0.26, 0.36) + vec3(1.25, 0.92, 0.66) * ndl) + vec3(1.0, 0.85, 0.65) * spec;
} else {
// PBF ocean liquid with subsurface turquoise glow at thin breaking crest
float fres = 0.04 + 0.96 * pow(1.0 - max(dot(N, V), 0.0), 4.0);
float crestThin = smoothstep(-0.15, 0.22, wp.y);
vec3 deepSea = vec3(0.03, 0.14, 0.22);
vec3 sssTeal = vec3(0.08, 0.56, 0.58) * crestThin * (0.45 + 0.85 * pow(max(dot(rd, sunDir), 0.0), 3.0));
vec3 refl = mix(vec3(0.18, 0.30, 0.46), vec3(1.0, 0.68, 0.42), pow(max(dot(reflect(rd, N), sunDir), 0.0), 6.0));
float spec = pow(max(dot(N, normalize(sunDir + V)), 0.0), 84.0);
col = mix(deepSea + sssTeal, refl, fres * 0.85) + vec3(1.5, 1.15, 0.82) * spec;
}
}
// Pass 2: Composite 18 ballistic spray billboards emitted from high-vorticity PBF wave crest
vec3 mistAccum = vec3(0.0);
float mistTrans = 1.0;
for (int i = 0; i < 18; i++) {
float fi = float(i);
float life = fract(fi * 0.137 + t * 0.36 * P_WAVE_SPEED);
float seed = hash21(vec2(fi, 3.7));
// Ballistic trajectory launched upward from breaking crest along the seawall
vec3 spawn = vec3(0.48 + (seed - 0.5) * 0.35, 0.06, (hash21(vec2(fi, 9.1)) - 0.5) * 1.65);
vec3 vel = vec3(0.42 + 0.28 * seed, 0.95 + 0.45 * hash21(vec2(fi, 5.2)), (seed - 0.5) * 0.35);
vec3 pos = spawn + vel * life - vec3(0.0, 0.65 * life * life, 0.0);
float radius = mix(0.24, 0.58, life);
// Intersect camera-facing billboard plane centered at pos
float denom = dot(rd, fw);
float tBill = dot(pos - ro, fw) / (abs(denom) < 1e-5 ? 1e-5 : denom);
if (tBill > 0.2 && tBill < sceneDepth + (useSoft ? 0.0 : 0.001)) {
vec3 bp = ro + rd * tBill;
vec3 off = bp - pos;
vec2 localUV = vec2(dot(off, ri), dot(off, up)) / radius;
float r2 = dot(localUV, localUV);
if (r2 < 1.0) {
float fbmMask = vnoise(localUV * 2.8 + vec2(fi * 3.1, -life * 2.0)) * 0.65 + vnoise(localUV * 5.8 + fi) * 0.35;
float spriteAlpha;
if (!useSoft) {
// Left baseline: hard-clipped flat billboard quad slicing sharply into seawall & water
float hardDisc = smoothstep(1.0, 0.55, r2) * smoothstep(0.28, 0.62, fbmMask);
spriteAlpha = hardDisc * (1.0 - life) * 0.68 * P_SPRAY_DENS;
} else {
// Right: soft-particle depth feathering against linear sceneDepth + radial Gaussian falloff
float depthDelta = sceneDepth - tBill;
float depthFade = smoothstep(0.0, P_FADE_DEPTH, depthDelta);
float softGauss = exp(-r2 * 2.6) * (0.45 + 0.75 * fbmMask);
spriteAlpha = softGauss * depthFade * sin(life * 3.14159) * 0.62 * P_SPRAY_DENS;
}
spriteAlpha = clamp(spriteAlpha, 0.0, 0.85);
// Sunlit warm backscatter on sea mist vs flat unlit white on baseline
float backLit = pow(max(dot(rd, sunDir), 0.0), 3.0);
vec3 mistCol = useSoft
? mix(vec3(0.68, 0.76, 0.84), vec3(1.45, 1.05, 0.72) * P_SUN_GLOW, 0.45 + 0.55 * backLit)
: vec3(0.82, 0.85, 0.88);
mistAccum += mistTrans * spriteAlpha * mistCol;
mistTrans *= (1.0 - spriteAlpha);
}
}
}
col = col * mistTrans + mistAccum;
col = acesTone(col * 1.05);
if (abs(fragCoord.x - splitX * res.x) < 1.0) col = vec3(0.95, 0.93, 0.89);
fragColor = vec4(pow(clamp(col, 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);
}Why they connect
Position Based Fluids advances core incompressible liquid particles via spatial-grid neighbor density projection and vorticity confinement, outputting particle positions, velocities, neighbor counts, and local vorticity magnitudes. Those particles feed directly into Soft particles (depth-fade billboards): fluid particles exceeding both a velocity-divergence / crest curvature threshold and a low-neighbor free-surface criterion spawn secondary ballistic mist particles that expand, decelerate under aerodynamic drag, and render as camera-facing depth-faded billboards against both solid tank walls and the core fluid depth buffer.
How to build it
Run a compact PBF solver (2-4 Jacobi density iterations + XSPH viscosity + vorticity confinement) and flag surface particles whose neighbor count drops below 50% of rest density while speed exceeds a splash threshold. Spawn mist billboards into a fixed-size ring buffer inheriting the parent particle's velocity plus a small outward normal impulse. Render opaque tank walls and the core fluid body first to populate a linear depth texture, then draw sorted soft-particle spray quads modulated by radial fBM noise, lifetime fade, and smoothstep(0, fadeDepth, sceneLinearDepth - fragLinearDepth) so spray kisses walls and water surfaces without sharp intersection seams.
Field marks
- Violent sloshing can exhaust the fixed mist ring buffer in a few frames, causing abrupt popping as active mist sprites get recycled early.
- Blending unlit white mist billboards over dark refracted liquid looks pasted-on unless billboards sample the scene's directional sun and ambient sky tint.
- Overlapping large expanding mist quads quickly become fill-rate bound when the camera moves inside a splash zone.
- Low-neighbor thresholds accidentally trigger mist emission on thin laminar films sliding down walls unless combined with an upward velocity or vorticity gate.
Prior art
No prior art found on 2026-12-01.
Searches run (2)
- arXiv: all:"position based fluids" AND all:"soft particles"
- GitHub repos: "position based fluids" "soft particles"