Make IrradianceVolume
require LightProbe
(and document this). (#19621)
## Objective Make it easier to use `IrradianceVolume` with fewer ways to silently fail. Fix #19614. ## Solution * Add `#[require(LightProbe)]` to `struct IrradianceVolume`. * Document this fact. * Also document the volume being centered on the origin by default (this was the other thing that was unclear when getting started). I also looked at the other implementor of `LightProbeComponent`, `EnvironmentMapLight`, but it has a use which is *not* as a light probe, so it should not require `LightProbe`. ## Testing * Confirmed that `examples/3d/irradiance_volumes.rs` still works after removing `LightProbe`. * Reviewed generated documentation.
This commit is contained in:
parent
8203e5c4e0
commit
ce3db843bc
@ -17,11 +17,12 @@
|
|||||||
//! documentation in the `bevy-baked-gi` project for more details on this
|
//! documentation in the `bevy-baked-gi` project for more details on this
|
||||||
//! workflow.
|
//! workflow.
|
||||||
//!
|
//!
|
||||||
//! Like all light probes in Bevy, irradiance volumes are 1×1×1 cubes that can
|
//! Like all light probes in Bevy, irradiance volumes are 1×1×1 cubes, centered
|
||||||
//! be arbitrarily scaled, rotated, and positioned in a scene with the
|
//! on the origin, that can be arbitrarily scaled, rotated, and positioned in a
|
||||||
//! [`bevy_transform::components::Transform`] component. The 3D voxel grid will
|
//! scene with the [`bevy_transform::components::Transform`] component. The 3D
|
||||||
//! be stretched to fill the interior of the cube, and the illumination from the
|
//! voxel grid will be stretched to fill the interior of the cube, with linear
|
||||||
//! irradiance volume will apply to all fragments within that bounding region.
|
//! interpolation, and the illumination from the irradiance volume will apply to
|
||||||
|
//! all fragments within that bounding region.
|
||||||
//!
|
//!
|
||||||
//! Bevy's irradiance volumes are based on Valve's [*ambient cubes*] as used in
|
//! Bevy's irradiance volumes are based on Valve's [*ambient cubes*] as used in
|
||||||
//! *Half-Life 2* ([Mitchell 2006, slide 27]). These encode a single color of
|
//! *Half-Life 2* ([Mitchell 2006, slide 27]). These encode a single color of
|
||||||
@ -154,7 +155,7 @@ use crate::{
|
|||||||
MAX_VIEW_LIGHT_PROBES,
|
MAX_VIEW_LIGHT_PROBES,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::LightProbeComponent;
|
use super::{LightProbe, LightProbeComponent};
|
||||||
|
|
||||||
/// On WebGL and WebGPU, we must disable irradiance volumes, as otherwise we can
|
/// On WebGL and WebGPU, we must disable irradiance volumes, as otherwise we can
|
||||||
/// overflow the number of texture bindings when deferred rendering is in use
|
/// overflow the number of texture bindings when deferred rendering is in use
|
||||||
@ -164,8 +165,12 @@ pub(crate) const IRRADIANCE_VOLUMES_ARE_USABLE: bool = cfg!(not(target_arch = "w
|
|||||||
/// The component that defines an irradiance volume.
|
/// The component that defines an irradiance volume.
|
||||||
///
|
///
|
||||||
/// See [`crate::irradiance_volume`] for detailed information.
|
/// See [`crate::irradiance_volume`] for detailed information.
|
||||||
|
///
|
||||||
|
/// This component requires the [`LightProbe`] component, and is typically used with
|
||||||
|
/// [`bevy_transform::components::Transform`] to place the volume appropriately.
|
||||||
#[derive(Clone, Reflect, Component, Debug)]
|
#[derive(Clone, Reflect, Component, Debug)]
|
||||||
#[reflect(Component, Default, Debug, Clone)]
|
#[reflect(Component, Default, Debug, Clone)]
|
||||||
|
#[require(LightProbe)]
|
||||||
pub struct IrradianceVolume {
|
pub struct IrradianceVolume {
|
||||||
/// The 3D texture that represents the ambient cubes, encoded in the format
|
/// The 3D texture that represents the ambient cubes, encoded in the format
|
||||||
/// described in [`crate::irradiance_volume`].
|
/// described in [`crate::irradiance_volume`].
|
||||||
|
@ -251,7 +251,6 @@ fn spawn_irradiance_volume(commands: &mut Commands, assets: &ExampleAssets) {
|
|||||||
intensity: IRRADIANCE_VOLUME_INTENSITY,
|
intensity: IRRADIANCE_VOLUME_INTENSITY,
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
LightProbe,
|
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user