Skip to content

Commit 404a98d

Browse files
authored
Merge pull request #1 from coreh/exposure_jms
Compensate for exposure after sampling background color, adjust transmission example
2 parents edfb721 + 0d4006e commit 404a98d

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

crates/bevy_pbr/src/render/pbr_transmission.wgsl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ fn specular_transmissive_light(world_position: vec4<f32>, frag_coord: vec3<f32>,
4242
background_color = fetch_transmissive_background(offset_position, frag_coord, view_z, perceptual_roughness);
4343
}
4444

45+
// Compensate for exposure, since the background color is coming from an already exposure-adjusted texture
46+
background_color = vec4(background_color.rgb / view_bindings::view.exposure, background_color.a);
47+
4548
// Dot product of the refracted direction with the exit normal (Note: We assume the exit normal is the entry normal but inverted)
4649
let MinusNdotT = dot(-N, T);
4750

examples/3d/transmission.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ fn setup(
156156
PbrBundle {
157157
mesh: icosphere_mesh.clone(),
158158
material: materials.add(StandardMaterial {
159-
emissive: Color::ANTIQUE_WHITE * 20.0 + Color::ORANGE_RED * 4.0,
159+
emissive: Color::ANTIQUE_WHITE * 80.0 + Color::ORANGE_RED * 16.0,
160160
diffuse_transmission: 1.0,
161161
..default()
162162
}),
@@ -328,7 +328,7 @@ fn setup(
328328
transform: Transform::from_xyz(-1.0, 1.7, 0.0),
329329
point_light: PointLight {
330330
color: Color::ANTIQUE_WHITE * 0.8 + Color::ORANGE_RED * 0.2,
331-
intensity: 1600.0,
331+
intensity: 60_000.0,
332332
radius: 0.2,
333333
range: 5.0,
334334
shadows_enabled: true,
@@ -348,7 +348,6 @@ fn setup(
348348
},
349349
transform: Transform::from_xyz(1.0, 1.8, 7.0).looking_at(Vec3::ZERO, Vec3::Y),
350350
color_grading: ColorGrading {
351-
exposure: -2.0,
352351
post_saturation: 1.2,
353352
..default()
354353
},
@@ -358,6 +357,7 @@ fn setup(
358357
#[cfg(not(all(feature = "webgl2", target_arch = "wasm32")))]
359358
TemporalAntiAliasBundle::default(),
360359
EnvironmentMapLight {
360+
intensity: 25.0,
361361
diffuse_map: asset_server.load("environment_maps/pisa_diffuse_rgb9e5_zstd.ktx2"),
362362
specular_map: asset_server.load("environment_maps/pisa_specular_rgb9e5_zstd.ktx2"),
363363
},
@@ -651,7 +651,7 @@ fn flicker_system(
651651
let c = (s * 7.0).cos() * 0.0125 + (s * 2.0).cos() * 0.025;
652652
let (mut light, mut light_transform) = light.single_mut();
653653
let mut flame_transform = flame.single_mut();
654-
light.intensity = 1600.0 + 3000.0 * (a + b + c);
654+
light.intensity = 60_000.0 + 3000.0 * (a + b + c);
655655
flame_transform.translation = Vec3::new(-1.0, 1.23, 0.0);
656656
flame_transform.look_at(Vec3::new(-1.0 - c, 1.7 - b, 0.0 - a), Vec3::X);
657657
flame_transform.rotate(Quat::from_euler(EulerRot::XYZ, 0.0, 0.0, PI / 2.0));

0 commit comments

Comments
 (0)