Implement per-kind light budgeting with device capability limits - #2238
Merged
4ian merged 1 commit intoAug 23, 2026
Conversation
- Evict lights that no longer fit the moment the device budget is shared with a new light kind, so a frame never renders over the budget. - Read the renderer on every budget recomputation instead of capturing it once, so a scene created before the renderer exists is not stuck on the guaranteed minimums. - Say in the max lights count descriptions that the caps are per light kind and that devices can enforce a lower limit. - Drop a stale mention of distance inflation for ties in insertByDistance. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GX7gMRj2UUgEFkBV4vpajs
4ian
changed the base branch from
main
to
claude/threejs-gdevelop-lighting-3h4nka
August 23, 2026 15:26
4ian
merged commit Aug 23, 2026
1a84312
into
claude/threejs-gdevelop-lighting-3h4nka
5 checks passed
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.
Summary
This PR refactors the 3D light management system to budget lights separately by kind (point lights, spot lights, spot lights with projected textures) and enforce device-specific hardware limits. This prevents shader compilation failures when exceeding device capabilities.
Key Changes
Device Budget Computation: Added
computeDeviceLightBudget()function that calculates per-device limits based on WebGL capabilities (texture units, varyings, uniform vectors) rather than using fixed limits.Per-Kind Light Budgeting: Refactored
LightManagerto maintain separate visible and shadow light lists for each light kind, allowing the budget to be shared intelligently across kinds while keeping individual kind counts stable for shader compilation.Capacity Capping: Introduced
makeDeviceCappedCapacity()to create capacities that respect both game-requested maximums and device limits, with dynamic getters to handle runtime changes.Improved CappedLightList:
__cameraDistanceproperty from light objects (now stored in list entries)trimToCapacity()methodLight Kind Detection: Added
LightManager.getLightKind()to distinguish between point lights, spot lights, and spot lights with projected textures, since three.js compiles these separately into shaders.Logging: Added logger for informing users when device limits are lower than requested.
Documentation: Updated parameter descriptions to clarify that light counts are per-kind and subject to device limits.
Notable Implementation Details
https://claude.ai/code/session_01GX7gMRj2UUgEFkBV4vpajs