From 15481375c822878e7d28126e90255ce7399e83fb Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 5 Dec 2026 21:53:08 +0100 Subject: [PATCH] Cut 10b plume fix: PostSky compositor callback + Aetheria gradient-offset SDF --- client/VolumetricCompositorEffect.cs | 6 +-- client/volumetric_raymarch.glsl | 68 ++++++++++++++++------------ 2 files changed, 41 insertions(+), 33 deletions(-) diff --git a/client/VolumetricCompositorEffect.cs b/client/VolumetricCompositorEffect.cs index e587147..409f621 100644 --- a/client/VolumetricCompositorEffect.cs +++ b/client/VolumetricCompositorEffect.cs @@ -5,7 +5,7 @@ using Godot; namespace RustToDust.Client; /// -/// 4-pass Forward+ Vulkan compute pipeline (PostOpaque) owning: +/// 4-pass Forward+ Vulkan compute pipeline (PostSky) owning: /// Pass 0: flow_field_step.glsl (camera-snapped 3m 64x24x64 RGBA16F ping-pong -> ) /// Pass 1: volumetric_tile_cull.glsl (16x16 half-res tiles + 128-element Bitonic sort) /// Pass 2: volumetric_raymarch.glsl (sorted monotonic sweep-line + Aetheria curl/triNoise + shock cavity + 2 shadow taps) @@ -99,7 +99,7 @@ public sealed partial class VolumetricCompositorEffect : CompositorEffect { _flowTexRd = flowTexRd; _emitterPool = emitterPool; - EffectCallbackType = EffectCallbackTypeEnum.PostOpaque; + EffectCallbackType = EffectCallbackTypeEnum.PostSky; AccessResolvedColor = true; AccessResolvedDepth = true; Enabled = true; @@ -124,7 +124,7 @@ public sealed partial class VolumetricCompositorEffect : CompositorEffect public override void _RenderCallback(int effectCallbackType, RenderData renderData) { - if (effectCallbackType != (int)EffectCallbackTypeEnum.PostOpaque || _rdFailed) + if (effectCallbackType != (int)EffectCallbackTypeEnum.PostSky || _rdFailed) { return; } diff --git a/client/volumetric_raymarch.glsl b/client/volumetric_raymarch.glsl index f710207..4828893 100644 --- a/client/volumetric_raymarch.glsl +++ b/client/volumetric_raymarch.glsl @@ -312,9 +312,11 @@ void main() { uint activeMask = 0u; float t = 0.0; int steps = 0; + int iter = 0; const int MaxSteps = 16; + const int MaxIter = 28; - while ((nextIdx < hitCount || activeMask != 0u) && t < tEndMax && T >= 0.015 && steps < MaxSteps) { + while ((nextIdx < hitCount || activeMask != 0u) && t < tEndMax && T >= 0.015 && steps < MaxSteps && iter < MaxIter) { // Empty-space jump directly to nextIdx's t0 whenever no emitter is currently active if (activeMask == 0u) { float minNext = uintBitsToFloat(hitPack[nextIdx] & 0xFFFFFFE0u); @@ -376,7 +378,7 @@ void main() { float tempSum = 0.0; float noiseSum = 0.0; float plasmaSum = 0.0; - vec3 stepCurl = aetheriaFlow(worldPos - flowSample.rgb * 0.20, 3.0, 0.68, elapsed); + vec3 stepCurl = aetheriaFlow(worldPos - flowSample.rgb * 0.20, 11.0, 0.68, elapsed); uint am = activeMask; while (am != 0u) { @@ -414,28 +416,32 @@ void main() { } vec3 advectedPos = worldPos - flowOffset; - float curlScale = 0.48 * radAvg * clamp(0.65 + 0.45 * abs(em.params.z), 0.55, 1.10); + // Gentle Tri3D flow warp (<= 0.24 * radAvg) so flow warps the plume organically without tearing it in half + float curlScale = 0.22 * radAvg * clamp(0.65 + 0.45 * abs(em.params.z), 0.55, 1.10); vec3 evalPos = advectedPos + stepCurl * curlScale; float segT = ab2 > 1e-5 ? clamp(dot(evalPos - A, ab) / ab2, 0.0, 1.0) : 0.0; vec3 closest = A + ab * segT; - float taper = ab2 > 0.15 ? mix(1.02, 0.72, segT) : 1.0; - float rad = mix(rA, rB, segT) * taper * (0.86 + 0.18 * clamp(stepCurl.x + stepCurl.y, -0.8, 0.8)); + float taper = ab2 > 0.15 ? mix(1.02, 0.78, segT) : 1.0; + float rad = mix(rA, rB, segT) * taper; vec3 radialVec = evalPos - closest; float distNorm = length(radialVec) / max(0.15, rad); - if (distNorm < 1.04) { - float softness = clamp(em.tintSoftness.a, 0.18, 0.75); - float baseFall = 1.0 - smoothstep(1.0 - softness, 1.04, distNorm); - if (baseFall > 0.04) { - // Aetheria Volumetric.cginc:201-212 sculpted pocket carving (macro triNoise3d - 0.5 * high-freq triNoise3d) - vec3 nCoord = evalPos / max(1.35, rad * 0.95) + vec3(seed); - float noise1 = triNoise3d(nCoord, elapsed * 0.36); - float noise2 = triNoise3d(nCoord * 5.5, elapsed * 0.56); - float billow = clamp((noise1 - 0.5 * noise2) * 2.55, 0.0, 1.0); - float rawDensity = billow * 0.66 + baseFall * 0.76 - 0.30 * distNorm; - float eroded = smoothstep(0.18, 0.74, rawDensity); - float rho_k = baseFall * eroded * em.params.x * nearFade; + if (distNorm < 1.24) { + // True Aetheria gradient-offset pattern (Volumetric.cginc:210-215): + // triNoise3d ONLY offsets the smooth radial SDF gradient by a small centered displacement << 1.0 + vec3 nCoord = (evalPos / max(1.4, rad * 0.95)) * 0.32 + vec3(seed); + float n1 = triNoise3d(nCoord, elapsed * 0.32); + float n2 = triNoise3d(nCoord * 3.6, elapsed * 0.52); + float dispAmp = 0.35 + 0.65 * clamp(distNorm, 0.0, 1.0); + float disp = ((n1 - 0.45 * n2) - 0.11) * 0.88 * dispAmp; + float warpedDist = clamp(distNorm - disp, 0.0, 1.2); + + if (warpedDist < 1.0) { + float softness = clamp(em.tintSoftness.a, 0.18, 0.75); + float falloffEdge = mix(0.04, 0.14, softness); + float profile = 1.0 - smoothstep(falloffEdge, 1.0, warpedDist); + float rho_k = profile * em.params.x * nearFade; // Shock-front cavity carving + adiabatic compression rim rho_k *= clamp(1.0 - shock * 0.42, 0.32, 1.0) * (1.0 + 0.45 * smoothstep(0.2, 0.9, shock)); @@ -445,11 +451,11 @@ void main() { albedoSum += em.tintSoftness.rgb * rho_k; radialSum += safeNorm(radialVec + vec3(0.0, 0.28 * rad, 0.0)) * rho_k; - // Tight radial temperature falloff: outer 65-75% cools to un-emissive rolling soot - float coreRadial = pow(clamp(1.0 - distNorm, 0.0, 1.0), 1.65); + // Tight radial temperature falloff: outer shell cools to un-emissive rolling soot + float coreRadial = pow(clamp(1.0 - warpedDist, 0.0, 1.0), 1.85); float localTemp = max(em.endRadiusTemp.w * coreRadial, shock * 0.22); tempSum += localTemp * rho_k; - noiseSum += clamp(noise1 * 2.5, 0.0, 1.0) * rho_k; + noiseSum += clamp((n1 - 0.45 * n2) * 2.5 + 0.25, 0.0, 1.0) * rho_k; if (emType == 3u || emType == 4u) { plasmaSum += rho_k; } @@ -465,25 +471,26 @@ void main() { vec3 albedo = albedoSum / rhoSum; vec3 localUpOrRadial = safeNorm(radialSum); - // Layer 1 & 2: Aetheria inverse-density charcoal soot contour (CloudShader.shader:96-97) - // Thin wispy outer rims stay bright sunlit vapor (~0.85-1.0); dense mid-body folds plunge into velvety charcoal soot (~0.10-0.22) - float sootContour = 1.0 / (1.0 + 3.2 * rawDens); + // Layer 1 & 2: Aetheria inverse-density charcoal soot contour (CloudShader.shader:96-97 / Volumetric.cginc:234) + // Thin wispy outer rims stay bright sunlit vapor; dense interior billows plunge into velvety charcoal soot + float sootContour = 1.0 / (1.0 + 4.4 * rawDens); float rimBias = 0.65 + 0.45 * clamp(dot(localUpOrRadial, sunDir), -1.0, 1.0); vec3 vaporAlbedo = mix(albedo, max(albedo, vec3(0.24, 0.23, 0.22)), 0.35 * sootContour); - float vaporEdgeFade = smoothstep(0.0, 0.10, rawDens); - vec3 scatterLum = vaporAlbedo * (sootContour * vaporEdgeFade) * (sunRad * (rimBias + phase * 2.4) + ambRad * 0.48); + float vaporEdgeFade = smoothstep(0.0, 0.08, rawDens); + vec3 scatterLum = vaporAlbedo * (sootContour * vaporEdgeFade * 1.65) * (sunRad * (rimBias + phase * 2.4) + ambRad * 0.48); - // Layer 3: Sharp turbulent core-only combustion (ignites only in hottest dense inner core pockets) + // Layer 3: Sharp turbulent core-only combustion peeking through dark soot crevices vec3 plasmaEmit = vec3(0.0); - float coreGate = smoothstep(0.68, 0.96, coreTemp * (0.72 + 0.55 * stepNoise)); + float coreSignal = coreTemp * (0.85 + 0.30 * stepNoise); + float coreGate = smoothstep(0.60, 0.92, coreSignal); if (coreGate > 0.001) { - float coreGlow = pow(clamp(rawDens, 0.0, 1.5), 2.3) * coreGate; + float coreGlow = pow(clamp(rawDens, 0.0, 1.5), 2.1) * coreGate; vec3 bb = blackbodyRamp(coreTemp); float plasmaMix = plasmaSum / rhoSum; if (plasmaMix > 0.01) { bb = mix(bb, albedo * (1.55 + 2.05 * coreTemp), 0.75 * plasmaMix); } - plasmaEmit = bb * (coreGlow * 7.2) * emitNearFade; + plasmaEmit = bb * (coreGlow * 6.4) * emitNearFade; } float sigmaT = rawDens * extScale; @@ -493,6 +500,7 @@ void main() { vec3 stepLight = (scatterLum + plasmaEmit) * integDivExt * nearFade; L += T * stepLight; T *= stepTrans; + steps++; if (T < 0.015) { T = 0.0; break; @@ -502,7 +510,7 @@ void main() { } t += ds; - steps++; + iter++; } imageStore(u_halfVol, px, vec4(min(L, vec3(24.0)), clamp(T, 0.0, 1.0)));