mirror of
https://github.com/bevyengine/bevy
synced 2024-11-10 07:04:33 +00:00
Improve Bloom 3D lighting (#11981)
# Objective
- With the recent lighting changes, the default configuration in the
`bloom_3d` example is less clear what bloom actually does
- See [this
screenshot](4fdb1455d5 (r1494648414)
)
for a comparison.
- `bloom_3d` additionally uses a for-loop to spawn the spheres, which
can be turned into `commands::spawn_batch` call.
- The text is black, which is difficult to see on the gray background.
## Solution
- Increase emmisive values of materials.
- Set text to white.
## Showcase
Before:
<img width="1392" alt="before"
src="https://github.com/bevyengine/bevy/assets/59022059/757057ad-ed9f-4eed-b135-8e2032fcdeb5">
After:
<img width="1392" alt="image"
src="https://github.com/bevyengine/bevy/assets/59022059/3f9dc7a8-94b2-44b9-8ac3-deef1905221b">
---------
Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com>
This commit is contained in:
parent
f67b17d80d
commit
713d91b721
2 changed files with 11 additions and 6 deletions
|
@ -106,6 +106,8 @@ pub struct BloomSettings {
|
|||
|
||||
impl BloomSettings {
|
||||
/// The default bloom preset.
|
||||
///
|
||||
/// This uses the [`EnergyConserving`](BloomCompositeMode::EnergyConserving) composite mode.
|
||||
pub const NATURAL: Self = Self {
|
||||
intensity: 0.15,
|
||||
low_frequency_boost: 0.7,
|
||||
|
|
|
@ -36,19 +36,20 @@ fn setup_scene(
|
|||
transform: Transform::from_xyz(-2.0, 2.5, 5.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||
..default()
|
||||
},
|
||||
BloomSettings::default(), // 3. Enable bloom for the camera
|
||||
// 3. Enable bloom for the camera
|
||||
BloomSettings::NATURAL,
|
||||
));
|
||||
|
||||
let material_emissive1 = materials.add(StandardMaterial {
|
||||
emissive: Color::linear_rgb(2300.0, 900.0, 300.0), // 4. Put something bright in a dark environment to see the effect
|
||||
emissive: Color::linear_rgb(23000.0, 9000.0, 3000.0), // 4. Put something bright in a dark environment to see the effect
|
||||
..default()
|
||||
});
|
||||
let material_emissive2 = materials.add(StandardMaterial {
|
||||
emissive: Color::linear_rgb(300.0, 2300.0, 900.0),
|
||||
emissive: Color::linear_rgb(3000.0, 23000.0, 9000.0),
|
||||
..default()
|
||||
});
|
||||
let material_emissive3 = materials.add(StandardMaterial {
|
||||
emissive: Color::linear_rgb(900.0, 300.0, 2300.0),
|
||||
emissive: Color::linear_rgb(9000.0, 3000.0, 23000.0),
|
||||
..default()
|
||||
});
|
||||
let material_non_emissive = materials.add(StandardMaterial {
|
||||
|
@ -60,6 +61,8 @@ fn setup_scene(
|
|||
|
||||
for x in -5..5 {
|
||||
for z in -5..5 {
|
||||
// This generates a pseudo-random integer between `[0, 6)`, but deterministically so
|
||||
// the same spheres are always the same colors.
|
||||
let mut hasher = DefaultHasher::new();
|
||||
(x, z).hash(&mut hasher);
|
||||
let rand = (hasher.finish() - 2) % 6;
|
||||
|
@ -90,7 +93,7 @@ fn setup_scene(
|
|||
"",
|
||||
TextStyle {
|
||||
font_size: 20.0,
|
||||
color: Color::BLACK,
|
||||
color: Color::WHITE,
|
||||
..default()
|
||||
},
|
||||
)
|
||||
|
@ -219,7 +222,7 @@ fn update_bloom_settings(
|
|||
*text = "Bloom: Off (Toggle: Space)".to_string();
|
||||
|
||||
if keycode.just_pressed(KeyCode::Space) {
|
||||
commands.entity(entity).insert(BloomSettings::default());
|
||||
commands.entity(entity).insert(BloomSettings::NATURAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue