Cut 8: Forward+ Vulkan cutover, atmospheric scattering sky, volumetric fog, SSR, 4-split shadows, & linear HDR

This commit is contained in:
Meta Vens 2026-12-05 17:34:33 +01:00
commit 35626ccd02
21 changed files with 1232 additions and 227 deletions

View file

@ -10,7 +10,7 @@ using RustToDust.Ymir;
namespace RustToDust.Client.Tests;
/// <summary>
/// Headless Godot smoke test: instantiates Main, drives 60 frames with throttle + fire + crater stamp,
/// Headless &amp; Vulkan Forward+ Godot smoke test: instantiates Main, drives 60 frames with throttle + fire + crater stamp,
/// verifies terrain tile baking and Ymir physics integration, and exits with code 0 on pass.
/// <c>godot --headless --path client res://tests/Smoke.tscn</c>
/// </summary>
@ -277,6 +277,7 @@ public partial class Smoke : Node
await VerifyMaxLoadPaladinGarageAsync();
await VerifySionMapAsync();
await VerifyOrbitalDropSequenceAsync();
VerifyForwardPlusAtmosphere();
}
private async Task VerifyHudAndShadersAsync(bool isHeadless)
@ -388,7 +389,7 @@ public partial class Smoke : Node
return;
}
// GPU verification on OpenGL 3.3: render isolated InventoryGridControl (ambient vs live bilinear heat) & panel_chrome.gdshader
// GPU verification on Forward+ Vulkan: render isolated InventoryGridControl (ambient vs live bilinear heat) & panel_chrome.gdshader
var gridVp = new SubViewport
{
Size = new Vector2I(240, 240),
@ -2006,6 +2007,84 @@ public partial class Smoke : Node
GD.Print($"SMOKE INFO: Cut 6b OrbitalDrop verified (touchdownTick={touchdownTick}, debris={debrisAtTouchdown}, postDisp={postDisp:F2}m, bucketsDelta={bucketsDuringDrop - bucketsBefore}, matDups={VehicleVisualInstance.PerfMaterialDupCount})");
}
private void VerifyForwardPlusAtmosphere()
{
string method = RenderingServer.GetCurrentRenderingMethod();
Check(method == "forward_plus", $"Expected RenderingMethod 'forward_plus', got '{method}'");
var sionBaked = AtmosphereLutBaker.GetOrBake(ArenaMapKind.Sion);
var desertBaked = AtmosphereLutBaker.GetOrBake(ArenaMapKind.Desert);
CheckFinitePositiveLut("Sion.Transmittance", sionBaked.TransmittanceImage, AtmosphereLutBaker.TransmittanceWidth, AtmosphereLutBaker.TransmittanceHeight);
CheckFinitePositiveLut("Sion.MultiScattering", sionBaked.MultiScatteringImage, AtmosphereLutBaker.MultiScatteringSize, AtmosphereLutBaker.MultiScatteringSize);
CheckFinitePositiveLut("Sion.SkyView", sionBaked.SkyViewImage, AtmosphereLutBaker.SkyViewWidth, AtmosphereLutBaker.SkyViewHeight);
CheckFinitePositiveLut("Desert.Transmittance", desertBaked.TransmittanceImage, AtmosphereLutBaker.TransmittanceWidth, AtmosphereLutBaker.TransmittanceHeight);
CheckFinitePositiveLut("Desert.MultiScattering", desertBaked.MultiScatteringImage, AtmosphereLutBaker.MultiScatteringSize, AtmosphereLutBaker.MultiScatteringSize);
CheckFinitePositiveLut("Desert.SkyView", desertBaked.SkyViewImage, AtmosphereLutBaker.SkyViewWidth, AtmosphereLutBaker.SkyViewHeight);
Check(sionBaked.ZenithTransmittanceMean > desertBaked.ZenithTransmittanceMean,
$"Expected Sion zenith transmittance ({sionBaked.ZenithTransmittanceMean:F4}) > Desert ({desertBaked.ZenithTransmittanceMean:F4})");
var atmo = _main.Atmosphere;
var env = atmo.Environment;
Check(env.TonemapMode == Godot.Environment.ToneMapper.Agx, $"Expected ToneMapper.Agx, got {env.TonemapMode}");
Check(env.GlowEnabled && env.GlowNormalized, $"Expected GlowEnabled && GlowNormalized, got enabled={env.GlowEnabled} norm={env.GlowNormalized}");
Check(env.GlowBlendMode == Godot.Environment.GlowBlendModeEnum.Additive, $"Expected GlowBlendModeEnum.Additive, got {env.GlowBlendMode}");
Check(env.SsrEnabled, "Expected SsrEnabled == true");
Check(env.SsaoEnabled, "Expected SsaoEnabled == true");
Check(env.VolumetricFogEnabled && env.VolumetricFogTemporalReprojectionEnabled,
$"Expected VolumetricFogEnabled && TemporalReprojection, got vf={env.VolumetricFogEnabled} tr={env.VolumetricFogTemporalReprojectionEnabled}");
Check(env.FogEnabled && env.FogAerialPerspective > 0.7f,
$"Expected FogEnabled && FogAerialPerspective > 0.7f, got fog={env.FogEnabled} ap={env.FogAerialPerspective:F2}");
var sun = atmo.Sun;
Check(sun.DirectionalShadowMode == DirectionalLight3D.ShadowMode.Parallel4Splits && sun.DirectionalShadowMaxDistance >= 280f,
$"Expected Parallel4Splits & maxDist >= 280m, got {sun.DirectionalShadowMode} maxDist={sun.DirectionalShadowMaxDistance:F1}");
Check(GetViewport().UseTaa, "Expected GetViewport().UseTaa == true");
int checkedLights = 0;
foreach (Node ch in _main.Arena.Particles.GetChildren())
{
if (ch is OmniLight3D omni)
{
checkedLights++;
Check(omni.LightVolumetricFogEnergy == 0f,
$"Expected {omni.Name}.LightVolumetricFogEnergy == 0f to prevent temporal fog ghosting, got {omni.LightVolumetricFogEnergy}");
}
}
Check(checkedLights == ParticlePool.MaxFlashLights, $"Expected {ParticlePool.MaxFlashLights} ParticlePool OmniLight3D nodes, found {checkedLights}");
Check(atmo.FilmGrainLayer.Layer == 5 && atmo.FilmGrainLayer.Layer < _main.Hud.Layer,
$"Expected FilmGrainLayer.Layer == 5 < Hud.Layer ({_main.Hud.Layer}), got {atmo.FilmGrainLayer.Layer}");
GD.Print($"SMOKE INFO: Cut 8 Forward+ verified (method={method}, sionZenithT={sionBaked.ZenithTransmittanceMean:F4}, desertZenithT={desertBaked.ZenithTransmittanceMean:F4}, grainLayer={atmo.FilmGrainLayer.Layer})");
}
private void CheckFinitePositiveLut(string label, Image img, int expectedW, int expectedH)
{
Check(img.GetFormat() == Image.Format.Rgbah, $"Expected {label} format Rgbah, got {img.GetFormat()}");
Check(img.GetWidth() == expectedW && img.GetHeight() == expectedH,
$"Expected {label} size {expectedW}x{expectedH}, got {img.GetWidth()}x{img.GetHeight()}");
bool allValid = true;
float maxSum = 0f;
int w = img.GetWidth();
int h = img.GetHeight();
for (int y = 0; y < h; y += Math.Max(1, h / 8))
{
for (int x = 0; x < w; x += Math.Max(1, w / 8))
{
Color c = img.GetPixel(x, y);
if (!float.IsFinite(c.R) || !float.IsFinite(c.G) || !float.IsFinite(c.B) ||
c.R < 0f || c.G < 0f || c.B < 0f)
{
allValid = false;
}
maxSum = MathF.Max(maxSum, c.R + c.G + c.B);
}
}
Check(allValid && maxSum > 0f, $"Expected finite positive values in {label} LUT (valid={allValid}, maxSum={maxSum:F4})");
}
private static int CountPremulViolations(Image img, float tolerance)
{
int count = 0;