Client Terrain: fix HeightViewport alpha blending, 1-texel border gutters, road rut axis, and GPU readback smoke

This commit is contained in:
Meta Vens 2026-12-04 14:16:05 +01:00
commit bb68620d1c
6 changed files with 112 additions and 39 deletions

View file

@ -91,11 +91,35 @@ public partial class Smoke : Node
Check(!float.IsNaN(player.X) && !float.IsNaN(player.Y) && !float.IsNaN(player.Z), "Player position became NaN");
int rebakesBefore = _main.Terrain.DirtyRebakes;
float cpuBefore = _main.Session.State.Terrain.SampleHeight(-48f, -48f);
bool hasGpuBefore = _main.Terrain.TrySampleBakedHeight(-48f, -48f, out float gpuBefore);
if (hasGpuBefore)
{
Check(MathF.Abs(gpuBefore - cpuBefore) <= 0.25f,
$"Expected baked GPU height ({gpuBefore:F2}m) to match CPU height ({cpuBefore:F2}m) before crater");
}
_main.Session.State.Terrain.StampCrater(-48f, -48f, radius: 5f, depth: 1.4f);
await ToSignal(GetTree(), SceneTree.SignalName.PhysicsFrame);
await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame);
float cpuAfter = _main.Session.State.Terrain.SampleHeight(-48f, -48f);
Check(cpuAfter < cpuBefore - 0.8f,
$"Expected CPU terrain height to drop after crater stamp (before {cpuBefore:F2}m, after {cpuAfter:F2}m)");
Check(_main.Terrain.DirtyRebakes == rebakesBefore + 1,
$"Expected 1 dirty tile rebake from isolated crater stamp, got {_main.Terrain.DirtyRebakes - rebakesBefore}");
if (_main.Terrain.TrySampleBakedHeight(-48f, -48f, out float gpuAfter))
{
Check(MathF.Abs(gpuAfter - cpuAfter) <= 0.25f,
$"Expected baked GPU height ({gpuAfter:F2}m) to match CPU height ({cpuAfter:F2}m) after crater");
if (hasGpuBefore)
{
Check(gpuAfter < gpuBefore - 0.8f,
$"Expected baked GPU height to drop after crater (before {gpuBefore:F2}m, after {gpuAfter:F2}m)");
}
}
_main.SetScriptedInput(null);
}