Skip to content

Commit e469ca8

Browse files
authored
minor gen env map cleanups (#20309)
# Objective - remove some unused wgsl lines - dont panic just early out to avoid ordering issues when spawning a generated envmap with a image handle that hasnt loaded/extracted yet - factor out a constant for envmap intensity in example - remove outdated comment ## Solution - do stuff ## Testing - reflection_probes example
1 parent 12f605e commit e469ca8

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

crates/bevy_pbr/src/light_probe/environment_map.wgsl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ fn compute_radiances(
3232
// Unpack.
3333
let N = input.N;
3434
let R = input.R;
35-
let NdotV = input.NdotV;
3635
let perceptual_roughness = input.perceptual_roughness;
3736
let roughness = input.roughness;
3837

@@ -111,7 +110,6 @@ fn compute_radiances(
111110
// Unpack.
112111
let N = input.N;
113112
let R = input.R;
114-
let NdotV = input.NdotV;
115113
let perceptual_roughness = input.perceptual_roughness;
116114
let roughness = input.roughness;
117115

crates/bevy_pbr/src/light_probe/generate.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -467,9 +467,9 @@ pub fn extract_generated_environment_map_entities(
467467
render_images: Res<RenderAssets<GpuImage>>,
468468
) {
469469
for (entity, filtered_env_map, env_map_light) in query.iter() {
470-
let env_map = render_images
471-
.get(&filtered_env_map.environment_map)
472-
.expect("Environment map not found");
470+
let Some(env_map) = render_images.get(&filtered_env_map.environment_map) else {
471+
continue;
472+
};
473473

474474
let diffuse_map = render_images.get(&env_map_light.diffuse_map);
475475
let specular_map = render_images.get(&env_map_light.specular_map);

examples/3d/reflection_probes.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ static START_ROTATION_HELP_TEXT: &str = "Press Enter to start rotation";
2828

2929
static REFLECTION_MODE_HELP_TEXT: &str = "Press Space to switch reflection mode";
3030

31+
const ENV_MAP_INTENSITY: f32 = 5000.0;
32+
3133
// The mode the application is in.
3234
#[derive(Resource)]
3335
struct AppStatus {
@@ -154,7 +156,7 @@ fn spawn_reflection_probe(commands: &mut Commands, cubemaps: &Cubemaps) {
154156
EnvironmentMapLight {
155157
diffuse_map: cubemaps.diffuse_environment_map.clone(),
156158
specular_map: cubemaps.specular_reflection_probe.clone(),
157-
intensity: 5000.0,
159+
intensity: ENV_MAP_INTENSITY,
158160
..default()
159161
},
160162
// 2.0 because the sphere's radius is 1.0 and we want to fully enclose it.
@@ -190,7 +192,7 @@ fn add_environment_map_to_camera(
190192
.insert(create_camera_environment_map_light(&cubemaps))
191193
.insert(Skybox {
192194
image: cubemaps.specular_environment_map.clone(),
193-
brightness: 5000.0,
195+
brightness: ENV_MAP_INTENSITY,
194196
..default()
195197
});
196198
}
@@ -253,9 +255,7 @@ fn change_reflection_type(
253255
.entity(camera)
254256
.insert(GeneratedEnvironmentMapLight {
255257
environment_map: cubemaps.specular_environment_map.clone(),
256-
// compensate for the energy loss of the reverse tonemapping
257-
// during filtering by using a higher intensity
258-
intensity: 5000.0,
258+
intensity: ENV_MAP_INTENSITY,
259259
..default()
260260
});
261261
}
@@ -328,7 +328,7 @@ fn create_camera_environment_map_light(cubemaps: &Cubemaps) -> EnvironmentMapLig
328328
EnvironmentMapLight {
329329
diffuse_map: cubemaps.diffuse_environment_map.clone(),
330330
specular_map: cubemaps.specular_environment_map.clone(),
331-
intensity: 5000.0,
331+
intensity: ENV_MAP_INTENSITY,
332332
..default()
333333
}
334334
}

0 commit comments

Comments
 (0)