3D engine that AI agents drive
JavaScript 3d3d-engineagentic-aiai-agentsblenderclaude-codegame-enginegaussian-splattinggltfjavascriptmcpmcp-servermodel-context-protocolpath-tracerpath-tracingpbrrenderingthreejs-alternativewebgl2webgpu
Document that ambientIntensity also scales the HDRI light (#1983)
Nguyen Xuan An5a65a8dfc326
diff --git a/changes/1983.md b/changes/1983.mdnew file mode 100644index 00000000..59636271--- /dev/null+++ b/changes/1983.md@@ -0,0 +1 @@+- Say in the `environment` tool schema, `docs/agent-look.md` and the look reference that `ambientIntensity` also scales the HDRI diffuse light and reflections, so an HDRI-only scene keeps it above 0 (#1983).diff --git a/docs/agent-look.md b/docs/agent-look.mdindex af7a03fd..a77b3a6a 100644--- a/docs/agent-look.md+++ b/docs/agent-look.md@@ -128,13 +128,13 @@ Sky colors use display RGB, matching the renderer's existing environment contrac| `specularAntiAliasing` | `1` | Absent unless set. `0` to `4`. Widens highlights where the shading normal or normal map detail changes within a pixel (geometric specular anti-aliasing plus a Toksvig term read from the filtered normal map length), so grainy or scanned metal stops sparkling from frame to frame at grazing angles. `0` gives a highlight that follows every texel; above `1` is softer. || `sunBounce` | `1` | Absent unless set. A number of 0 or more. A closed room a sun lights gets a few point lights at its sunlit patches (`withSunBounce`, found when the scene is prepared), so the floor, walls and pillars around a patch are lit by the light it bounces and the far end of the room less. `0` turns it off and gives the look without it; `1` is fitted to Cycles; above `1` is stronger. A value that is not a number of 0 or more is refused. Open scenes and rooms with no sun are left as they are. It loads lazily with the sun, and the lights take up to 6 of the 16 point light slots. || `setup` | `daylight` | `daylight`, `overcast`, `sunset` or `studio`. See Lighting setups |-| `environmentIntensity` | `1` | `0` to `100`. Scales the setup's environment light and reflections |+| `environmentIntensity` | `1` | `0` to `100`. Scales the setup's environment light and reflections, multiplied by `ambientIntensity` || `environmentRotation` | `0` | `-100` to `100` radians around the vertical axis || `lightDirection` | the setup's | Components within ±1000000, length at least `0.000001` || `keyColor` | the setup's | Components from `0` to `1000` || `keyIntensity` | `1` | `0` to `100` || `fillIntensity` | `0` | `0` to `100` |-| `ambientIntensity` | `1` | `0` to `100`. Scales the environment light |+| `ambientIntensity` | `1` | `0` to `100`. Scales the sky ambient and also the diffuse light and reflections of the setup environment map or HDRI, so `0` renders an HDRI-lit scene black whatever `environmentIntensity` is. For an HDRI-only scene keep it above `0` and set `keyIntensity` and `fillIntensity` to `0` || `daylight` | `1` | `0` to `100` || `pointLights` | `[]` | At most 16 point light records || `skyTop` | `[0.2, 0.38, 0.52]` | Components from `0` to `1` |diff --git a/scripts/mcp-server.mjs b/scripts/mcp-server.mjsindex d1e9bbe2..d5684f4f 100644--- a/scripts/mcp-server.mjs+++ b/scripts/mcp-server.mjs@@ -261,7 +261,7 @@ const environment = z.strictObject({keyColor: boundedVector(0, 1000).optional(),keyIntensity: bounded(0, 100).optional(),fillIntensity: bounded(0, 100).optional(),- ambientIntensity: bounded(0, 100).optional(),+ ambientIntensity: bounded(0, 100).optional().describe('Scales the sky ambient and, with an hdri or setup environment map, that map\'s diffuse light and reflections too. 0 blacks the map out; for an HDRI-only scene keep it above 0 and set key and fill to 0.'),daylight: bounded(0, 100).optional(),keyAffects: affects.describe('Node IDs lit; default all.'),shadowCascades: z.number().int().min(0).max(4).optional().describe('Sun shadow slices; 0 one map.'),diff --git a/skills/build-crucible-scene/references/look.md b/skills/build-crucible-scene/references/look.mdindex 49cb3fd5..5075ea6e 100644--- a/skills/build-crucible-scene/references/look.md+++ b/skills/build-crucible-scene/references/look.md@@ -53,7 +53,7 @@ Tool `scene_apply`:````keyIntensity: 0` drops the setup's sun when the HDRI has its own; keep it above 0 when you want shadows from the-key light. `"hdri": null` clears it.+key light. `"hdri": null` clears it. `ambientIntensity` also scales the HDRI's diffuse light and reflections, so `0` makes an HDRI-lit scene black even with a high `environmentIntensity`. For an HDRI-only scene set `keyIntensity` and `fillIntensity` to 0 and keep `ambientIntensity` above 0.## Color look and tone mappingdiff --git a/tests/hdri-ambient-intensity-docs.test.js b/tests/hdri-ambient-intensity-docs.test.jsnew file mode 100644index 00000000..3ed0760c--- /dev/null+++ b/tests/hdri-ambient-intensity-docs.test.js@@ -0,0 +1,64 @@+import test from 'node:test';+import assert from 'node:assert/strict';+import { mkdtemp } from 'node:fs/promises';+import { tmpdir } from 'node:os';+import { join } from 'node:path';+import { Client } from '@modelcontextprotocol/client';+import { InMemoryTransport } from '@modelcontextprotocol/server';+import { createAgentRuntime } from '../scripts/agent-runtime.mjs';+import { createAgentMcpServer } from '../scripts/mcp-server.mjs';+import { decodePngPixels, meanBrightness } from './support/png-pixels.mjs';++// Issue 1983: ambientIntensity multiplies the HDRI's diffuse light and reflections, so an HDRI-only scene with ambientIntensity 0+// renders black. The environment topic must say so, and the render must do what the text says.++async function startServer(context) {+ const directory = await mkdtemp(join(tmpdir(), 'crucible-hdri-ambient-'));+ const runtime = createAgentRuntime({ backend: 'cpu', memory: 192, jobs: join(directory, 'jobs') });+ const server = createAgentMcpServer(runtime);+ const client = new Client({ name: 'hdri-ambient-test', version: '1' });+ const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();+ await server.connect(serverTransport);+ await client.connect(clientTransport);+ context.after(async () => {+ await client.close();+ await server.close();+ await runtime.close?.();+ });+ return client;+}++async function call(client, name, argumentsValue) {+ const result = await client.callTool({ name, arguments: argumentsValue }, { timeout: 120000 });+ assert.equal(result.isError, undefined, result.content?.find(item => item.type === 'text')?.text);+ return result;+}++function recipeWith(environment) {+ return {+ format: 'crucible.scene', schemaVersion: 1,+ geometries: [{ id: 'ball', type: 'sphere' }],+ materials: [{ id: 'plain', color: [0.7, 0.7, 0.7], roughness: 0.8 }],+ nodes: [{ id: 'ball', geometry: 'ball', material: 'plain' }],+ camera: { eye: [0, 0, 3], target: [0, 0, 0] },+ environment: { hdri: 'sky-clouds', keyIntensity: 0, fillIntensity: 0, ground: false, ...environment },+ };+}++async function ballBrightness(client, environment) {+ const created = await call(client, 'scene_create', { recipe: recipeWith(environment) });+ const look = await call(client, 'scene_look', { sessionId: created.structuredContent.sessionId, width: 128, height: 128 });+ const bytes = Buffer.from(look.content.find(item => item.type === 'image').data, 'base64');+ return meanBrightness(decodePngPixels(bytes), [0.4, 0.4, 0.6, 0.6]);+}++test('the environment topic says ambientIntensity scales the HDRI, and the render agrees', { timeout: 240000 }, async context => {+ const client = await startServer(context);+ const topic = JSON.stringify((await call(client, 'scene_capabilities', { topic: 'environment' })).structuredContent);+ assert.match(topic, /ambientIntensity\?":"[^"]*hdri[^"]*diffuse light and reflections/);+ assert.match(topic, /keep it above 0 and set key and fill to 0/);+ const lit = await ballBrightness(client, { ambientIntensity: 1 });+ const black = await ballBrightness(client, { ambientIntensity: 0, environmentIntensity: 1.4 });+ assert.ok(lit > 20, `an HDRI-lit ball with ambientIntensity 1 should be visible, mean ${lit}`);+ assert.ok(black < 1, `ambientIntensity 0 blacks the HDRI out whatever environmentIntensity is, mean ${black}`);+});