Repository navigation
fix(forest): cull and LOD chunks by their own box, grow boxes over instances, far dock and string lights - #514
Merged
Merged
Conversation
…stances, far dock and string lights
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 #512.
What it does
After #512 the Barbara dock could still vanish or switch LOD at the wrong distance. Each forest chunk was culled and LOD-switched from its cell centre, and its box ignored the instanced trees and props that stick out of it. Now each chunk is culled by its own box. The far LOD also draws the dock and the camp string lights, so they don't disappear when the camera pulls back.
How it works
bakedBoxcovers only the baked geometry.boxisbakedBoxgrown to cover every instance's template extent.boxdrives only the frustum test, so a tree leaning into view is never culled.bakedBoxdrives the near/far switch, out-of-view retention and torch-caster reach. These use XZ distance to the box rather than to the cell centre, so the terrain near ring stays at 70 m. Instance LOD still uses cell distance.boxDistanceXZ,nearStatic,boxInFrustum) live in the newpackages/kit/forest/cull.ts.Risk
The change is limited to the forest renderer in
packages/kit/forest. Barbara is the only game that uses it. Growing the boxes keeps a few more chunks in view, which adds triangles but no measurable GPU time (table below). If a box were wrong, chunks would pop at the screen edge or the near/far switch would move.At night, the dock still can't be seen from across the lake (70–100 m away), before or after this change. At that distance the deck is only a few pixels tall and nearly unlit. A test checks that the far mesh contains the deck, so it's covered even where a screenshot can't show it.
Proof
GPU frame time on the Mac mini at High quality, 5 alternating rounds, without → with instance extents (noise is about ±1 ms):
campEastzoom, before (left) and after (right): before, only the glows showed; now the bulbs are drawn too.bun run verify: 49 steps passtests/forest-cull.test.ts2/2 (the dock is kept in view from mid range, near/far uses box distance, the far mesh contains the deck)