Repository navigation
Clustered light culling for scenes with many lights (ABI 1.21) - #126
Merged
Merged
Conversation
strata_set_light_culling(engine, STRATA_LIGHT_CULLING_CLUSTERED) lets the point and spot light lists hold up to 4096 lights each. Every lit frame the view frustum is cut into 16 x 9 x 24 clusters, the lights reaching each one are listed on the CPU (at most 256 per cluster) and packed into an RGBA32F texture on unit 10, and each lit fragment evaluates only its cluster's list; the same path runs on WebGL 2. StrataLightStats and strata_get_light_stats report the last frame's culling. Off by default, and then every earlier golden is drawn bit for bit. Scene keyword light_culling, golden light_clustered_street_night (a synthetic town, tools/gen_street_lights_scene.py), C# and Python bindings, unit tests and docs/LIGHTING.md. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LYNeunMSrWW3U3RS97BYKD
Taken from CI run 45740342622's golden-out-web artifact (SwiftShader, WebGL 2); it is within 0.15% of the llvmpipe golden. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01LYNeunMSrWW3U3RS97BYKD
dmccoystephenson
force-pushed
the
feat/clustered-lights
branch
from
November 26, 2026 02:16
cb25e30 to
808f44b
Compare
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.
Clustered light culling is added so a scene can hold hundreds or thousands of point and spot lights. ABI minor 20 → 21,
STRATA_ABI_VERSIONstays 1. Culling is off by default, and then every earlier golden is drawn bit for bit (all existing goldens are unchanged).What is added (ABI 1.21)
strata_set_light_culling(engine, STRATA_LIGHT_CULLING_CLUSTERED):strata_set_point_lightsandstrata_set_spot_lightstake up toSTRATA_MAX_CLUSTERED_LIGHTS(4096) each instead of 32. Each lit frame the view frustum is cut into 16 × 9 tiles × 24 depth slices; the lights whose range reaches each cluster are listed on the CPU (at mostSTRATA_MAX_LIGHTS_PER_CLUSTER, 256, brightest kept), packed into an RGBA32F texture on unit 10 (a ring of three, so uploads never wait on a frame in flight), and each lit fragment evaluates only its cluster's list viatexelFetch, so the same path runs on WebGL 2. Shadowed lights still share the four cube maps. Switching back toSTRATA_LIGHT_CULLING_NONEwhile more than 32 lights of a kind are set isSTRATA_ERROR_INVALID_STATE.StrataLightStats+strata_get_light_stats: lights in view, lit clusters, list entries, longest list, overflowed clusters and culling CPU time for the last frame.light_culling none|clustered; strata-golden prints the light stats for clustered scenes; C# and Python bindings with layout tests;tests/unit/test_clusters.cpp; design, limits and timings in docs/LIGHTING.md.Rough llvmpipe numbers from docs/LIGHTING.md (ratios only; shared, busy machine): 32 lamps unculled 250 ms/frame vs 60 ms clustered; 256 lamps clustered 192 ms. Culling CPU time stayed under 1 ms at 1024 lights.
Golden
One new scene,
light_clustered_street_night: a synthetic town at midnight with 240 street lamps and 16 spot lights, written bytools/gen_street_lights_scene.py. It is new, so there is no "before":The
web-swiftshader.pnggolden is taken from this pull request's firstgolden-out-webartifact in a follow-up commit.Testing
Local (Mesa 21 llvmpipe): build, ctest,
strata-golden check(37 scenes; the only failure istex_globe_sun, whose golden is CI-blessed for CI's Mesa and is known to differ on Mesa 21). This builds on the ABI 1.20 materials change (#124), now onmain.drafted by Claude on behalf of Daniel Stephenson
🤖 Generated with Claude Code
https://claude.ai/code/session_01LYNeunMSrWW3U3RS97BYKD