Move IrradianceVolume to bevy_light (#20000)
# Objective - Reunite it with its family ## Solution - Immigration ## Testing - irradiance_volumes example
This commit is contained in:
parent
e2810085a8
commit
75f49bd335
@ -27,7 +27,7 @@ use cluster::{
|
|||||||
mod ambient_light;
|
mod ambient_light;
|
||||||
pub use ambient_light::AmbientLight;
|
pub use ambient_light::AmbientLight;
|
||||||
mod probe;
|
mod probe;
|
||||||
pub use probe::{EnvironmentMapLight, LightProbe};
|
pub use probe::{EnvironmentMapLight, IrradianceVolume, LightProbe};
|
||||||
mod volumetric;
|
mod volumetric;
|
||||||
pub use volumetric::{FogVolume, VolumetricFog, VolumetricLight};
|
pub use volumetric::{FogVolume, VolumetricFog, VolumetricLight};
|
||||||
pub mod cascade;
|
pub mod cascade;
|
||||||
@ -121,6 +121,7 @@ impl Plugin for LightPlugin {
|
|||||||
.register_type::<PointLight>()
|
.register_type::<PointLight>()
|
||||||
.register_type::<LightProbe>()
|
.register_type::<LightProbe>()
|
||||||
.register_type::<EnvironmentMapLight>()
|
.register_type::<EnvironmentMapLight>()
|
||||||
|
.register_type::<IrradianceVolume>()
|
||||||
.register_type::<VolumetricFog>()
|
.register_type::<VolumetricFog>()
|
||||||
.register_type::<VolumetricLight>()
|
.register_type::<VolumetricLight>()
|
||||||
.register_type::<PointLightShadowMap>()
|
.register_type::<PointLightShadowMap>()
|
||||||
|
|||||||
@ -107,3 +107,50 @@ impl Default for EnvironmentMapLight {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The component that defines an irradiance volume.
|
||||||
|
///
|
||||||
|
/// See `bevy_pbr::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)]
|
||||||
|
#[reflect(Component, Default, Debug, Clone)]
|
||||||
|
#[require(LightProbe)]
|
||||||
|
pub struct IrradianceVolume {
|
||||||
|
/// The 3D texture that represents the ambient cubes, encoded in the format
|
||||||
|
/// described in `bevy_pbr::irradiance_volume`.
|
||||||
|
pub voxels: Handle<Image>,
|
||||||
|
|
||||||
|
/// Scale factor applied to the diffuse and specular light generated by this component.
|
||||||
|
///
|
||||||
|
/// After applying this multiplier, the resulting values should
|
||||||
|
/// be in units of [cd/m^2](https://en.wikipedia.org/wiki/Candela_per_square_metre).
|
||||||
|
///
|
||||||
|
/// See also <https://google.github.io/filament/Filament.html#lighting/imagebasedlights/iblunit>.
|
||||||
|
pub intensity: f32,
|
||||||
|
|
||||||
|
/// Whether the light from this irradiance volume has an effect on meshes
|
||||||
|
/// with lightmaps.
|
||||||
|
///
|
||||||
|
/// Set this to false if your lightmap baking tool bakes the light from this
|
||||||
|
/// irradiance volume into the lightmaps in order to avoid counting the
|
||||||
|
/// irradiance twice. Frequently, applications use irradiance volumes as a
|
||||||
|
/// lower-quality alternative to lightmaps for capturing indirect
|
||||||
|
/// illumination on dynamic objects, and such applications will want to set
|
||||||
|
/// this value to false.
|
||||||
|
///
|
||||||
|
/// By default, this is set to true.
|
||||||
|
pub affects_lightmapped_meshes: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for IrradianceVolume {
|
||||||
|
#[inline]
|
||||||
|
fn default() -> Self {
|
||||||
|
IrradianceVolume {
|
||||||
|
voxels: Handle::default(),
|
||||||
|
intensity: 0.0,
|
||||||
|
affects_lightmapped_meshes: true,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -51,9 +51,9 @@ use bevy_light::SimulationLightSystems;
|
|||||||
pub use bevy_light::{
|
pub use bevy_light::{
|
||||||
light_consts, AmbientLight, CascadeShadowConfig, CascadeShadowConfigBuilder, Cascades,
|
light_consts, AmbientLight, CascadeShadowConfig, CascadeShadowConfigBuilder, Cascades,
|
||||||
ClusteredDecal, DirectionalLight, DirectionalLightShadowMap, DirectionalLightTexture,
|
ClusteredDecal, DirectionalLight, DirectionalLightShadowMap, DirectionalLightTexture,
|
||||||
FogVolume, LightPlugin, LightProbe, NotShadowCaster, NotShadowReceiver, PointLight,
|
FogVolume, IrradianceVolume, LightPlugin, LightProbe, NotShadowCaster, NotShadowReceiver,
|
||||||
PointLightShadowMap, PointLightTexture, ShadowFilteringMethod, SpotLight, SpotLightTexture,
|
PointLight, PointLightShadowMap, PointLightTexture, ShadowFilteringMethod, SpotLight,
|
||||||
TransmittedShadowReceiver, VolumetricFog, VolumetricLight,
|
SpotLightTexture, TransmittedShadowReceiver, VolumetricFog, VolumetricLight,
|
||||||
};
|
};
|
||||||
pub use cluster::*;
|
pub use cluster::*;
|
||||||
pub use components::*;
|
pub use components::*;
|
||||||
|
|||||||
@ -133,9 +133,8 @@
|
|||||||
//!
|
//!
|
||||||
//! [Why ambient cubes?]: #why-ambient-cubes
|
//! [Why ambient cubes?]: #why-ambient-cubes
|
||||||
|
|
||||||
use bevy_ecs::{component::Component, reflect::ReflectComponent};
|
|
||||||
use bevy_image::Image;
|
use bevy_image::Image;
|
||||||
use bevy_light::LightProbe;
|
pub use bevy_light::IrradianceVolume;
|
||||||
use bevy_render::{
|
use bevy_render::{
|
||||||
render_asset::RenderAssets,
|
render_asset::RenderAssets,
|
||||||
render_resource::{
|
render_resource::{
|
||||||
@ -145,11 +144,9 @@ use bevy_render::{
|
|||||||
renderer::{RenderAdapter, RenderDevice},
|
renderer::{RenderAdapter, RenderDevice},
|
||||||
texture::{FallbackImage, GpuImage},
|
texture::{FallbackImage, GpuImage},
|
||||||
};
|
};
|
||||||
use bevy_utils::default;
|
|
||||||
use core::{num::NonZero, ops::Deref};
|
use core::{num::NonZero, ops::Deref};
|
||||||
|
|
||||||
use bevy_asset::{AssetId, Handle};
|
use bevy_asset::AssetId;
|
||||||
use bevy_reflect::{std_traits::ReflectDefault, Reflect};
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
add_cubemap_texture_view, binding_arrays_are_usable, RenderViewLightProbes,
|
add_cubemap_texture_view, binding_arrays_are_usable, RenderViewLightProbes,
|
||||||
@ -163,53 +160,6 @@ use super::LightProbeComponent;
|
|||||||
/// (see issue #11885).
|
/// (see issue #11885).
|
||||||
pub(crate) const IRRADIANCE_VOLUMES_ARE_USABLE: bool = cfg!(not(target_arch = "wasm32"));
|
pub(crate) const IRRADIANCE_VOLUMES_ARE_USABLE: bool = cfg!(not(target_arch = "wasm32"));
|
||||||
|
|
||||||
/// The component that defines an irradiance volume.
|
|
||||||
///
|
|
||||||
/// 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)]
|
|
||||||
#[reflect(Component, Default, Debug, Clone)]
|
|
||||||
#[require(LightProbe)]
|
|
||||||
pub struct IrradianceVolume {
|
|
||||||
/// The 3D texture that represents the ambient cubes, encoded in the format
|
|
||||||
/// described in [`crate::irradiance_volume`].
|
|
||||||
pub voxels: Handle<Image>,
|
|
||||||
|
|
||||||
/// Scale factor applied to the diffuse and specular light generated by this component.
|
|
||||||
///
|
|
||||||
/// After applying this multiplier, the resulting values should
|
|
||||||
/// be in units of [cd/m^2](https://en.wikipedia.org/wiki/Candela_per_square_metre).
|
|
||||||
///
|
|
||||||
/// See also <https://google.github.io/filament/Filament.html#lighting/imagebasedlights/iblunit>.
|
|
||||||
pub intensity: f32,
|
|
||||||
|
|
||||||
/// Whether the light from this irradiance volume has an effect on meshes
|
|
||||||
/// with lightmaps.
|
|
||||||
///
|
|
||||||
/// Set this to false if your lightmap baking tool bakes the light from this
|
|
||||||
/// irradiance volume into the lightmaps in order to avoid counting the
|
|
||||||
/// irradiance twice. Frequently, applications use irradiance volumes as a
|
|
||||||
/// lower-quality alternative to lightmaps for capturing indirect
|
|
||||||
/// illumination on dynamic objects, and such applications will want to set
|
|
||||||
/// this value to false.
|
|
||||||
///
|
|
||||||
/// By default, this is set to true.
|
|
||||||
pub affects_lightmapped_meshes: bool,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Default for IrradianceVolume {
|
|
||||||
#[inline]
|
|
||||||
fn default() -> Self {
|
|
||||||
IrradianceVolume {
|
|
||||||
voxels: default(),
|
|
||||||
intensity: 0.0,
|
|
||||||
affects_lightmapped_meshes: true,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// All the bind group entries necessary for PBR shaders to access the
|
/// All the bind group entries necessary for PBR shaders to access the
|
||||||
/// irradiance volumes exposed to a view.
|
/// irradiance volumes exposed to a view.
|
||||||
pub(crate) enum RenderViewIrradianceVolumeBindGroupEntries<'a> {
|
pub(crate) enum RenderViewIrradianceVolumeBindGroupEntries<'a> {
|
||||||
|
|||||||
@ -288,8 +288,7 @@ impl Plugin for LightProbePlugin {
|
|||||||
load_shader_library!(app, "environment_map.wgsl");
|
load_shader_library!(app, "environment_map.wgsl");
|
||||||
load_shader_library!(app, "irradiance_volume.wgsl");
|
load_shader_library!(app, "irradiance_volume.wgsl");
|
||||||
|
|
||||||
app.register_type::<IrradianceVolume>()
|
app.add_plugins(ExtractInstancesPlugin::<EnvironmentMapIds>::new());
|
||||||
.add_plugins(ExtractInstancesPlugin::<EnvironmentMapIds>::new());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn finish(&self, app: &mut App) {
|
fn finish(&self, app: &mut App) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user