Repository navigation
Occlusion culling (#108) - #346
Open
markwpearce wants to merge 27 commits into
Open
markwpearce wants to merge 27 commits into
markwpearce wants to merge 27 commits into
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…342) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…er (#108) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…#108) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Renderer.updateOcclusion() runs after updateSceneObjects(): it rebuilds the span map only when the camera, projection, canvas, an occluder or an occlusion setting changed, then re-tests each candidate whose verdict is stale. Both draw loops skip an occluded object via markSkippedOccluded(). A screen-aligned billboard is tested by the camera-facing quad directScaled draws, never in the fixed-pixel-size modes; particles are never tested. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- An unfilled rectangle stops contributing, so toggling filled rebuilds the map - A billboard revealed after being hidden re-rasterizes its temp bitmap - No static-BSP warning for a static model occluder - Text is never occluded; AnimatedImage frame size changes invalidate geometry - A culled object isn't an occlusion candidate, so its latch holds - Debug overlay only draws spans while occlusion is active - Direct OcclusionTypes imports, doc comment and docs fixes Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The back gable's three triangles were wound inward and the cross was single-sided, so the chapel only looked right with solidDrawBackFace. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Occluders now take temp-bitmap reuse, the image fast path, model per-face reuse/whole-model stretch and coarse triangle fills like anything else. While an approximate path may run, each occluder polygon is inset by that path's worst error (BGE.Occlusion.insetConvexPolygon); an image on the fast path claims the rectangle it paints, 1px in. A change in inset or quality rebuilds the occlusion map, so the claim grows back when motion stops. Model per-face raster reuse now only happens while moving. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
BGE.OccluderDrawPolicy picks how occluders trade exactness for speed: exact (no fast paths, exact claim), fastShrink (the default: fast paths, claim shrunk by their worst error) or fastExactClaim (fast paths, exact claim). A policy change bumps qualityVersion so cached drawings redraw. Model per-face raster reuse is limited to moving frames only for a fastShrink occluder again; other models reuse on still frames as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
--param profile=1 flies a fixed, frame-indexed camera path past the chapel once per configuration (occlusion off, then each occluder draw policy) at a pinned quality level, and prints and shows the frame times, occluded counts and draw calls for the moving and still segments. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Model faces have outward normals (counter-clockwise from outside, as .obj and .stl files are wound), but isNormalFacingCamera() treated a normal pointing away from the camera as front-facing. So solid/oriented/wireFrame models drew their inside faces, shading was inverted, and occluder panels were gated the wrong way. Models now use their own outward-normal helpers; billboards are unchanged. The occlusion spec cube is wound normally again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
In examples/terrain on a Roku Ultra the pass cost ~19ms per moving frame, which made occlusion a net loss. It's now ~7ms, about break-even there. - Rule objects out before the full test by their depth position: nearer than every span, or not under a nearer span in their band. Only the objects actually behind an occluder get the full test (23 -> 8 a frame). - Camera3d.projectPointsWithDepth() projects points with the same results as worldPointToCanvasPoint()/distanceFromCameraFront(), much cheaper. - Model occluders cache their world-space panels until they move. - Oriented images, rectangles and circles are tested by the worldPoints update() already placed, instead of recomputing them. - Camera3d.getLevelUpVector() is cached by orientation, and a directScaled quad no longer computes the camera vectors twice. This sped up every moving frame in terrain by ~7ms, occlusion or not. - Renderer.getOcclusionMsLastFrame()/getOcclusionTestsLastFrame(), shown by the terrain profile and the occlusion scene benchmark. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
Closes #108
Closes #342
Static drawables can now be marked
isOccluderand hide what's behind them (span map per screen band, conservative test - anything uncertain still draws).isOnScreen()is backed by aBGE.VisibilityStateenum now. Design is inspecs/2026-10-16-occlusion-culling-design.md.Also in here:
Renderer.occluderDrawPolicy-fastShrink(default),exact,fastExactClaimCamera3d.getLevelUpVector()and stopped computing the camera-facing quad twice - ~7ms off every moving frame, occlusion or not--param profile=1runs a scripted profile), rendererTest gets two occlusion benchmarksNumbers (Roku Ultra, ms per moving frame): terrain is about break-even, off 85 vs on 83-85, since what it hides are cheap tree blits. The occlusion-heavy rendererTest scene is a real win, ~120 on vs 129-135 off.
Things to decide / known issues:
exactshould stop it, at a cost. Is the default policy right, or should it befastExactClaimfor the extra speed?🤖 Generated with Claude Code