Repository navigation
Viewer perf: occlusion culling, high tier without AO pre-pass, readable highlights - #1228
Merged
Merged
Conversation
Each time the eye moves, the building's opaque walls, slabs, roofs and ceilings are rasterized on the CPU into a 256-px depth image; every drawn mesh (static-merge batches and the meshes left individual) whose box lies wholly behind it is skipped for that render through three's drawing pipeline (`isCulled`). A level's floor hides the levels under it, a facade the rooms behind it. - Same-frame and conservative: no readback lag, occluder image eroded by a pixel, boxes dilated, anything crossing the near plane drawn. - Only renders through the main camera are culled: the sun's cached shadow map and captures still see everything. - Recomputed when the camera moves (1.5-3.5 ms), otherwise only when the scene changes. Shows as `occlusion-cull` in `?perf`; `?occlusion=0` draws everything. Measured (M5 Max headless, same session A/B): rn9 overview 26 -> 32 fps (3229 -> 2302 draws), hav5 overview 38 -> 50 fps (capped; 1829 -> 1049 draws); renders identical. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The high tier fed GTAO from a depth/normal/velocity pre-pass so AO darkened indirect light only (the enhanced viewer's `gtao-indirect`). The pre-pass draws the whole scene a second time: on an editor scene of thousands of meshes it doubled every draw (7873 vs 3994 on a 5-level house) and the encode cost with it. High now uses medium's path at full resolution: GTAO from the scene pass's depth and normals, blended softly over the whole image. The daylight room context loses its unused AO input. Measured (M5 Max headless, editor, high): 40 -> 46 fps, encode 22.8 -> 12.0 ms, draws 7873 -> 3994. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The selection, hover and delete highlights tint the object with a soft indigo emissive. Under a night exposure that crossed the bloom threshold and hazed over the selected item, killing its readability. Highlight materials are now marked `noBloom`; the scene pass's lighting mask carries a bloom weight (G channel, 0 for those materials) and the bloom input is weighted by it. The highlight itself is unchanged. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The selection highlight was meant to be a soft indigo emissive (0.4 x 0.12) but ran at full strength: its intensity was max(material's, 0.12), and a material's default intensity is 1. At night it got worse twice over: the daylight hooks treated the tinted clone as a glowing surface (night boost, exposure lift), and on lamp items the lamp system swapped it for a lamp emitter at full display brightness. A selected fan lit up like a bulb. - `tintEmissive` folds the intensity into the colour: the material's own glow plus the tint at its own strength (selection 0.12, wall hover 0.08, delete unchanged at 0.92). - `markHighlight` (replaces `markNoBloom`) flags the clone: kept out of the bloom, the night emitter boost and the lamp emitters, and its emission divided by the metered exposure so it reads the same at any time of day. It gets its own program cache key (three's ignores userData, so the clone otherwise reused its source's program and the hooks never saw it). Co-Authored-By: Claude Opus 5.5 <[email protected]>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit e07a566. Configure here.
| if (!mesh.geometry.boundingBox) mesh.geometry.computeBoundingBox() | ||
| if (!mesh.geometry.boundingSphere) mesh.geometry.computeBoundingSphere() | ||
| occludees.push(mesh) | ||
| }) |
There was a problem hiding this comment.
Instanced meshes culled from local bounds
Medium Severity
list() skips skinned meshes but still treats InstancedMesh as a normal mesh. Culling then tests geometry.boundingBox transformed by matrixWorld, ignoring per-instance matrices. If that local box sits behind an occluder, every instance is skipped even when copies are visible elsewhere.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit e07a566. Configure here.
Merged
3 tasks done
wass08
added a commit
that referenced
this pull request
Nov 6, 2026
…ottosson/performance) (#1232) * Viewer CPU: one scene walk per frame, nested node batching - scene-matrices: one dirty-tracked matrix update per frame instead of three's full update in every pass; subtrees nothing in the frame draws (batched originals, a soloed level's shadow-only content) are hidden for the render only and skipped by the walk while the layout revision holds. - Node batching reaches nodes nested under hosts (cabinet modules, items on items, wall/ceiling-hosted items); a host's edits, gestures and tint release what it carries. Cabinets, cabinet modules and shelves opt in. - Solo re-hide, shadow bounds and fences no longer walk the scene every frame. Waterfront 41-49 -> ~16 ms frame CPU, apartment 29 -> ~15 ms (dev build, RTX 3060 Ti, High tier). Co-Authored-By: Claude Opus 5.5 <[email protected]> * Viewer CPU: unsorted item batches, cloud-free fog, shared level arrays - Item batches skip the per-pass depth sort (opaque; the prepass lays depth). - Fog samples a cloud-free horizon radiance: the clouds fade out at the fog's elevation, so the two fbm calls per fragment and cloudTime (which moved every frame) drop out of every fogged material. - The room light's level arrays move to a shared uniform group bumped only when a level moves: as per-object array uniforms they were re-uploaded for every object in every pass (~760 writeBuffer a frame in the apartment, now 1). Co-Authored-By: Claude Opus 5.5 <[email protected]> * Port fixes: culler sees set-aside occluders; item batches keep their sort - The occlusion culler (#1228) runs inside the render, where `renderWithSceneMatrices` hides subtrees nothing draws: the merged originals it rasterizes as walls and slabs. They count as shown again (`isSetAsideForRender`), as the merged outline already does; test added. - Item batches keep three's front-to-back sort: `sortObjects = false` was justified by the depth pre-pass, which #1228 removed, and on a GPU-bound editor the overdraw costs more than the sort saves. Co-Authored-By: Claude Opus 5.5 <[email protected]> * Moving an item: stays on its level, no floating, no rebuild storms Moving an item (e.g. a bedside carrying a lamp) hitched for seconds and could hop floors: - Placement: hovering another floor's furniture, slab, wall, ceiling or roof (past the building edge, through a window) re-parented the item to that floor mid-gesture. With a level selected, the move tool now ignores surfaces on other levels; the floor cursor keeps following the selected one. - Leaving a host back to the floor kept the surface move's live transform, a building-space cursor (the host's top, level height included), which the remounted item read level-local: a bedside left on a 4th-floor bed floated ~10 m up until the next floor move. The detach publishes the floor pose. - Daylight rooms rebuilt (thousands of rays, ~1.6 s) on every scene edit; furniture edits and child-list-only changes no longer trigger it (a moved lamp still does, through its light's position). - The live stair/elevator opening systems replanned on a level's child list changing; they now ignore child lists, as the document reconcile already does. - Node batching cascaded releases from any dirty node, including a level whose child list changed: the whole floor's batches were released and rejoined. Levels, buildings and sites no longer cascade (also fixes two history tests that expected only a wall's own openings to release). Measured on a 5-level condo, moving a bedside with an item on top across the screen: worst frame 2.3 s -> 0.5-0.85 s, no level hops, correct height. Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: bottosson <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
2 of 4 tasks
This was referenced Nov 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Follow-up to #1224.
Occlusion culling for baked scenes
Each time the camera moves, the building's opaque walls, slabs, roofs and ceilings are rasterized on the CPU into a 256-px depth image. Every drawn mesh (static-merge batches and the meshes left individual) whose box lies wholly behind it is skipped for that render through three's drawing pipeline (
isCulled).occlusion-cullin?perf;?occlusion=0draws everything.High tier: GTAO from the scene pass
The enhanced viewer's high tier fed GTAO from a depth/normal/velocity pre-pass, which draws the whole scene a second time. On an editor scene that doubled every draw. High now uses medium's path at full resolution.
Editor highlights stay readable
max(material's, 0.12), and a material's default is 1.tintEmissivefolds the strength into the colour (selection 0.12, wall hover 0.08, delete unchanged).markHighlightflags highlight materials: kept out of all of that, with exposure-compensated emission so the tint reads the same day and night, and its own program cache key (three's ignoresuserData).Test plan
check-types, viewer tests (1345), nodes tests, editor component tests, biome🤖 Generated with Claude Code
Note
Medium Risk
Adds a custom occlusion culler hook and reworks GTAO/daylight lighting paths, so GPU/CPU rendering behavior could regress if culling or AO math misclassifies geometry.
Overview
perf(viewer): occlusion culling, GTAO rework, highlight fixes
Introduces a conservative CPU occlusion culler for baked GLB scenes that rasterizes major shells into a tiny depth buffer and plugs into
renderer.drawingPipeline.isCulled, toggleable with?occlusion=0, rebuilding whenever static merges update. High-quality ambient occlusion now shares the single scene-pass medium-tier path at full resolution (drops the extra pre-pass), rewires daylight room lighting to match, and keeps temporal buffers consistent.Adds an
editor-highlighttoolkit (markHighlight,tintEmissive) so selection clones keep stable tint strength, bespoke program keys, and skip daylight emitter/bloom boosts; wall highlights adopt the same behavior. Bloom now masks highlighted pixels via the lighting MRT channel, room emitters ignore highlight clones, and Bun tests cover the new helpers plus the occlusion module.Risk: Medium — touches WebGPU post-processing, daylight lighting hooks, and a new render-time culling path that could mis-hide meshes if assumptions break.
Reviewed by Cursor Bugbot for commit e07a566. Bugbot is set up for automated code reviews on this repo. Configure here.