From 1b7dea0d06b573e9439db35cb26ac73fb4b35fcb Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Fri, 20 Nov 2026 06:16:29 +0100 Subject: [PATCH] RenderCheck: the chamber's light is bounded from below too; it must lift the puppet over the same frame with the light off, so a glow of 0 fails Co-Authored-By: Claude Sonnet 5.5 --- README.md | 2 +- client/tests/RenderCheck.cs | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index cf8ff52..e56dc7c 100644 --- a/README.md +++ b/README.md @@ -84,7 +84,7 @@ Exports need export templates (not installed here yet), so the client runs from The smoke has no renderer. `RenderCheck.tscn` is the check that does: it poses the puppet in a bent pose under a moved parent, renders one frame (gl_compatibility, the client's renderer), and compares the drawn silhouette with the mesh skinned on the CPU (intersection over union, at -least 0.999: a correct render measures 1.0000, and a forearm bone 10 degrees off, a bone 2 cm off and hard weights fail), and checks the lit puppet is not clipped to white. Add `-- --png=` to keep the frame. It needs a display. +least 0.999: a correct render measures 1.0000, and a forearm bone 10 degrees off, a bone 2 cm off and hard weights fail), and checks the lit puppet is not clipped to white and that the chamber's light still lights it (a glow of 0 fails). Add `-- --png=` to keep the frame. It needs a display. Known gaps: the silhouette does not see the shading normal (a puppet whose NORMAL is left unskinned passes) or the culling box (a 1 cm `CustomAabb` passes). diff --git a/client/tests/RenderCheck.cs b/client/tests/RenderCheck.cs index 944622f..5da8dc2 100644 --- a/client/tests/RenderCheck.cs +++ b/client/tests/RenderCheck.cs @@ -11,7 +11,7 @@ namespace BadDay.Client.Tests; /// It poses the carriers in a bent pose (every joint turned at random) under a moved and turned BodyRenderer, renders one frame of the /// puppet alone on black, and compares the rendered silhouette with the silhouette of the same mesh skinned on the CPU from the /// carriers and the spread bind (not from anything Puppet computed) and projected through the camera. Intersection over union must be -/// at least . It also looks at the light, with the chamber near full glow: the puppet's faces must not clip to white and must differ from each other. +/// at least . It also looks at the light, with the chamber near full glow: the puppet's faces must not clip to white and must differ from each other, and the chamber's light must lift the puppet over the same frame with that light off (so the glow is bounded from below as well). /// godot --path client res://tests/RenderCheck.tscn [-- --png=path]; exit code 0 passes, 1 fails. It needs a window, so it is /// not part of the headless smoke. /// @@ -32,6 +32,9 @@ public partial class RenderCheck : Node /// The puppet's facets must differ: its 10th to 90th percentile brightness spans at least this many of 255 levels. private const float MinSpread = 30f; + /// The chamber's glow must light the puppet: with the light on, the mean level of the puppet's pixels must exceed the same frame with the light off by at least this many of 255 levels (the shipped light lifts it 9.8). A glow of 0 fails. + private const float MinGlowLift = 5f; + private const int BendSeed = 7; private const float BendDegrees = 60f; @@ -115,27 +118,44 @@ public partial class RenderCheck : Node } int both = 0, either = 0, clipped = 0; + var puppetPixels = new System.Collections.Generic.List(); var levels = new System.Collections.Generic.List(); for (int i = 0; i < covered.Length; i++) { if (covered[i] || drawn[i]) either++; if (!covered[i] || !drawn[i]) continue; both++; + puppetPixels.Add(i); var px = image.GetPixel(i % w, i / w); float level = Mathf.Max(px.R, Mathf.Max(px.G, px.B)) * 255f; levels.Add(level); if (level >= 250f) clipped++; } + float meanOn = levels.Count == 0 ? 0 : levels.Average(); levels.Sort(); float lit = levels.Count; float spread = lit == 0 ? 0 : levels[(int)(lit * 0.9f)] - levels[(int)(lit * 0.1f)]; float iou = either == 0 ? 0 : (float)both / either; float share = lit == 0 ? 1 : clipped / lit; + + // The control: the same frame with the chamber's light off, over the same pixels. + var glowLight = main.Chamber.GetChildren().OfType().Single(); + float energy = glowLight.LightEnergy; + glowLight.LightEnergy = 0f; + for (int i = 0; i < 4; i++) await ToSignal(RenderingServer.Singleton, RenderingServer.SignalName.FramePostDraw); + var dark = GetViewport().GetTexture().GetImage(); + dark.Convert(Image.Format.Rgba8); + glowLight.LightEnergy = energy; + float meanOff = puppetPixels.Count == 0 ? 0 : puppetPixels.Average(i => { var px = dark.GetPixel(i % w, i / w); return Mathf.Max(px.R, Mathf.Max(px.G, px.B)) * 255f; }); + float lift = meanOn - meanOff; + + GD.Print($"RENDER glow lift {lift:F2} levels (mean {meanOn:F1} lit, {meanOff:F1} with the chamber light off)"); GD.Print($"RENDER iou {iou:F4} (covered {covered.Count(x => x)}, drawn {drawn.Count(x => x)}), clipped {share:P1} of {lit} puppet pixels, 10th to 90th percentile level spread {spread:F0} of 255"); bool ok = true; if (iou < MinIou) { GD.PrintErr($"RENDER FAIL: the drawn silhouette matches the CPU-skinned mesh with IoU {iou:F3}, under {MinIou}"); ok = false; } if (share > MaxClipped) { GD.PrintErr($"RENDER FAIL: {share:P1} of the puppet's pixels are clipped to white, over {MaxClipped:P0}; the facets cannot read"); ok = false; } if (spread < MinSpread) { GD.PrintErr($"RENDER FAIL: the puppet's pixels span only {spread:F0} levels between the 10th and 90th percentile, under {MinSpread}; the facets do not differ"); ok = false; } + if (lift < MinGlowLift) { GD.PrintErr($"RENDER FAIL: the chamber's light lifts the puppet by {lift:F2} levels, under {MinGlowLift}; the box's glow does not light the body"); ok = false; } return ok; }