Skip to content

Commit

Permalink
make bloom spheres sometimes non-emissive
Browse files Browse the repository at this point in the history
  • Loading branch information
jakobhellermann committed Dec 24, 2021
1 parent 719935e commit 2bf969d
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions examples/3d/bloom.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use bevy::prelude::*;
use bevy::{pbr::bloom::BloomSettings, prelude::*};
use std::collections::hash_map::DefaultHasher;
use std::hash::{Hash, Hasher};

fn main() {
App::new()
Expand Down Expand Up @@ -35,13 +37,25 @@ fn setup(
emissive: Color::rgb_linear(1.0, 0.3, 0.2) * 4.0,
..Default::default()
});
let material_non_emissive = materials.add(StandardMaterial {
..Default::default()
});

for x in -10..10 {
for z in -10..10 {
let mut hasher = DefaultHasher::new();
(x, z).hash(&mut hasher);
let rand = hasher.finish() % 2 == 0;

let material = match rand {
true => material.clone(),
false => material_non_emissive.clone(),
};

commands
.spawn_bundle(PbrBundle {
mesh: mesh.clone(),
material: material.clone(),
material,
transform: Transform::from_xyz(x as f32 * 2.0, 0.0, z as f32 * 2.0),
..Default::default()
})
Expand Down

0 comments on commit 2bf969d

Please sign in to comment.