Skip to content

Commit

Permalink
Reuse light for both render passes.
Browse files Browse the repository at this point in the history
  • Loading branch information
n3vu0r committed Jul 6, 2024
1 parent c28fd88 commit 1c8f663
Showing 1 changed file with 14 additions and 18 deletions.
32 changes: 14 additions & 18 deletions examples/egui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,27 +130,23 @@ fn setup(
.insert(MainPassCube);

// Defines initial transform of cameras and light.
let target = Vec3::new(0.0, 0.0, 0.0);
let target = Vec3::ZERO;
let eye = Vec3::new(0.0, 0.0, 15.0);
let up = Vec3::Y;

// Light
//
// NOTE: Currently lights are shared between passes,
// see https://github.com/bevyengine/bevy/issues/3462
commands.spawn(SpotLightBundle {
transform: Transform::from_xyz(eye.x, eye.y, eye.z).looking_at(target, up),
spot_light: SpotLight {
intensity: 10_000_000.,
range: 100.0,
color: Color::WHITE,
shadows_enabled: true,
inner_angle: PI / 4.0 * 0.85,
outer_angle: PI / 4.0,
// The same light is reused for both passes, you can specify different lights for preview and
// main pass by setting appropriate `RenderLayers`.
commands
.spawn(SpotLightBundle {
transform: Transform::from_translation(eye).looking_at(target, up),
spot_light: SpotLight {
intensity: 10_000_000.0,
range: 100.0,
..default()
},
..default()
},
..default()
});
})
.insert(RenderLayers::default().with(1));

// The main pass camera with controller.
let controller = commands
Expand All @@ -166,7 +162,7 @@ fn setup(
.spawn((
Camera3dBundle {
camera: Camera {
// render before the "main pass" camera
// Render before the main pass camera.
order: -1,
target: RenderTarget::Image(image_handle),
clear_color: ClearColorConfig::Custom(Color::srgba(1.0, 1.0, 1.0, 0.0)),
Expand Down

0 comments on commit 1c8f663

Please sign in to comment.