Skip to content

Commit

Permalink
Merge pull request #1 from coreh/exposure_jms
Browse files Browse the repository at this point in the history
Compensate for exposure after sampling background color, adjust transmission example
  • Loading branch information
GitGhillie authored Dec 31, 2023
2 parents edfb721 + 0d4006e commit 404a98d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions crates/bevy_pbr/src/render/pbr_transmission.wgsl
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ fn specular_transmissive_light(world_position: vec4<f32>, frag_coord: vec3<f32>,
background_color = fetch_transmissive_background(offset_position, frag_coord, view_z, perceptual_roughness);
}

// Compensate for exposure, since the background color is coming from an already exposure-adjusted texture
background_color = vec4(background_color.rgb / view_bindings::view.exposure, background_color.a);

// Dot product of the refracted direction with the exit normal (Note: We assume the exit normal is the entry normal but inverted)
let MinusNdotT = dot(-N, T);

Expand Down
8 changes: 4 additions & 4 deletions examples/3d/transmission.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ fn setup(
PbrBundle {
mesh: icosphere_mesh.clone(),
material: materials.add(StandardMaterial {
emissive: Color::ANTIQUE_WHITE * 20.0 + Color::ORANGE_RED * 4.0,
emissive: Color::ANTIQUE_WHITE * 80.0 + Color::ORANGE_RED * 16.0,
diffuse_transmission: 1.0,
..default()
}),
Expand Down Expand Up @@ -328,7 +328,7 @@ fn setup(
transform: Transform::from_xyz(-1.0, 1.7, 0.0),
point_light: PointLight {
color: Color::ANTIQUE_WHITE * 0.8 + Color::ORANGE_RED * 0.2,
intensity: 1600.0,
intensity: 60_000.0,
radius: 0.2,
range: 5.0,
shadows_enabled: true,
Expand All @@ -348,7 +348,6 @@ fn setup(
},
transform: Transform::from_xyz(1.0, 1.8, 7.0).looking_at(Vec3::ZERO, Vec3::Y),
color_grading: ColorGrading {
exposure: -2.0,
post_saturation: 1.2,
..default()
},
Expand All @@ -358,6 +357,7 @@ fn setup(
#[cfg(not(all(feature = "webgl2", target_arch = "wasm32")))]
TemporalAntiAliasBundle::default(),
EnvironmentMapLight {
intensity: 25.0,
diffuse_map: asset_server.load("environment_maps/pisa_diffuse_rgb9e5_zstd.ktx2"),
specular_map: asset_server.load("environment_maps/pisa_specular_rgb9e5_zstd.ktx2"),
},
Expand Down Expand Up @@ -651,7 +651,7 @@ fn flicker_system(
let c = (s * 7.0).cos() * 0.0125 + (s * 2.0).cos() * 0.025;
let (mut light, mut light_transform) = light.single_mut();
let mut flame_transform = flame.single_mut();
light.intensity = 1600.0 + 3000.0 * (a + b + c);
light.intensity = 60_000.0 + 3000.0 * (a + b + c);
flame_transform.translation = Vec3::new(-1.0, 1.23, 0.0);
flame_transform.look_at(Vec3::new(-1.0 - c, 1.7 - b, 0.0 - a), Vec3::X);
flame_transform.rotate(Quat::from_euler(EulerRot::XYZ, 0.0, 0.0, PI / 2.0));
Expand Down

0 comments on commit 404a98d

Please sign in to comment.