Remove LioghtProbe requirement from example and doc
This commit is contained in:
parent
9c56874b24
commit
c589cd2b39
@ -2,14 +2,15 @@
|
||||
//!
|
||||
//! A *generated environment map* converts a single, high-resolution cubemap
|
||||
//! into the pair of diffuse and specular cubemaps required by the PBR
|
||||
//! shader. Add [`bevy_light::GeneratedEnvironmentMapLight`] (together with
|
||||
//! [`bevy_light::LightProbe`]) to an entity and Bevy will, each frame:
|
||||
//! shader. Add [`bevy_light::GeneratedEnvironmentMapLight`] to a camera
|
||||
//! and Bevy will, each frame, generate the diffuse and specular cubemaps
|
||||
//! required by the PBR shader.
|
||||
//!
|
||||
//! 1. Copy the base mip (level 0) of the source cubemap into an
|
||||
//! intermediate storage texture.
|
||||
//! 1. Copy the base mip (level 0) of the source cubemap into an intermediate
|
||||
//! storage texture.
|
||||
//! 2. Generate mipmaps using single-pass down-sampling (SPD).
|
||||
//! 3. Convolve the mip chain twice:
|
||||
//! * a Lambertian convolution for the 32 × 32 diffuse cubemap;
|
||||
//! * a Lambertian convolution for the 32 × 32 diffuse cubemap
|
||||
//! * a GGX convolution, once per mip level, for the specular cubemap.
|
||||
//!
|
||||
//! The filtered results are then consumed exactly like the textures supplied
|
||||
|
@ -152,18 +152,6 @@ fn spawn_reflection_probe(commands: &mut Commands, cubemaps: &Cubemaps) {
|
||||
));
|
||||
}
|
||||
|
||||
fn spawn_generated_environment_map(commands: &mut Commands, cubemaps: &Cubemaps) {
|
||||
commands.spawn((
|
||||
LightProbe,
|
||||
GeneratedEnvironmentMapLight {
|
||||
environment_map: cubemaps.specular_environment_map.clone(),
|
||||
intensity: 5000.0,
|
||||
..default()
|
||||
},
|
||||
Transform::from_scale(Vec3::splat(2.0)),
|
||||
));
|
||||
}
|
||||
|
||||
// Spawns the help text.
|
||||
fn spawn_text(commands: &mut Commands, app_status: &AppStatus) {
|
||||
// Create the text.
|
||||
@ -202,7 +190,6 @@ fn add_environment_map_to_camera(
|
||||
fn change_reflection_type(
|
||||
mut commands: Commands,
|
||||
light_probe_query: Query<Entity, With<LightProbe>>,
|
||||
sky_box_query: Query<Entity, With<Skybox>>,
|
||||
camera_query: Query<Entity, With<Camera3d>>,
|
||||
keyboard: Res<ButtonInput<KeyCode>>,
|
||||
mut app_status: ResMut<AppStatus>,
|
||||
@ -217,34 +204,38 @@ fn change_reflection_type(
|
||||
app_status.reflection_mode =
|
||||
ReflectionMode::try_from((app_status.reflection_mode as u32 + 1) % 3).unwrap();
|
||||
|
||||
// Add or remove the light probe.
|
||||
// Remove light probes
|
||||
for light_probe in light_probe_query.iter() {
|
||||
commands.entity(light_probe).despawn();
|
||||
}
|
||||
for skybox in sky_box_query.iter() {
|
||||
commands.entity(skybox).remove::<Skybox>();
|
||||
}
|
||||
match app_status.reflection_mode {
|
||||
ReflectionMode::EnvironmentMap => {}
|
||||
ReflectionMode::ReflectionProbe => spawn_reflection_probe(&mut commands, &cubemaps),
|
||||
ReflectionMode::GeneratedEnvironmentMap => {
|
||||
spawn_generated_environment_map(&mut commands, &cubemaps);
|
||||
}
|
||||
ReflectionMode::GeneratedEnvironmentMap => {}
|
||||
}
|
||||
|
||||
// Add or remove the environment map from the camera.
|
||||
// Update the environment-map components on the camera entity/entities
|
||||
for camera in camera_query.iter() {
|
||||
// Remove any existing environment-map components
|
||||
commands
|
||||
.entity(camera)
|
||||
.remove::<(EnvironmentMapLight, GeneratedEnvironmentMapLight)>();
|
||||
|
||||
match app_status.reflection_mode {
|
||||
ReflectionMode::EnvironmentMap
|
||||
| ReflectionMode::ReflectionProbe
|
||||
| ReflectionMode::GeneratedEnvironmentMap => {
|
||||
let image = cubemaps.specular_environment_map.clone();
|
||||
// A baked or reflection-probe environment map
|
||||
ReflectionMode::EnvironmentMap | ReflectionMode::ReflectionProbe => {
|
||||
commands
|
||||
.entity(camera)
|
||||
.insert(create_camera_environment_map_light(&cubemaps))
|
||||
.insert(Skybox {
|
||||
image,
|
||||
brightness: 5000.0,
|
||||
.insert(create_camera_environment_map_light(&cubemaps));
|
||||
}
|
||||
|
||||
// GPU-filtered environment map generated at runtime
|
||||
ReflectionMode::GeneratedEnvironmentMap => {
|
||||
commands
|
||||
.entity(camera)
|
||||
.insert(GeneratedEnvironmentMapLight {
|
||||
environment_map: cubemaps.specular_environment_map.clone(),
|
||||
intensity: 5000.0,
|
||||
..default()
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user