Official Codebase of 3DCodeVerse
Python
lib: comments that still said <color_fragment> is the only hook, or that there is no post chain
gaoypengaa4263d49aea
diff --git a/harness/codeverse3d/languages/scene_threejs/starter/src/lib/accumulation.js b/harness/codeverse3d/languages/scene_threejs/starter/src/lib/accumulation.jsindex f98ed9b0..551bf58d 100644--- a/harness/codeverse3d/languages/scene_threejs/starter/src/lib/accumulation.js+++ b/harness/codeverse3d/languages/scene_threejs/starter/src/lib/accumulation.js@@ -20,9 +20,10 @@* away from them. So a layer sells its depth by what it COVERS (steep* faces lose it, concave lees keep it), by a torn edge instead of a* ruled one, and by the shade it drops on the material just outside- * that edge. Gloss is per MATERIAL, not per pixel, so each patch- * composes ONE factor through `composeRoughness`, weighted by how much- * of the surface it took over.+ * that edge. Gloss here is per MATERIAL, not per pixel (neither patch+ * uses `patchStandard`'s `roughnessBody`), so each patch composes ONE+ * factor through `composeRoughness`, weighted by how much of the+ * surface it took over.*/import * as THREE from 'three';diff --git a/harness/codeverse3d/languages/scene_threejs/starter/src/lib/aging.js b/harness/codeverse3d/languages/scene_threejs/starter/src/lib/aging.jsindex fc904fac..9637648c 100644--- a/harness/codeverse3d/languages/scene_threejs/starter/src/lib/aging.js+++ b/harness/codeverse3d/languages/scene_threejs/starter/src/lib/aging.js@@ -18,9 +18,11 @@* `patchDripStains(m, { from })` is the one way to pin the source to an* exact sill.*- * Gloss is per MATERIAL, not per pixel — `<color_fragment>` runs before- * `<roughnessmap_fragment>` — so each patch composes one roughening- * factor through `composeRoughness`: dirt, rust and dust are all matte.+ * Gloss is per MATERIAL, not per pixel — all three write only at+ * `<color_fragment>`, before `<roughnessmap_fragment>`, and none uses+ * `patchStandard`'s `roughnessBody` — so each patch composes one+ * roughening factor through `composeRoughness`: dirt, rust and dust are+ * all matte.** COLOUR: no effect here is one tone. Weather is a mixture — the dirt* that ran down is not the salt it leached out of the wall, the pit indiff --git a/harness/codeverse3d/languages/scene_threejs/starter/src/lib/clouds.js b/harness/codeverse3d/languages/scene_threejs/starter/src/lib/clouds.jsindex f7a7bd28..15aef37c 100644--- a/harness/codeverse3d/languages/scene_threejs/starter/src/lib/clouds.js+++ b/harness/codeverse3d/languages/scene_threejs/starter/src/lib/clouds.js@@ -6,14 +6,15 @@ import { mulberry32, fbm2 } from './noise.js';import { makeShaderMaterial, keepOutOfDepthPasses } from './shader.js';// Cumulus/cirrus mood presets, graded for THIS renderer: ACES filmic at-// exposure 1.0, sRGB out, NO post chain (no bloom to rescue a dim top,-// no grade to pull a tint back). A lit cumulus top is the brightest-// diffuse thing in a daylight frame, so `sunColor` is a near-WHITE with-// a warm bias — the old 0xffc890 sun tint was graded against a bloom+-// grade chain and lands as tan smoke here (measured: cloud region-// (224,233,236) against a (232,239,242) sky, 3% contrast). `shadeColor`-// is the sky-lit underside, never neutral grey: it is where the blue-// comes from.+// exposure 1.0, sRGB out, and nothing after that rescues a dim top or+// pulls a tint back (the post chain's bloom takes only EMISSION, which a+// cloud has none of, and its grade is identity unless the scene asks).+// A lit cumulus top is the brightest diffuse thing in a daylight frame,+// so `sunColor` is a near-WHITE with a warm bias — the old 0xffc890 sun+// tint was graded against a bloom+grade chain and lands as tan smoke+// here (measured: cloud region (224,233,236) against a (232,239,242)+// sky, 3% contrast). `shadeColor` is the sky-lit underside, never+// neutral grey: it is where the blue comes from.const PRESETS = {day: { sunColor: 0xfff4e6, shadeColor: 0x7e94b8, litGain: 1.55 },golden: { sunColor: 0xffd0a0, shadeColor: 0x7c82ac, litGain: 1.70 },diff --git a/harness/codeverse3d/languages/scene_threejs/starter/src/lib/damp.js b/harness/codeverse3d/languages/scene_threejs/starter/src/lib/damp.jsindex 6bdf135d..ccba9d5c 100644--- a/harness/codeverse3d/languages/scene_threejs/starter/src/lib/damp.js+++ b/harness/codeverse3d/languages/scene_threejs/starter/src/lib/damp.js@@ -22,8 +22,9 @@* (measured: a splat over a triplanar did exactly that). Every one here* multiplies or mixes with what it is handed.*- * Gloss is per MATERIAL, not per pixel — `<color_fragment>` runs before- * `<roughnessmap_fragment>` — so each composes ONE factor through+ * Gloss is per MATERIAL, not per pixel — all three write only at+ * `<color_fragment>`, before `<roughnessmap_fragment>`, and none uses+ * `patchStandard`'s `roughnessBody` — so each composes ONE factor through* `composeRoughness`, and they pull BOTH ways: moss and dried mud are* matte, damp ground and a water-filled crack are glossy.*/@@ -222,7 +223,7 @@ const siltDamp = (base) =>* It MIXES over the albedo it is handed (and shades the material just* outside its edge, the only thickness a patch that cannot displace* geometry has), so a triplanar, a splat or a stain underneath survives- * everywhere the moss is thin. Gloss is per MATERIAL, not per pixel:+ * everywhere the moss is thin. Gloss here is per MATERIAL, not per pixel:* moss is the mattest thing on any rock, so its factor goes UP.** @param {THREE.Material} material A built-in material, patched in@@ -394,9 +395,9 @@ export function patchMoss(material, opts = {}) {** It MULTIPLIES the albedo it is handed and deepens its colour, so a* triplanar, a splat or a wear pattern underneath comes through the- * apron rather than being replaced by it. Gloss is per MATERIAL, not- * per pixel, so the factor goes DOWN — the opposite direction from moss- * on the same chain.+ * apron rather than being replaced by it. Gloss here is per MATERIAL,+ * not per pixel, so the factor goes DOWN — the opposite direction from+ * moss on the same chain.** @param {THREE.Material} material A built-in material, patched in* place — a shared material damps every mesh wearing it.diff --git a/harness/codeverse3d/languages/scene_threejs/starter/src/lib/finish.js b/harness/codeverse3d/languages/scene_threejs/starter/src/lib/finish.jsindex ca1f93fa..ad17f6e1 100644--- a/harness/codeverse3d/languages/scene_threejs/starter/src/lib/finish.js+++ b/harness/codeverse3d/languages/scene_threejs/starter/src/lib/finish.js@@ -8,8 +8,8 @@* `terrain_shade` and `waterside` on one material.** Both lift `totalEmissiveRadiance` rather than the albedo, which is the- * one decision that separates them from a pale repaint. The only- * fragment hook is `<color_fragment>`, so a patch may either tint ALBEDO+ * one decision that separates them from a pale repaint. At+ * `<color_fragment>`, where both run, a patch may either tint ALBEDO* — capped at the light already landing on the surface — or ADD light,* the choice `windows.js` documents for a lit room. A lantern at dusk* and an oil sheen on a shaded cobble are both brighter than their own@@ -349,13 +349,14 @@ const IRID_BODY = [* dim HemisphereLight — `sunRig` always does — or the film has nothing* to split and stays invisible.*- * METALNESS is the limit. Per-pixel metalness is unreachable (there is- * no `composeMetalness` — `<color_fragment>` is the only hook), so this- * cannot do what a real coating does to metal, which is to tint how the- * METAL reflects. Above about 0.6 metalness the material has no diffuse- * left and the film reads as a flat wash over a reflection that has not- * changed. For a beetle's back or anodised steel, drop metalness to- * 0.2-0.4 and let the film carry the colour.+ * METALNESS is the limit. This patch never touches metalness (it runs at+ * `<color_fragment>` and does not use `patchStandard`'s+ * `metalnessBody`), so it cannot do what a real coating does to metal,+ * which is to tint how the METAL reflects. Above about 0.6 metalness+ * the material has no diffuse left and the film reads as a flat wash+ * over a reflection that has not changed. For a beetle's back or+ * anodised steel, drop metalness to 0.2-0.4 and let the film carry the+ * colour.** @param {THREE.Material} material A lit built-in material (it needs* `totalEmissiveRadiance`), patched in place — a shared materialdiff --git a/harness/codeverse3d/languages/scene_threejs/starter/src/lib/flock.js b/harness/codeverse3d/languages/scene_threejs/starter/src/lib/flock.jsindex 55a070be..c858f950 100644--- a/harness/codeverse3d/languages/scene_threejs/starter/src/lib/flock.js+++ b/harness/codeverse3d/languages/scene_threejs/starter/src/lib/flock.js@@ -33,7 +33,8 @@ import * as THREE from 'three';import { mulberry32 } from './noise.js';import {- instancedQuad, makeShaderMaterial, readVec3, tickShaders, keepOutOfDepthPasses,+ instancedQuad, keepOutOfDepthPasses, makeShaderMaterial, readVec3,+ tickShaders,} from './shader.js';const _TAU = Math.PI * 2;diff --git a/harness/codeverse3d/languages/scene_threejs/starter/src/lib/neon.js b/harness/codeverse3d/languages/scene_threejs/starter/src/lib/neon.jsindex 37e9d5e2..17d25f7b 100644--- a/harness/codeverse3d/languages/scene_threejs/starter/src/lib/neon.js+++ b/harness/codeverse3d/languages/scene_threejs/starter/src/lib/neon.js@@ -46,15 +46,14 @@ const FLICK_GLSL = [].join('\n');// HOW WHITE THE MIDDLE OF THE GLASS GOES, and it is not very white.-// This renderer tone maps in the FRAGMENT TAIL with no post chain, so-// additive layers sum in DISPLAY space: the near and far walls of a-// double-sided shell plus the halo twice stack four deep on the middle-// of a tube, and every channel a colour carries is multiplied by that-// stack. Whitening the colour BEFORE it threw the gas away — measured,-// a cyan sign rendered as a white strip light with a cyan edge. A tube-// IS meant to clip, toward its OWN hue, which the stack does by itself-// once the colour stays saturated. So: a fifth of the way to white dead-// centre, gone two thirds out — a hot line in coloured glass.+// Additive layers SUM: the near and far walls of a double-sided shell+// plus the halo twice stack four deep on the middle of a tube, and+// every channel a colour carries is multiplied by that stack. Whitening+// the colour BEFORE it threw the gas away — measured, a cyan sign+// rendered as a white strip light with a cyan edge. A tube IS meant to+// clip, toward its OWN hue, which the stack does by itself once the+// colour stays saturated. So: a fifth of the way to white dead centre,+// gone two thirds out — a hot line in coloured glass.const FILAMENT_GLSL = ['float astraNeonFilament(float face, float hot) {',' return pow(face, 14.0) * hot * 0.22;',@@ -764,8 +763,9 @@ export function makeLightTrails(opts = {}) {const gain = hazy ? 0.55 : 1.15;const half = width * 3;// 0.5, not 0.7, on the head-lights: a lamp that whitens hard has- // no colour temperature left to vary, and with no bloom pass here- // the white it clips to is the last thing the frame records.+ // no colour temperature left to vary, and the white it clips to is+ // the last thing the frame records — the post chain's bloom only+ // haloes it.g.add(laneMesh(fr, -lane, half, lift, trailMaterial('NeonTrailWarm', toColor(opts.warm, 0xffeec8), 1, count, rate,gain, 0.5, 0.60, key, hazy, 0.40), 'TrailsWarm'));diff --git a/harness/codeverse3d/languages/scene_threejs/starter/src/lib/roadway.js b/harness/codeverse3d/languages/scene_threejs/starter/src/lib/roadway.jsindex 8b425394..5f73255e 100644--- a/harness/codeverse3d/languages/scene_threejs/starter/src/lib/roadway.js+++ b/harness/codeverse3d/languages/scene_threejs/starter/src/lib/roadway.js@@ -30,10 +30,11 @@* Tracks that must run somewhere else on the same material take* `offset` (metres across) rather than a second centreline.*- * Gloss is per MATERIAL, not per pixel — `<color_fragment>` runs before- * `<roughnessmap_fragment>` — so each patch composes ONE factor through- * `composeRoughness`: polished ruts and a damp gutter drop it, grit and- * loose aggregate raise it.+ * Gloss is per MATERIAL, not per pixel — all three write only at+ * `<color_fragment>`, before `<roughnessmap_fragment>`, and none uses+ * `patchStandard`'s `roughnessBody` — so each patch composes ONE factor+ * through `composeRoughness`: polished ruts and a damp gutter drop it,+ * grit and loose aggregate raise it.*/import * as THREE from 'three';diff --git a/harness/codeverse3d/languages/scene_threejs/starter/src/lib/shader.js b/harness/codeverse3d/languages/scene_threejs/starter/src/lib/shader.jsindex 16a430ff..f3ad0887 100644--- a/harness/codeverse3d/languages/scene_threejs/starter/src/lib/shader.js+++ b/harness/codeverse3d/languages/scene_threejs/starter/src/lib/shader.js@@ -15,10 +15,12 @@* 1b. every scene here sets `scene.fog`, and fog reaches a shader ONLY* through its chunks — without them the effect keeps full contrast* while the world around it recedes, which is the sticker look;- * 1c. this renderer has NO post chain: tone mapping (ACES, exposure- * 1.0) and the sRGB encode happen in the fragment tail, so a shader- * without three's two closing chunks renders dark and untonemapped- * next to every built-in — they are appended for you;+ * 1c. scene renders go through a post chain whose OutputPass does the+ * tone mapping (ACES, exposure 1.0) and the sRGB encode, but a pass+ * drawn straight to the canvas (`post: false`, the raw coverage+ * passes) does both in the fragment tail, so there a shader without+ * three's two closing chunks renders dark and untonemapped next to+ * every built-in — they are appended for you;* 2. an `#include` sharing a line with anything else fails to compile;* 3. GLSL 3.00 syntax in a material three compiles as GLSL ES 1.00.*@@ -290,10 +292,10 @@ const FOG_PARS_F = '#include <fog_pars_fragment>';const FOG_F = '#include <fog_fragment>';// What three appends to the end of every one of its OWN fragment// shaders. Both resolve per render target: identity into the-// linear buffer a post chain reads, tone map + sRGB straight to-// the canvas. This harness renders straight to the canvas (ACES,-// exposure 1.0, no post chain today), so without them a custom-// shader is dark and untonemapped next to every built-in.+// linear buffer the post chain reads (scene renders; its OutputPass+// tone-maps), tone map + sRGB straight to the canvas (`post: false`+// and the raw passes: ACES, exposure 1.0) — where, without them, a+// custom shader is dark and untonemapped next to every built-in.const OUT_F = [' #include <tonemapping_fragment>',' #include <colorspace_fragment>',@@ -577,7 +579,10 @@ export function makeShaderMaterial(opts = {}) {* (uTime added, driven by `tickShaders`); `vertexHead`/`fragmentHead`* code before main; `vertexBody` runs after `<begin_vertex>` (edit* `transformed`); `fragmentBody` runs after `<color_fragment>` (edit- * `diffuseColor`); `util` include GLSL_UTIL.+ * `diffuseColor`); `roughnessBody` / `metalnessBody` / `outputBody`+ * run after `<roughnessmap_fragment>` / `<metalnessmap_fragment>` /+ * `<opaque_fragment>` (per-pixel `roughnessFactor`, `metalnessFactor`,+ * the lit `gl_FragColor`); `util` include GLSL_UTIL.* @returns {THREE.Material} The same material.*//**diff --git a/harness/codeverse3d/languages/scene_threejs/starter/src/lib/signage.js b/harness/codeverse3d/languages/scene_threejs/starter/src/lib/signage.jsindex dede75f0..582eb654 100644--- a/harness/codeverse3d/languages/scene_threejs/starter/src/lib/signage.js+++ b/harness/codeverse3d/languages/scene_threejs/starter/src/lib/signage.js@@ -198,9 +198,9 @@ function _paintVariance(geo, size, amount) {* (default 1) scales the baked paint mottle / wall shading, 0 drops* the vertex colours entirely (a `material` you pass in reads them* only if it sets `vertexColors`); `emissive` + `emissiveIntensity`- * (default 1.6 when emissive is set — there is NO bloom pass in this- * pipeline, so 1.5-4 is the whole usable range and 20 is a white- * blob) make a neon / backlit sign; `light` the practical an+ * (default 1.6 when emissive is set — the post chain's bloom only+ * adds a soft halo, so 1.5-4 is the whole usable range and 20 is a+ * white blob) make a neon / backlit sign; `light` the practical an* emissive sign throws on its own board — `false` to drop it (do* that for a facade carrying dozens of signs: this is one real* PointLight per line), a number to set its candela directly. Thediff --git a/harness/codeverse3d/languages/scene_threejs/starter/src/lib/strata.js b/harness/codeverse3d/languages/scene_threejs/starter/src/lib/strata.jsindex c02e5e95..7f126fc9 100644--- a/harness/codeverse3d/languages/scene_threejs/starter/src/lib/strata.js+++ b/harness/codeverse3d/languages/scene_threejs/starter/src/lib/strata.js@@ -374,10 +374,11 @@ export function patchRockStrata(material, opts = {}) {* weaker than the last, so a run continues below where it started and* tapers out, which is flow rather than stripes.*- * Roughness is per MATERIAL, not per pixel (`<color_fragment>` runs- * before `<roughnessmap_fragment>`), so the wash takes a small polish- * off the whole surface through `composeRoughness` — a face with water- * tracks is a face that gets wet.+ * Roughness is per MATERIAL here, not per pixel (the patch writes only+ * at `<color_fragment>`, before `<roughnessmap_fragment>`, and does not+ * use `patchStandard`'s `roughnessBody`), so the wash takes a small+ * polish off the whole surface through `composeRoughness` — a face with+ * water tracks is a face that gets wet.** @param {THREE.Material} material A built-in material, patched in* place — a shared material streaks every mesh wearing it.diff --git a/harness/codeverse3d/languages/scene_threejs/starter/src/lib/submerged.js b/harness/codeverse3d/languages/scene_threejs/starter/src/lib/submerged.jsindex 2d0cd68b..0746142d 100644--- a/harness/codeverse3d/languages/scene_threejs/starter/src/lib/submerged.js+++ b/harness/codeverse3d/languages/scene_threejs/starter/src/lib/submerged.js@@ -573,9 +573,10 @@ const ICE_BODY = [* A geometry with no uv has no border, and frosts everywhere — give* the sheet a PlaneGeometry's uv or pass `frost: 0`.*- * Gloss goes through `composeRoughness`, the only route to it: the one- * fragment hook runs before `<roughnessmap_fragment>`, so roughness is- * a material value, and frostier ice is duller.+ * Gloss goes through `composeRoughness`: this patch writes only at+ * `<color_fragment>`, before `<roughnessmap_fragment>`, and does not use+ * `patchStandard`'s `roughnessBody`, so roughness is a material value,+ * and frostier ice is duller.** @param {THREE.Material} material A built-in material, patched in* place.diff --git a/harness/codeverse3d/languages/scene_threejs/starter/src/lib/surface_wear.js b/harness/codeverse3d/languages/scene_threejs/starter/src/lib/surface_wear.jsindex 99f6fbac..11f66952 100644--- a/harness/codeverse3d/languages/scene_threejs/starter/src/lib/surface_wear.js+++ b/harness/codeverse3d/languages/scene_threejs/starter/src/lib/surface_wear.js@@ -11,10 +11,11 @@* neither needs a UV; and both CHAIN with each other and with* `terrain_shade` / `waterside` on one material.*- * Gloss is the one thing neither can do per pixel: the only fragment- * hook runs after `<color_fragment>`, which is BEFORE- * `<roughnessmap_fragment>`, so both retune `material.roughness`- * instead and compose their factors through `composeRoughness`.+ * Gloss is the one thing neither does per pixel: both write only at+ * `<color_fragment>`, which is BEFORE `<roughnessmap_fragment>`, and+ * neither uses `patchStandard`'s `roughnessBody`, so both retune+ * `material.roughness` instead and compose their factors through+ * `composeRoughness`.** PORT NOTES (2026-09-01, measured on our host — no post chain, ACES in* the fragment tail, a bright baked environment as the specular source):diff --git a/harness/codeverse3d/languages/scene_threejs/starter/src/lib/water.js b/harness/codeverse3d/languages/scene_threejs/starter/src/lib/water.jsindex 3ad3b634..59c646ef 100644--- a/harness/codeverse3d/languages/scene_threejs/starter/src/lib/water.js+++ b/harness/codeverse3d/languages/scene_threejs/starter/src/lib/water.js@@ -8,9 +8,9 @@** The addon's fragment shader is REGRADED here (see `_regrade`): its* stock look is a 30%-reflective milk with a flat +0.1 veil, which on- * our pipeline (ACES, exposure 1.0, no post chain) renders a pool as- * pale plastic — measured 2026-09-01, a still pool read mean_lum 0.73- * at BOTH a steep and a grazing view, i.e. no Fresnel at all.+ * our pipeline (ACES, exposure 1.0) renders a pool as pale plastic —+ * measured 2026-09-01, a still pool read mean_lum 0.73 at BOTH a steep+ * and a grazing view, i.e. no Fresnel at all.*/import * as THREE from 'three';@@ -293,7 +293,7 @@ function _readScene(scene, uniforms, pinned) {* `waterColor` hex (default 0x0e3f5c);* `sunColor` hex (default 0xffffff);* `distortionScale` reflection wobble (default 2.8);- * `rttSize` reflection render-target px (default 256);+ * `rttSize` reflection render-target px (default 512);* `size` wave-pattern density uniform (default: scaled to the plane);* `waterNormals` texture override (default `makeWaterNormals(256)`);* `fog` fold scene fog into the shader (default true);diff --git a/harness/codeverse3d/languages/scene_threejs/starter/src/lib/waterside.js b/harness/codeverse3d/languages/scene_threejs/starter/src/lib/waterside.jsindex be94c040..d981aeea 100644--- a/harness/codeverse3d/languages/scene_threejs/starter/src/lib/waterside.js+++ b/harness/codeverse3d/languages/scene_threejs/starter/src/lib/waterside.js@@ -41,10 +41,10 @@ const BASE = worldBase('waterside:base', 'wsP', 'wsN');* sky-family colour a `<color_fragment>` patch can reach), which is* what separates wet sand from sand in shadow.*- * `gloss` lands on the MATERIAL, not per pixel: `patchStandard`'s only- * fragment hook runs after `<color_fragment>` and therefore BEFORE- * `<roughnessmap_fragment>` declares `roughnessFactor`, so per-pixel- * roughness is out of reach. It therefore defaults to a LIGHT touch:+ * `gloss` lands on the MATERIAL, not per pixel: this patch writes only+ * at `<color_fragment>`, BEFORE `<roughnessmap_fragment>` declares+ * `roughnessFactor`, and does not use `patchStandard`'s `roughnessBody`.+ * It therefore defaults to a LIGHT touch:* a shore ground is mostly dry, and the reference default of 0.45 took* `MAT.soil()` from roughness 0.95 to 0.43 over the whole beach —* measured on this renderer (ACES, exposure 1.0, baked environment) itdiff --git a/harness/tests/scene_runtime/lib/test_water.py b/harness/tests/scene_runtime/lib/test_water.pyindex a833bf13..de2eddc9 100644--- a/harness/tests/scene_runtime/lib/test_water.py+++ b/harness/tests/scene_runtime/lib/test_water.py@@ -380,9 +380,10 @@ def test_the_regrade_replaces_the_addon_tail(probe) -> None:def test_the_regrade_keeps_our_pipelines_fragment_tail(probe) -> None:- """We have no post chain: ACES and the sRGB encode happen in the- fragment tail, so a splice that dropped three's two closing chunks- would render the water dark next to every built-in material."""+ """Off the post chain (`post: false`, the raw passes) ACES and the sRGB+ encode happen in the fragment tail, so a splice that dropped three's+ two closing chunks would render the water dark there, next to every+ built-in material."""assert probe["keepsToneMap"], "tonemapping/colorspace chunks lost"