atmosphere: add volumetric fog (WIP)
This commit is contained in:
parent
193f95992c
commit
727d8d2493
|
@ -32,6 +32,7 @@ impl Plugin for CameraPlugin {
|
||||||
fn build(&self, app: &mut App) {
|
fn build(&self, app: &mut App) {
|
||||||
app.add_systems(Startup, setup_camera);
|
app.add_systems(Startup, setup_camera);
|
||||||
app.add_systems(Update, handle_input.run_if(in_control).run_if(game_running));
|
app.add_systems(Update, handle_input.run_if(in_control).run_if(game_running));
|
||||||
|
app.add_systems(Update, tweak_scene);
|
||||||
app.add_systems(
|
app.add_systems(
|
||||||
Update,
|
Update,
|
||||||
update_map_only_object_visibility
|
update_map_only_object_visibility
|
||||||
|
@ -147,6 +148,14 @@ pub fn setup_camera(
|
||||||
transform: Transform::from_xyz(0.0, 0.0, 8.0).looking_at(Vec3::ZERO, Vec3::Y),
|
transform: Transform::from_xyz(0.0, 0.0, 8.0).looking_at(Vec3::ZERO, Vec3::Y),
|
||||||
..default()
|
..default()
|
||||||
},
|
},
|
||||||
|
bevy::pbr::VolumetricFogSettings {
|
||||||
|
// This value is explicitly set to 0 since we have no environment map light
|
||||||
|
ambient_intensity: 0.0,
|
||||||
|
absorption: 0.1,
|
||||||
|
density: 0.01,
|
||||||
|
step_count: 16,
|
||||||
|
..default()
|
||||||
|
},
|
||||||
bevy::core_pipeline::fxaa::Fxaa {
|
bevy::core_pipeline::fxaa::Fxaa {
|
||||||
edge_threshold: bevy::core_pipeline::fxaa::Sensitivity::Extreme,
|
edge_threshold: bevy::core_pipeline::fxaa::Sensitivity::Extreme,
|
||||||
..default()
|
..default()
|
||||||
|
@ -793,3 +802,14 @@ pub fn position_to_transform(
|
||||||
transform.rotation = rot.as_quat();
|
transform.rotation = rot.as_quat();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn tweak_scene(
|
||||||
|
mut commands: Commands,
|
||||||
|
mut lights: Query<(Entity, &mut DirectionalLight), Changed<DirectionalLight>>,
|
||||||
|
) {
|
||||||
|
for (light, mut directional_light) in lights.iter_mut() {
|
||||||
|
// Shadows are needed for volumetric lights to work.
|
||||||
|
directional_light.shadows_enabled = true;
|
||||||
|
commands.entity(light).insert(bevy::pbr::VolumetricLight);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue