Skip to content

Commit ea69012

Browse files
jf908superdump
andauthored
Small docs PR for PointLightShadowMap/DirectionalLightShadowMap (#18768)
# Objective - Improve the docs for `PointLightShadowMap` and `DirectionalLightShadowMap` ## Solution - Add example for how to use `PointLightShadowMap` and move the `DirectionalLightShadowMap` example from `DirectionalLight`. - Match `PointLight` and `DirectionalLight` docs about shadows. - Describe what `size` means. --------- Co-authored-by: Robert Swain <[email protected]>
1 parent ee7b624 commit ea69012

File tree

3 files changed

+29
-8
lines changed

3 files changed

+29
-8
lines changed

crates/bevy_pbr/src/light/directional_light.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,7 @@ use super::*;
4141
/// To modify the cascade setup, such as the number of cascades or the maximum shadow distance,
4242
/// change the [`CascadeShadowConfig`] component of the entity with the [`DirectionalLight`].
4343
///
44-
/// To control the resolution of the shadow maps, use the [`DirectionalLightShadowMap`] resource:
45-
///
46-
/// ```
47-
/// # use bevy_app::prelude::*;
48-
/// # use bevy_pbr::DirectionalLightShadowMap;
49-
/// App::new()
50-
/// .insert_resource(DirectionalLightShadowMap { size: 2048 });
51-
/// ```
44+
/// To control the resolution of the shadow maps, use the [`DirectionalLightShadowMap`] resource.
5245
#[derive(Component, Debug, Clone, Reflect)]
5346
#[reflect(Component, Default, Debug, Clone)]
5447
#[require(

crates/bevy_pbr/src/light/mod.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,21 @@ pub mod light_consts {
9191
}
9292
}
9393

94+
/// Controls the resolution of [`PointLight`] shadow maps.
95+
///
96+
/// ```
97+
/// # use bevy_app::prelude::*;
98+
/// # use bevy_pbr::PointLightShadowMap;
99+
/// App::new()
100+
/// .insert_resource(PointLightShadowMap { size: 2048 });
101+
/// ```
94102
#[derive(Resource, Clone, Debug, Reflect)]
95103
#[reflect(Resource, Debug, Default, Clone)]
96104
pub struct PointLightShadowMap {
105+
/// The width and height of each of the 6 faces of the cubemap.
106+
107+
///
108+
/// Defaults to `1024`.
97109
pub size: usize,
98110
}
99111

@@ -108,9 +120,19 @@ impl Default for PointLightShadowMap {
108120
pub type WithLight = Or<(With<PointLight>, With<SpotLight>, With<DirectionalLight>)>;
109121

110122
/// Controls the resolution of [`DirectionalLight`] shadow maps.
123+
///
124+
/// ```
125+
/// # use bevy_app::prelude::*;
126+
/// # use bevy_pbr::DirectionalLightShadowMap;
127+
/// App::new()
128+
/// .insert_resource(DirectionalLightShadowMap { size: 4096 });
129+
/// ```
111130
#[derive(Resource, Clone, Debug, Reflect)]
112131
#[reflect(Resource, Debug, Default, Clone)]
113132
pub struct DirectionalLightShadowMap {
133+
// The width and height of each cascade.
134+
///
135+
/// Defaults to `2048`.
114136
pub size: usize,
115137
}
116138

crates/bevy_pbr/src/light/point_light.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ use super::*;
1919
/// | 4000 | 300 | | 75-100 | 40.5 |
2020
///
2121
/// Source: [Wikipedia](https://en.wikipedia.org/wiki/Lumen_(unit)#Lighting)
22+
///
23+
/// ## Shadows
24+
///
25+
/// To enable shadows, set the `shadows_enabled` property to `true`.
26+
///
27+
/// To control the resolution of the shadow maps, use the [`PointLightShadowMap`] resource.
2228
#[derive(Component, Debug, Clone, Copy, Reflect)]
2329
#[reflect(Component, Default, Debug, Clone)]
2430
#[require(

0 commit comments

Comments
 (0)