Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WorldClusters allocation is now dynamic, removed from composition update #5569

Merged
merged 4 commits into from Aug 17, 2023

Conversation

mvaligursky
Copy link
Contributor

@mvaligursky mvaligursky commented Aug 16, 2023

Refactoring to limit the amount of LayerComposition updates.

Before: When a light was added / removed from the layer, the expensive composition update would execute. Part of the update was to assign world clusters (textures storing clustered lights) to individual layers based on their lights.

Now: The world clusters assignment takes place at the start of the frame. The layers lazily update their light hash values and world clusters are shared between layers based on this hash.

The is still a cost of computing a hash for a layer on frames lights are added / removed on it - but this is reasonably cheap.
Note that this is needed specifically for WebGL1 path, on other platforms we could use bitflag to encode layers and reject lights from a single clusters structure at runtime. One day.

Note that the composition still updates when lights are added / removed, and further refactoring is needed, this PR only addresses the clustered part of it.

@mvaligursky mvaligursky self-assigned this Aug 16, 2023
@mvaligursky mvaligursky marked this pull request as draft August 16, 2023 20:22
@mvaligursky mvaligursky added the area: graphics Graphics related issue label Aug 17, 2023
@mvaligursky mvaligursky marked this pull request as ready for review August 17, 2023 09:24
src/scene/layer.js Outdated Show resolved Hide resolved
@mvaligursky mvaligursky merged commit 1cde179 into main Aug 17, 2023
7 checks passed
@mvaligursky mvaligursky deleted the mv-worldcluster-update branch August 17, 2023 09:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: graphics Graphics related issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants