bevy/crates/bevy_pbr/src
robtfm 244687a0bb Dynamic light clusters (#3968)
# Objective

provide some customisation for default cluster setup
avoid "cluster index lists is full" in all cases (using a strategy outlined by @superdump)

## Solution

Add ClusterConfig enum (which can be inserted into a view at any time) to allow specifying cluster setup with variants:
- None (do not do any light assignment - for views which do not require light info, e.g. minimaps etc)
- Single (one cluster)
- XYZ (explicit cluster counts in each dimension)
- FixedZ (most similar to current - specify Z-slices and total, then x and y counts are dynamically determined to give approximately square clusters based on current aspect ratio)
Defaults to FixedZ { total: 4096, z: 24 } which is similar to the current setup.

Per frame, estimate the number of indices that would be required for the current config and decrease the cluster counts / increase the cluster sizes in the x and y dimensions if the index list would be too small.

notes:

- I didn't put ClusterConfig in the camera bundles to avoid introducing a dependency from bevy_render to bevy_pbr. the ClusterConfig enum comes with a pbr-centric impl block so i didn't want to move that into bevy_render either.
- ~Might want to add None variant to cluster config for views that don't care about lights?~
- Not well tested for orthographic
- ~there's a cluster_muck branch on my repo which includes some diagnostics / a modified lighting example which may be useful for tyre-kicking~ (outdated, i will bring it up to date if required)

anecdotal timings:

FPS on the lighting demo is negligibly better (~5%), maybe due to a small optimisation constraining the light aabb to be in front of the camera
FPS on the lighting demo with 100 extra lights added is ~33% faster, and also renders correctly as the cluster index count is no longer exceeded
2022-03-08 04:56:42 +00:00
..
render Dynamic light clusters (#3968) 2022-03-08 04:56:42 +00:00
alpha.rs Replace old renderer with new renderer (#3312) 2021-12-14 03:58:23 +00:00
bundle.rs add Visibility for lights (#3958) 2022-03-05 03:23:01 +00:00
lib.rs Dynamic light clusters (#3968) 2022-03-08 04:56:42 +00:00
light.rs Dynamic light clusters (#3968) 2022-03-08 04:56:42 +00:00
material.rs Make get_resource (and friends) infallible (#4047) 2022-02-27 22:37:18 +00:00
pbr_material.rs StandardMaterial: expose a cull_mode option (#3982) 2022-03-05 03:37:23 +00:00
wireframe.rs Make get_resource (and friends) infallible (#4047) 2022-02-27 22:37:18 +00:00