move global illumination from world.rs to camera.rs

This commit is contained in:
yuni 2024-04-01 18:06:41 +02:00
parent 71d926ec0f
commit 5c50ac33e3
2 changed files with 19 additions and 18 deletions

View file

@ -3,9 +3,11 @@ use bevy::input::mouse::MouseMotion;
use bevy::window::PrimaryWindow;
use bevy::core_pipeline::bloom::{BloomCompositeMode, BloomSettings};
use bevy::core_pipeline::tonemapping::Tonemapping;
use bevy::pbr::CascadeShadowConfigBuilder;
use bevy::transform::TransformSystem;
use bevy::math::DVec3;
use bevy_xpbd_3d::prelude::*;
use std::f32::consts::PI;
use crate::{settings, audio, actor};
pub struct CameraPlugin;
@ -46,6 +48,23 @@ pub fn setup_camera(
..default()
},
));
// Add Light from the Sun
commands.spawn(DirectionalLightBundle {
directional_light: DirectionalLight {
illuminance: 1000.0,
shadows_enabled: false,
..default()
},
transform: Transform::from_rotation(Quat::from_rotation_y(PI/2.0)),
cascade_shadow_config: CascadeShadowConfigBuilder {
first_cascade_far_bound: 7.0,
maximum_distance: 25.0,
..default()
}
.into(),
..default()
});
}
pub fn sync_camera_to_player(

View file

@ -1,6 +1,5 @@
use crate::{actor, nature, settings};
use bevy::prelude::*;
use bevy::pbr::CascadeShadowConfigBuilder;
use bevy::render::render_resource::{AsBindGroup, ShaderRef};
use bevy::math::DVec3;
use bevy_xpbd_3d::prelude::*;
@ -180,23 +179,6 @@ pub fn setup(
Position::from_xyz(0.0, 0.0, 0.0),
Rotation::from(Quat::from_rotation_z(1f32.to_radians())),
));
// Add Light from the Sun
commands.spawn(DirectionalLightBundle {
directional_light: DirectionalLight {
illuminance: 1000.0,
shadows_enabled: false,
..default()
},
transform: Transform::from_rotation(Quat::from_rotation_y(PI/2.0)),
cascade_shadow_config: CascadeShadowConfigBuilder {
first_cascade_far_bound: 7.0,
maximum_distance: 25.0,
..default()
}
.into(),
..default()
});
}
fn handle_cheats(