Stable Fluids × Nubis-style Ray-marched Volumetric Clouds
Storms that form and drift. Cloudscapes where storm cells form, merge, shear and dissipate with a wind field, because coverage and cloud type are advected by a small 2D fluid simulation rather than scrolled as a static weather map.
Open in StudioReproduced1417× · 43.9 ms
Verified proof

Split-screen WebGL2 proof comparing rigidly scrolled static weather maps feeding a Nubis volumetric cloud march (left) against a divergence-free 2D curl-vortex fluid velocity field semi-Lagrangian advecting storm coverage, cloud type, and height-sheared 3D erosion detail (right).
Chromium Headless ANGLE/SwiftShader WebGL2 · 512x512 · produces swirling, shearing cumulonimbus storm fronts with height-dependent anvil lean and Beer-Powder silver linings instead of rigidly scrolled cloud slabs
Show GLSL proof (200 lines)
const float P_FLUID_CURL = 1.15; // P Vortex Advection [0.0, 2.5, 0.05]
const float P_WIND_SHEAR = 0.85; // P Altitude Shear [0.0, 2.0, 0.05]
const float P_CLOUD_COVER = 0.56; // P Storm Coverage [0.25, 0.85, 0.02]
const float P_SILVER_LINING = 1.20; // P HG Phase Scatter [0.3, 2.5, 0.05]
float hash31(vec3 p) {
p = fract(p * 0.1031);
p += dot(p, p.yzx + 33.33);
return fract((p.x + p.y) * p.z);
}
float vnoise3(vec3 p) {
vec3 i = floor(p);
vec3 f = fract(p);
vec3 u = f * f * (3.0 - 2.0 * f);
float n000 = hash31(i + vec3(0.0, 0.0, 0.0));
float n100 = hash31(i + vec3(1.0, 0.0, 0.0));
float n010 = hash31(i + vec3(0.0, 1.0, 0.0));
float n110 = hash31(i + vec3(1.0, 1.0, 0.0));
float n001 = hash31(i + vec3(0.0, 0.0, 1.0));
float n101 = hash31(i + vec3(1.0, 0.0, 1.0));
float n011 = hash31(i + vec3(0.0, 1.0, 1.0));
float n111 = hash31(i + vec3(1.0, 1.0, 1.0));
float nx00 = mix(n000, n100, u.x);
float nx10 = mix(n010, n110, u.x);
float nx01 = mix(n001, n101, u.x);
float nx11 = mix(n011, n111, u.x);
return mix(mix(nx00, nx10, u.y), mix(nx01, nx11, u.y), u.z);
}
float fbm3(vec3 p) {
float s = 0.0;
float a = 0.52;
for (int i = 0; i < 4; i++) {
s += a * vnoise3(p);
p = p * 2.05 + vec3(13.1, 7.7, 5.3);
a *= 0.48;
}
return s;
}
// Incompressible 2D fluid streamfunction psi(x,z) -> curl velocity v = (dpsi/dz, -dpsi/dx) (div v == 0)
float streamFunc(vec2 xz, float t) {
vec2 v1 = vec2(-1.4 + 0.4 * sin(t * 0.25), -5.2 + 0.5 * cos(t * 0.22));
vec2 v2 = vec2( 1.6 + 0.3 * cos(t * 0.28), -6.8 + 0.4 * sin(t * 0.20));
float g1 = 1.65 * exp(-dot(xz - v1, xz - v1) * 0.14);
float g2 = -1.45 * exp(-dot(xz - v2, xz - v2) * 0.16);
float jet = 0.42 * sin(xz.y * 0.45 + 0.35 * sin(xz.x * 0.4 + t * 0.3));
return (g1 + g2 + jet) * P_FLUID_CURL;
}
vec2 fluidVelocity(vec2 xz, float t) {
float e = 0.08;
float dpdx = (streamFunc(xz + vec2(e, 0.0), t) - streamFunc(xz - vec2(e, 0.0), t)) / (2.0 * e);
float dpdz = (streamFunc(xz + vec2(0.0, e), t) - streamFunc(xz - vec2(0.0, e), t)) / (2.0 * e);
return vec2(dpdz, -dpdx) + vec2(0.32, 0.10);
}
// Weather map returning vec3(coverage, cloudType, moisture) from either static scroll or 2D fluid advection
vec3 evalWeather(vec2 xz, float t, bool useFluid, out vec2 vel) {
if (!useFluid) {
vel = vec2(0.28, 0.0);
vec2 q = xz * 0.24 - vel * t;
float cov = fbm3(vec3(q, 1.4));
float ctype = smoothstep(0.35, 0.72, fbm3(vec3(q * 0.75 + 4.1, 2.3)));
return vec3(cov, ctype, 0.5);
} else {
// Two-stage midpoint semi-Lagrangian backtrace through incompressible 2D fluid velocity field
vel = fluidVelocity(xz, t);
float dt = 0.55 + 0.35 * sin(t * 0.22);
vec2 midPos = xz - vel * (0.5 * dt);
vec2 midVel = fluidVelocity(midPos, t);
vec2 srcPos = xz - midVel * dt;
// Vorticity convergence pumps moisture into billowing cumulonimbus storm towers
float vort = length(vel - midVel) * 2.4;
float cov = fbm3(vec3(srcPos * 0.24, 1.4 + t * 0.05)) + vort * 0.22;
float ctype = clamp(smoothstep(0.28, 0.70, fbm3(vec3(srcPos * 0.22 + 4.1, 2.3))) + vort * 0.48, 0.0, 1.0);
float moist = clamp(0.45 + vort * 0.65, 0.0, 1.0);
return vec3(cov, ctype, moist);
}
}
// Nubis height-gradient shaping (stratus -> cumulus -> towering anvil cumulonimbus)
float heightProfile(float h, float ctype) {
float bot = smoothstep(0.0, 0.14, h);
float topH = mix(0.42, 0.96, ctype);
float top = 1.0 - smoothstep(topH * 0.62, topH, h);
// Anvil spread near storm top for high cloudType
float anvil = smoothstep(0.68, 0.88, h) * (1.0 - smoothstep(0.88, 1.0, h)) * ctype * 0.35;
return clamp(bot * top + anvil, 0.0, 1.0);
}
float sampleCloudDensity(vec3 p, float t, bool useFluid) {
float h = clamp((p.y - 1.15) / 2.25, 0.0, 1.0);
if (h <= 0.001 || h >= 0.999) return 0.0;
vec2 vel;
vec3 w = evalWeather(p.xz, t, useFluid, vel);
float shape = heightProfile(h, w.y);
float covThresh = 1.0 - P_CLOUD_COVER;
float base = smoothstep(covThresh - 0.14, covThresh + 0.34, w.x) * shape;
if (base < 0.005) return 0.0;
// Height-dependent wind shear driven by fluid velocity offsets 3D erosion detail
vec2 shear = useFluid ? (vel * h * P_WIND_SHEAR * 1.15) : vec2(0.0);
vec3 q = vec3((p.xz - shear) * 0.58, p.y * 0.78) - vec3(t * 0.14, 0.0, 0.0);
float billow = fbm3(q);
float erode = fbm3(q * 2.35 + vec3(5.2, 2.1, 8.4));
float dens = base - (1.0 - billow) * 0.36 - (1.0 - erode) * 0.16;
return clamp(dens * 2.15, 0.0, 1.0);
}
float hgPhase(float cosTheta, float g) {
float g2 = g * g;
return (1.0 - g2) / (4.0 * 3.1415926 * pow(max(1.0 + g2 - 2.0 * g * cosTheta, 0.02), 1.5));
}
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 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
bool useFluid = uv.x > 0.0;
vec2 suv = vec2(useFluid ? (uv.x - 0.25) : (uv.x + 0.25), uv.y);
vec3 ro = vec3(0.0, 0.65, 0.0);
vec3 rd = normalize(vec3(suv.x * 1.15, suv.y + 0.22, -1.25));
vec3 sunDir = normalize(vec3(0.45, 0.32, -0.84));
float cosSun = dot(rd, sunDir);
// Sky backdrop with atmospheric scattering
vec3 zenith = vec3(0.08, 0.22, 0.52);
vec3 horiz = vec3(0.76, 0.66, 0.56);
vec3 sky = mix(horiz, zenith, pow(max(rd.y, 0.0), 0.52));
sky += vec3(1.3, 0.72, 0.32) * pow(max(cosSun, 0.0), 10.0) * 0.55;
sky += vec3(1.8, 1.35, 0.85) * smoothstep(0.996, 0.999, cosSun) * 3.2;
vec3 col = sky;
if (rd.y > 0.02) {
float tMin = (1.15 - ro.y) / rd.y;
float tMax = min((3.40 - ro.y) / rd.y, 18.0);
if (tMax > tMin && tMin > 0.0) {
const int STEPS = 28;
float dt = (tMax - tMin) / float(STEPS);
// Interleaved gradient noise jitter to suppress stepping bands
float jit = fract(52.9829189 * fract(dot(fragCoord.xy, vec2(0.06711056, 0.00583715))));
float t = tMin + jit * dt;
vec3 lightAcc = vec3(0.0);
float trans = 1.0;
float phase = mix(hgPhase(cosSun, -0.25), hgPhase(cosSun, 0.68), 0.62) * P_SILVER_LINING * 4.5 + 0.35;
vec3 sunCol = vec3(1.35, 0.96, 0.66);
vec3 ambTop = vec3(0.32, 0.48, 0.78);
vec3 ambBot = vec3(0.14, 0.16, 0.24);
for (int i = 0; i < STEPS; i++) {
vec3 pos = ro + rd * t;
float d = sampleCloudDensity(pos, iTime, useFluid);
if (d > 0.004) {
// 4-step sun shadow march inside Nubis cloud layer
float sunOpt = 0.0;
for (int s = 1; s <= 4; s++) {
float st = float(s) * 0.32;
sunOpt += sampleCloudDensity(pos + sunDir * st, iTime, useFluid) * 0.32;
}
float beer = exp(-sunOpt * 1.65);
float powder = 1.0 - exp(-d * 4.5);
float multScat = mix(beer, exp(-sunOpt * 0.45) * 0.65, 0.38);
float hFrac = clamp((pos.y - 1.15) / 2.25, 0.0, 1.0);
vec3 amb = mix(ambBot, ambTop, hFrac) * (0.55 + 0.45 * beer);
vec3 scat = sunCol * multScat * (0.45 + 0.55 * powder) * phase + amb;
float stepT = exp(-d * dt * 1.45);
lightAcc += trans * scat * (1.0 - stepT);
trans *= stepT;
if (trans < 0.02) break;
}
t += dt;
}
// Aerial perspective blend into horizon haze
float distFade = exp(-tMin * 0.045);
col = mix(sky, lightAcc + trans * sky, distFade);
}
} else {
// Distant dark sea below horizon
vec3 sea = mix(vec3(0.05, 0.09, 0.16), horiz * 0.55, exp(rd.y * 8.0));
col = sea;
}
// Bottom strip: live 2D weather coverage + fluid curl field preview
if (uv.y < -0.405) {
vec2 wxz = vec2(suv.x * 10.0, -5.5 + (uv.y + 0.455) * 32.0);
vec2 vel;
vec3 w = evalWeather(wxz, iTime, useFluid, vel);
vec3 wCol = mix(vec3(0.05, 0.09, 0.18), vec3(0.88, 0.92, 0.96), smoothstep(0.32, 0.72, w.x));
if (useFluid) wCol = mix(wCol, vec3(1.0, 0.52, 0.18), clamp(length(vel) * 0.25 * w.y, 0.0, 0.75));
col = wCol;
}
col = acesTone(col * 1.08);
if (abs(uv.y + 0.405) < 0.0025) col = vec3(0.88, 0.86, 0.82);
if (abs(uv.x) < 0.003) col = vec3(0.96, 0.94, 0.88);
fragColor = vec4(pow(clamp(col, 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);
}Why they connect
Stable Fluids runs on a 2D grid over the weather domain and outputs volume-density channels, here coverage, cloud type and moisture, advected by an incompressible velocity field. Nubis-style Ray-marched Volumetric Clouds expects a weather texture, so the hop is composite: the simulation's density grid is written into that texture each step. The simulation velocity is passed along as well, to offset the detail-noise lookup and to give temporal reprojection better motion, and the clouds then output radiance and volume-density as usual.
How to build it
Unreal, with the volumetric cloud material reading a render target, or a WebGPU cloud renderer. Run stable fluids at a few hundred cells per side over the visible weather area, with sources painted by hand or driven by humidity and temperature maps. Advect coverage and type with a less diffusive scheme such as MacCormack or BFECC so edges survive. Write the result into the weather texture. Integrate an offset field from the simulation velocity and apply it to the 3D noise lookup, with shear that grows with height. Recentre the domain as the camera travels.
Field marks
- Numerical diffusion smears cloud edges and kills small cells.
- Evolving clouds make temporal reprojection ghost more.
- Recentering the domain causes popping without blending.
- Realism is limited: there is no thermodynamics or condensation.
Prior art
No prior art found on 2026-11-29.
Searches run (4)
- arXiv: all:"volumetric clouds" AND all:"fluid simulation" → 0 results
- GitHub repos: "volumetric clouds" "fluid simulation" → 0 results
- arXiv: all:"cloud rendering" AND all:"weather map" AND all:"simulation" → 0 results
- GitHub repos: "cloud rendering" "weather map" simulation → 0 results