1
1
use bevy:: {
2
2
diagnostic:: { FrameTimeDiagnosticsPlugin , LogDiagnosticsPlugin } ,
3
3
math:: { DVec2 , DVec3 } ,
4
- pbr:: { ExtractedPointLight , GlobalLightMeta } ,
4
+ pbr:: { ClusterConfig , ClusterZConfig , ExtractedPointLight , GlobalLightMeta } ,
5
5
prelude:: * ,
6
6
render:: { camera:: CameraProjection , primitives:: Frustum , RenderApp , RenderStage } ,
7
7
} ;
@@ -70,7 +70,7 @@ fn setup(
70
70
}
71
71
72
72
// camera
73
- match std:: env:: args ( ) . nth ( 1 ) . as_deref ( ) {
73
+ let mut camera = match std:: env:: args ( ) . nth ( 1 ) . as_deref ( ) {
74
74
Some ( "orthographic" ) => {
75
75
let mut orthographic_camera_bundle = OrthographicCameraBundle :: new_3d ( ) ;
76
76
orthographic_camera_bundle. orthographic_projection . scale = 20.0 ;
@@ -88,6 +88,21 @@ fn setup(
88
88
_ => commands. spawn_bundle ( PerspectiveCameraBundle :: default ( ) ) ,
89
89
} ;
90
90
91
+ // NOTE: The lights in this example are distributed primarily in x and y across the
92
+ // screen. Using only 1 z-slice and letting the x,y slicing be calculated
93
+ // automatically produces much better light distribution across the clusters (i.e.
94
+ // fewer maximum lights in any one cluster). The consequences of this versus the
95
+ // default on an M1 Max means going from ~65fps to ~130fps!!!
96
+ camera. insert ( ClusterConfig :: FixedZ {
97
+ total : 4096 ,
98
+ z_slices : 1 ,
99
+ z_config : ClusterZConfig {
100
+ first_slice_depth : 5.0 ,
101
+ far_z_mode : bevy:: pbr:: ClusterFarZMode :: MaxLightRange ,
102
+ } ,
103
+ dynamic_resizing : true ,
104
+ } ) ;
105
+
91
106
// add one cube, the only one with strong handles
92
107
// also serves as a reference point during rotation
93
108
commands. spawn_bundle ( PbrBundle {
0 commit comments