Official Codebase of 3DCodeVerse
Python
scene_frames: a night scene is not a broken render
gaoypenged59f4ee5354
diff --git a/harness/codeverse/skills/_claims/cv3d-scene-lighting.toml b/harness/codeverse/skills/_claims/cv3d-scene-lighting.tomlindex e38bbec5..b82bf6f5 100644--- a/harness/codeverse/skills/_claims/cv3d-scene-lighting.toml+++ b/harness/codeverse/skills/_claims/cv3d-scene-lighting.toml@@ -34,3 +34,12 @@ text = "92 %"python = "codeverse.spatial.frame_metrics:FLAT_MODAL_ERROR"scale = 100format = "{:.0f} %"++# The contrast floor that separates "dim but lit" (WARN) from "unlit or broken" (ERROR).+# The skill tells authors to aim at this instead of the 0.15 mean in a practical-lit+# night scene, so it must not drift from the gate.+[[claim]]+key = "scene_lowkey_min_std"+text = "0.12"+python = "codeverse.spatial.frame_metrics:LOWKEY_MIN_STD"+format = "{:.2f}"diff --git a/harness/codeverse/skills/cv3d-scene-lighting/SKILL.md b/harness/codeverse/skills/cv3d-scene-lighting/SKILL.mdindex 8cef2268..e2083bdd 100644--- a/harness/codeverse/skills/cv3d-scene-lighting/SKILL.md+++ b/harness/codeverse/skills/cv3d-scene-lighting/SKILL.md@@ -58,9 +58,20 @@ linear 0.02 to 0.05 moves the frame from 0.08 to 0.20. Small increases pay near## The recipe-* **Tint, do not dim.** Dusk and night are coloured darkness. Turning the key down is not- how you make dusk; changing its hue and the hemisphere's is. Take the whole row from the- cookbook's time-of-day table rather than inventing a triad.+* **Tint, do not dim** — for DUSK, and for a night lit from the sky. Dusk is coloured+ darkness, so change the key's hue and the hemisphere's rather than turning the key down.+ Take the whole row from the cookbook's time-of-day table rather than inventing a triad.+* **But a PRACTICAL-lit night really is dim, and fill will ruin it.** When the brief says+ the light comes from lanterns, lamps, fire, neon or windows, the picture is supposed to+ be dark between them: that contrast IS the subject. Adding AmbientLight or a+ HemisphereLight to lift the average is the single most destructive thing you can do to+ such a scene — measured 2026-08-25 on a lantern-lit temple courtyard, the added fill+ washed dark granite paving to near-white, flattened the whole frame to "snow at dawn",+ and drowned a KoiWater ShaderMaterial that was running correctly the entire time. Light+ it from its own practicals instead: emissive on the lamp, a PointLight at each one, a+ low but non-zero base colour on dark materials so they read as material and not as void,+ and shadows left dark. The gate now tells these two cases apart — a dim frame WITH+ contrast (`lum_std` >= 0.12) is reported as "dim but lit" and is only a WARN.* **The sun is white at noon and warm only near the horizon.** A warm sun at high elevationreads as an error, not as mood.* **The fill is the opposite hue from the key.** Hemisphere light is sky colour above,@@ -72,11 +83,18 @@ linear 0.02 to 0.05 moves the frame from 0.08 to 0.20. Small increases pay near* **Fog colour is the sky's horizon colour**, never white or grey unless the brief saysovercast, and never a black background.-Working numbers, straight from the gate's own fix hint: DirectionalLight **2-4**,-HemisphereLight **0.5-1.0**, `emissiveIntensity` **2-6** with a PointLight **0.5-2** per-practical, and keep mean luminance **>= 0.15** so you are not sitting on the threshold. If-the frame is blown instead: key <= 3, hemisphere <= 1.0, sky below 0.9 white,-`emissiveIntensity` <= 4 on large surfaces.+Working numbers for a scene lit from the SKY (day, overcast, dusk), straight from the+gate's fix hint: DirectionalLight **2-4**, HemisphereLight **0.5-1.0**,+`emissiveIntensity` **2-6** with a PointLight **0.5-2** per practical, and keep mean+luminance **>= 0.15** so you are not sitting on the threshold. If the frame is blown+instead: key <= 3, hemisphere <= 1.0, sky below 0.9 white, `emissiveIntensity` <= 4 on+large surfaces.++Do **not** carry that ">= 0.15" over to a scene lit from its PRACTICALS. There the target+is contrast, not average: `lum_std` **>= 0.12** with the lit areas reading clearly, mean+luminance wherever it lands (0.06-0.15 is normal and fine), one dim moon/sky key at+**<= 0.2** if you want shape in the shadows, and no AmbientLight or HemisphereLight at+all. Chasing the 0.15 average in a night scene is exactly how you get a grey wash.For a flat frame, add contrast rather than light: a shadow-casting key, materials withgenuinely different albedos, and a camera aimed at content rather than at sky.diff --git a/harness/codeverse/spatial/frame_metrics.py b/harness/codeverse/spatial/frame_metrics.pyindex 57b493e1..faa48cd9 100644--- a/harness/codeverse/spatial/frame_metrics.py+++ b/harness/codeverse/spatial/frame_metrics.py@@ -29,6 +29,13 @@ FRAME_GATE = "scene_frames"# thresholds (fractions of the frame / of full white)DARK_MEAN_LUM = 0.12+#: a frame this dark in the MEAN is still correctly exposed when it has real contrast --+#: a lantern-lit night is dim on average and bright where the lanterns are. Measured+#: 2026-08-25 on tsr_scn_temple_night r01: the three authored cameras sat at lum_std+#: 0.171 / 0.199 / 0.249 while the flat overview rig sat at 0.058, so lum_std separates+#: "low-key by design" from "unlit or broken" cleanly. ``lum_std`` has been in the+#: camera_checks payload from host_metrics.mjs all along; this gate never read it.+LOWKEY_MIN_STD = 0.12DARK_FRAC = 0.35BLOWN_FRAC = 0.20FLAT_MODAL_FRAC = 0.85@@ -40,12 +47,27 @@ CONTENT_MIN_OVERVIEW = 0.05EYE_MIN_ABOVE_GROUND_M = 0.3EYE_MAX_ABOVE_GROUND_M = 80.0+#: for a frame that is dark AND flat -- nothing is lit, so adding light is right_DARK_HINT = ("raise the key + fill: DirectionalLight intensity 2–4, HemisphereLight 0.5–1.0 (sky colour / ground colour), ""add emissive lights where the brief has them (lantern glow: MeshStandardMaterial emissive + emissiveIntensity 2–6, ""a PointLight 0.5–2 per lantern); scene.fog colour must match the sky colour; dusk/night is orange/purple/deep blue, ""NOT black — keep mean luminance ≥ 0.15 (check with scene_views: camera_checks.mean_lum)")+#: for a frame that is dark but CONTRASTY -- something IS lit, so adding fill is the+#: wrong move and actively destroys the picture. Measured 2026-08-25: temple_night was+#: told by _DARK_HINT to add a HemisphereLight, did so, and the resulting flat fill+#: washed the granite paving to near-white, flattened the scene to "snow at dawn" and+#: drowned a working KoiWater ShaderMaterial -- the effect was running the whole time.+#: The judge then scored the washed-out version 0.7287 and passed it.+_LOWKEY_HINT = (+ "this frame is DIM BUT LIT — it has real contrast, so do NOT add AmbientLight or HemisphereLight and do NOT "+ "raise a DirectionalLight to fix it: flat fill is what turns a night scene into a grey wash, washes dark "+ "materials out to near-white and drowns emissive/shader effects. Instead lift the picture where the light "+ "actually comes from: raise emissiveIntensity on the lamps/lanterns themselves, add or brighten a PointLight "+ "at each practical light, give dark materials a low but non-zero base colour so they read as material and not "+ "as void, and let the shadowed areas stay dark. Only if the frame is ALSO flat (no contrast) does it need key/fill."+)_BLOWN_HINT = ("lower exposure: DirectionalLight ≤ 3, HemisphereLight ≤ 1.0, no MeshBasicMaterial white planes; ""sky colour below 0.9 white; emissiveIntensity ≤ 4 on large surfaces"@@ -89,10 +111,19 @@ def _exposure_findings(chk: dict[str, Any], *, authored: bool) -> list[GateFindi# scene being unlit (measured: it cost the rooftop battery a 0.60 cap three rounds running)rig = "" if authored else "harness rig view (not an authored camera): "mean, dark, blown, modal = (_num(chk, k) for k in ("mean_lum", "dark_frac", "blown_frac", "modal_frac"))+ std = _num(chk, "lum_std")is_dark = (mean is not None and mean < DARK_MEAN_LUM) or (dark is not None and dark > DARK_FRAC)+ # dim BUT lit: real contrast and not mostly black. A night scene must not be failed+ # for being a night scene, and must never be told to flatten itself with fill light.+ low_key = is_dark and std is not None and std >= LOWKEY_MIN_STD and (dark is None or dark <= DARK_FRAC)if is_dark:- out.append(_f(sev, name, rig + (f"frame too dark: mean luminance {mean:.2f}, {dark or 0:.0%} of pixels near black" if mean is not None- else f"frame too dark: {dark:.0%} of pixels near black"), _DARK_HINT,+ msg = (f"frame too dark: mean luminance {mean:.2f}, {dark or 0:.0%} of pixels near black" if mean is not None+ else f"frame too dark: {dark:.0%} of pixels near black")+ if low_key:+ msg = (f"frame is dim but lit: mean luminance {mean:.2f} with contrast {std:.2f} "+ f"({dark or 0:.0%} of pixels near black) — low-key by design, not unlit")+ out.append(_f(Severity.WARN if low_key else sev, name, rig + msg,+ _LOWKEY_HINT if low_key else _DARK_HINT,kind="dark_frame", view=name, mean_lum=mean, dark_frac=dark))if blown is not None and blown > BLOWN_FRAC:out.append(_f(sev, name, rig + f"frame blown out: {blown:.0%} of pixels pure white", _BLOWN_HINT,