3D engine that AI agents drive
Merge remote-tracking branch 'origin/main' into feat/outdoor-shadow-fill
Nguyen Xuan An020bd9bf6dc2
diff --cc .gitignoreindex 79f3ca5f,b18a8380..37eef5cf--- a/.gitignore+++ b/.gitignore@@@ -61,4 -61,6 +61,7 @@@ public/gaussian-splats.m# Optional denoiser binaries fetched by packages/denoise-oidn/fetch-oidn.mjspackages/denoise-oidn/vendor/++ # Renders and previews that are not part of the package+ out/+__pycache__/diff --cc docs/lighting.mdindex cc5029c7,dd1e9c22..0ad979f4--- a/docs/lighting.md+++ b/docs/lighting.md@@@ -126,23 -128,12 +128,27 @@@ Luminance of the 67js picture over Cycl| `brick-room` | 0.57 | 0.86 | 0.37 | 0.95 || `temple-hall` | 0.97 | 0.97 | 1.62 | 1.64 |-The two `temple-hall` p20 values differ only by the rescaling of the picture (the scene has a sun, so no bounce is added). The outdoor shadow fill of the issue is not done.+The two `temple-hall` p20 values differ only by the rescaling of the picture (the scene has a sun, so no bounce is added).++## Sun shadows fill under a low sun++A scene with a sun that is not a closed room or a bake gets one more constant diffuse light under a low sun, the same `bounce` colour the room uses, so it costs nothing per frame and changes no shader. Slopes, walls and roofs that face a low sun send its light back into the shadows, and the ground term does not see them (`mountain-valley` has no level ground at all). The fill is `0.4 * albedo * sun colour / pi * (wall - ground)^2`, where `ground` is the sun's vertical share on a level surface, `wall` its horizontal share on a vertical one and `albedo` the floor's (at least 0.2). A high sun gives zero, so the studio scenes and `long-street` are unchanged, and so are `temple-hall` and `dark-shaft`. `environment.outdoorFill: false` turns it off.++Measured on SwiftShader against the committed Cycles panels (960 x 540 picture scaled to the panel, FLIP of the panel pair):++| Scene | Mean before | Mean after | p20 before | p20 after | FLIP before | FLIP after |+| --- | --- | --- | --- | --- | --- | --- |+| `mountain-valley` | 0.90 | 0.99 | 0.60 | 0.79 | 0.1699 | 0.1259 |+| `megacity-dusk` | 0.93 | 0.97 | 0.59 | 0.85 | 0.1686 | 0.1431 |+| `fog-valley` | 1.07 | 1.09 | 0.86 | 0.92 | 0.1906 | 0.1810 |+| `temple-hall`, `dark-shaft` | | | | unchanged | | unchanged |++The other 19 reference scenes drew the same pixels (mean, p20 and FLIP identical).+ ## Sky seen from the floor++ `applyFloorSkyVisibility(parts, { strength, includeClosedRooms })` (`67js/addons/floor-sky-visibility`) is opt-in and returns `{ parts, report }`. It cuts the floor parts into texels, shoots 64 cosine-weighted rays from each against the other opaque parts and stores the share that escapes as the floor's `skyVisibility`, so the world and sky light on a floor under a roof or between walls is scaled down and open ground is not. Pass the returned parts to the renderer. `strength` 1 uses the traced share, 0.5 keeps half of what it hides. A closed room is left alone unless `includeClosedRooms` is `true`, and a scene that is too large (over 200,000 triangles), has no floor or runs past `maxSeconds` (20) comes back unchanged with `report.reason`. It is not on by default: it moves the dark end of halls and studio floors toward Cycles, and makes sunlit streets too dark (`long-street` +0.0135 FLIP at 0.5). The trace takes 0.5 to 1.7 s, and the floor grows to about 66,000 triangles, which adds 0.1 to 0.3 ms per frame in the reference scenes. Numbers: `bench/reference/README.md`, "Sky visibility traced from the floor texels".+## Local shadows`castShadow: true` on a point or spot light draws that light's depth into one shared atlas of 2048 x 3072 texels: 24 tiles of 512 x 512, a 24 MiB depth texture allocated on first use. A spot light takes one tile with a perspective view of `2 * angle + 4` degrees (170 at most). A point light takes six tiles, one per cube face, each 92 degrees wide. Lights are given tiles in order: point lights, then spot lights. A request for more than 24 tiles, for example five shadowed point lights, throws `RangeError` and changes nothing. So the most is four shadowed point lights, or for example two point lights and eight spot lights.