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;

View file

@ -3,11 +3,12 @@ using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Godot;
using RustToDust.Core;
namespace RustToDust.Client.Tests;
/// <summary>
/// Live OpenGL 3.3 (gl_compatibility) visual verification probe for:
/// Live Forward+ (Vulkan) visual verification probe for:
/// - Baked COLOR_0 vertex weathering (AO, edge curvature, per-island hash, rest height)
/// - Brokkr 6-layer MechPaint spatial shader (mech_paint.gdshader) + INSTANCE_CUSTOM scorch/heat
/// - 4x4 POM MultiMesh decal atlas + decal_pom.gdshader in 1 draw call
@ -207,7 +208,7 @@ public partial class VisualProbe : Node3D
cam.GlobalPosition = new Vector3(2.8f, 4.3f, 13.4f);
cam.LookAt(new Vector3(0.0f, 4.4f, 0.2f), Vector3.Up);
// Wait several rendered frames so OpenGL 3.3 compiles all shaders and finishes drawing
// Wait several rendered frames so Vulkan Forward+ compiles all shaders and finishes drawing
for (int f = 0; f < 6; f++)
{
await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame);
@ -249,43 +250,11 @@ public partial class VisualProbe : Node3D
private void SetupEnvironment()
{
var sun = new DirectionalLight3D
{
Name = "DesertSun",
LightColor = new Color(1.0f, 0.93f, 0.82f),
LightEnergy = 1.85f,
ShadowEnabled = true,
DirectionalShadowMode = DirectionalLight3D.ShadowMode.Parallel2Splits,
RotationDegrees = new Vector3(-38f, 36f, 0f)
};
AddChild(sun);
// Cool oblique fill light so POM recesses & metal rims catch clear specular highlights
var fill = new DirectionalLight3D
{
Name = "SkyFill",
LightColor = new Color(0.68f, 0.80f, 0.98f),
LightEnergy = 0.55f,
ShadowEnabled = false,
RotationDegrees = new Vector3(-25f, -125f, 0f)
};
AddChild(fill);
var skyMat = new ProceduralSkyMaterial
{
SkyTopColor = new Color(0.24f, 0.34f, 0.44f),
SkyHorizonColor = new Color(0.76f, 0.56f, 0.37f),
GroundBottomColor = new Color(0.28f, 0.20f, 0.14f),
GroundHorizonColor = new Color(0.68f, 0.48f, 0.32f)
};
var env = new Godot.Environment
{
BackgroundMode = Godot.Environment.BGMode.Sky,
Sky = new Sky { SkyMaterial = skyMat },
AmbientLightSource = Godot.Environment.AmbientSource.Sky,
AmbientLightEnergy = 0.65f
};
AddChild(new WorldEnvironment { Name = "WorldEnv", Environment = env });
GetViewport().UseTaa = true;
var atmosphere = new AtmosphereSystem { Name = "AtmosphereSystem" };
AddChild(atmosphere);
atmosphere.ApplyMap(ArenaMapKind.Desert);
atmosphere.Sun.RotationDegrees = new Vector3(-38f, 36f, 0f);
}
private void VerifyBakedVertexColors(string name, ArrayMesh mesh)