Skip to content

3D engine that AI agents drive

Merge pull request #1953 from codepawl/1948-area-light-portal

Nguyen Xuan An5092433eb56a
diff --cc docs/path-tracer.md
index 27033053,e2e1879b..837f34a4
--- a/docs/path-tracer.md
+++ b/docs/path-tracer.md
@@@ -27,10 -27,10 +27,10 @@@ Unidirectional path tracing against th
```js
environment.areaLights = [{ position: [-2, 1.5, 0], direction: [1, 0, 0], up: [0, 1, 0], width: 2, height: 1, portal: true }];
```
- A shading point behind the portal (outside) is lit by BSDF samples only, and a ray that reaches the sky by another way than a portal still counts in full. The CPU tracer samples the sky through the portals in the same way (`src/path-tracer-portal.js`: a portal chosen uniformly, a point uniform on it, the pdf summed over the portals the direction crosses), and its next-event light for the sky is drawn through them. The WebGPU tracer does the same in its megakernel and wavefront kernels (the portals sit at the end of the environment table buffer), and the real-time WebGPU tracer does not use them yet. The WebGL tracer draws no light from a portal and names it in `report.ignored`. The agent scene tools do not take `portal` yet.
+ A shading point behind the portal (outside) is lit by BSDF samples only, and a ray that reaches the sky by another way than a portal still counts in full. The CPU tracer samples the sky through the portals in the same way (`src/path-tracer-portal.js`: a portal chosen uniformly, a point uniform on it, the pdf summed over the portals the direction crosses), and its next-event light for the sky is drawn through them. The WebGPU tracer does the same in its megakernel and wavefront kernels (the portals sit at the end of the environment table buffer), and the real-time WebGPU tracer does not use them yet. The WebGL tracer draws no light from a portal and names it in `report.ignored`. The agent scene tools take it: `environment.areaLights[].portal` in a recipe or `set-environment` (a boolean; `true` needs a rect light with `width` and `height` above 0, anything else is rejected with the field name). A render job passes the portal to the trace scene Cook reads; the rasterizer draws no light from it (the light emits nothing there) and `scene_inspect` lists a `portal-ignored-by-raster` diagnostic. `scene_capabilities` topic `lightPortals` names the field.
![The same dim room corner lit only by the sky through a window, 64 samples a pixel in Cook: without a portal (left, grainy) and with one over the window (right, smooth), at the same brightness](cook-light-portals.jpg)
-- Exposure (#1833): a render job's `effects.exposure` multiplies the traced linear picture before the view transform, on the CPU, WebGL and WebGPU backends and on a native frame; `renderPathTracedImage` and `toneMapToRgba8` take it as `exposure` (a number above 0, default 1), and the linear pixels it returns are not scaled. A scene with no sun, sky or lamp traces black. `ambientIntensity`, `fillIntensity`, `daylight` and `skyTop`/`skyBottom` are rasterizer terms: the tracer lights the scene with the environment map, so use `environmentIntensity` to scale the sky.
+- Exposure (#1833): a render job's `effects.exposure` multiplies the traced linear picture before the view transform, on the CPU, WebGL and WebGPU backends and on a native frame; `renderPathTracedImage` and `toneMapToRgba8` take it as `exposure` (a number above 0, default 1), and the linear pixels it returns are not scaled. A scene with no sun, sky or lamp traces black. `ambientIntensity` multiplies the environment map strength, as it scales the rasterizer's environment light (Cycles: the World Background strength; `src/path-trace-terms.js`); a camera ray still sees the sky at the unscaled strength on the native kernel. `fillIntensity` (two fixed unshadowed lights) and `world: true` (outdoor haze shading) are rasterizer only, and the render report says so when a recipe sets them. `daylight` and `skyTop`/`skyBottom` change nothing in the rasterizer while an environment map lights the scene, which every recipe has, so the trace agrees. `world: false` hides nothing from the trace: a camera ray sees the environment map, where the rasterizer draws a flat background. Light the shadow side with a point or area light or `environmentIntensity`.
Raster against tracer on a daylit interior (#1334, `bench/reference/interior-exposure.mjs`: an 8 x 6.5 m room with one window, physical sky, sun bounce 2, AgX, 960 x 540, GPU tracer, 48 samples, no denoiser). Before #1833 the tracer ignored `effects.exposure`, so the room looked about 3 stops darker than the raster at exposure 3.6. Now both apply it, and the tracer is the brighter one, because it carries the light that bounces around the room and the raster fill is lower (raising `sunBounce` to 8 lifts the raster mean only from 31.9 to 47.6 of 255):