3D engine that AI agents drive
Reference harness: --bake-grid draws a scene with bake.irradianceGrid (issue #506)
Nguyen Xuan An60ae5ce61a17
diff --git a/bench/reference/harness.js b/bench/reference/harness.jsindex d3d7fe85..15445b0e 100644--- a/bench/reference/harness.js+++ b/bench/reference/harness.js@@ -170,7 +170,7 @@ function describeScene(id, scene) {// Blender always gets the original parts: the bake is 67js's approximation of what Cycles computes.async function bakeScene(scene, bakeOptions) {if (bakeOptions.preset) {- return bakeScenePreset(scene, bakeOptions.preset);+ return bakeScenePreset(scene, bakeOptions.preset, bakeOptions.irradianceGrid);}const { bakeLightmapsAsync } = await import('/src/light-bake-gpu.js');const { pointLights, keyColor, lightDirection } = scene.environment;@@ -182,9 +182,9 @@ async function bakeScene(scene, bakeOptions) {// The bake an agent gets from `bake: { preset }`: the same settings and budget fit as a recipe. Probes stay out of it and come// from --probes, as in the other rows.-async function bakeScenePreset(scene, preset) {+async function bakeScenePreset(scene, preset, irradianceGrid = false) {const { normalizeAgentBake, bakeAgentParts } = await import('/src/agent-bake.js');- const settings = normalizeAgentBake({ preset, probes: false });+ const settings = normalizeAgentBake({ preset, probes: false, ...(irradianceGrid ? { irradianceGrid } : {}) });const started = performance.now();let baked;try {diff --git a/bench/reference/run.mjs b/bench/reference/run.mjsindex 671701cf..ea445798 100644--- a/bench/reference/run.mjs+++ b/bench/reference/run.mjs@@ -117,7 +117,7 @@ const sceneIdsGiven = lookIds ?? (sceneFlag >= 0 ? argumentsGiven[sceneFlag + 1]// The fresh bake.json lands in the work directory and is checked against the committed one (compare-scores.mjs); --update-baseline replaces// the committed bake.json and images/<id>-baked.jpg with it.const bakeScoreRun = bakedSceneIds !== null && !sceneSet && !pathTracerFlag;-const bakeVariantFlags = ['--sky-only', '--bake-preset', '--bake-backend', '--bake-samples', '--bake-density', '--probes', '--ambient', '--ambient-occlusion', '--cascades', '--no-object-probes', '--object-probes', '--no-water', '--ssr-water', '--no-ground-bounce', '--floor-sky', '--floor-sky-rooms', '--no-floor-sky'];+const bakeVariantFlags = ['--sky-only', '--bake-preset', '--bake-grid', '--bake-backend', '--bake-samples', '--bake-density', '--probes', '--ambient', '--ambient-occlusion', '--cascades', '--no-object-probes', '--object-probes', '--no-water', '--ssr-water', '--no-ground-bounce', '--floor-sky', '--floor-sky-rooms', '--no-floor-sky'];const bakeScoreIsBaseline = bakeScoreRun && argumentsGiven.includes('--update-baseline') && !bakeVariantFlags.some(flag => argumentsGiven.includes(flag));const onlyScenes = sceneIdsGiven ?? (bakeScoreRun ? bakedSceneIds : null);const skipCpu = skipCpuFlag || bakeScoreRun || Boolean(viewTransform);@@ -147,7 +147,7 @@ async function renderBackend(backend, serverUrl, graphics) {// Object probes are on by default, as in a recipe, so the baseline scores what a user gets.const objectProbesThisScene = !argumentsGiven.includes('--no-object-probes') && (objectProbeSceneIds === null || objectProbeSceneIds.includes(id));const probes = probesThisScene || (objectProbesThisScene ? 'objects' : false);- const bake = bakesThisScene ? { ...skyOnlyOptions, ...(bakePreset ? { preset: bakePreset } : {}), ...(bakeBackend ? { backend: bakeBackend } : {}), ...(bakeSamples ? { samples: bakeSamples } : {}), ...(bakeDensity ? { texelsPerUnit: bakeDensity } : {}) } : null;+ const bake = bakesThisScene ? { ...skyOnlyOptions, ...(bakePreset ? { preset: bakePreset } : {}), ...(argumentsGiven.includes('--bake-grid') ? { irradianceGrid: true } : {}), ...(bakeBackend ? { backend: bakeBackend } : {}), ...(bakeSamples ? { samples: bakeSamples } : {}), ...(bakeDensity ? { texelsPerUnit: bakeDensity } : {}) } : null;const result = await page.evaluate(([sceneId, shouldDescribe, ambientOcclusion, ambientOcclusionRadius, bakeOptions, cascadeCount, withProbes, ambientScale, selectedViewTransform]) => window.renderReferenceScene(sceneId, { describe: shouldDescribe, ambientOcclusion, ambientOcclusionRadius, bake: bakeOptions, cascades: cascadeCount, probes: withProbes, ambient: ambientScale, viewTransform: selectedViewTransform }), [id, describe, ambientOcclusion, ambientOcclusionRadius, bake, cascades, probes, ambient, viewTransform]);if (result.glError !== 0) throw new Error(`${id} on ${backend} gave WebGL error ${result.glError}.`);graphics[backend] = result.graphics;