diff --git a/crates/bevy_light/src/directional_light.rs b/crates/bevy_light/src/directional_light.rs index 1857d57bc4ed0..e65a1e1b2024e 100644 --- a/crates/bevy_light/src/directional_light.rs +++ b/crates/bevy_light/src/directional_light.rs @@ -257,8 +257,9 @@ pub fn update_directional_light_frusta( /// Requires a `bevy::pbr::Atmosphere` component on a [`Camera3d`](bevy_camera::Camera3d) to have any effect. /// /// By default, the atmosphere is rendered with [`SunDisk::EARTH`], which approximates the -/// apparent size and brightness of the Sun as seen from Earth. You can also disable the sun -/// disk entirely with [`SunDisk::OFF`]. +/// apparent size and brightness of the Sun as seen from Earth. Use [`SunDisk::MARS`] for the +/// smaller apparent sun size from Mars. You can also disable the sun disk entirely +/// with [`SunDisk::OFF`]. /// /// In order to cause the sun to "glow" and light up the surrounding sky, enable bloom /// in your post-processing pipeline by adding a `Bloom` component to your camera. @@ -284,6 +285,15 @@ impl SunDisk { intensity: 1.0, }; + /// Mars-like parameters for the sun disk. + /// + /// Uses the mean apparent size (~21 arcminutes) of the Sun from Mars + /// at ~1.52 AU distance with default intensity. + pub const MARS: SunDisk = SunDisk { + angular_size: 0.00615, + intensity: 1.0, + }; + /// No visible sun disk. /// /// Keeps scattering and directional light illumination, but hides the disk itself. diff --git a/examples/3d/atmosphere.rs b/examples/3d/atmosphere.rs index 99396ccc7d78a..5258ceb4d2731 100644 --- a/examples/3d/atmosphere.rs +++ b/examples/3d/atmosphere.rs @@ -15,7 +15,7 @@ use bevy::{ input::keyboard::KeyCode, light::{ atmosphere::ScatteringMedium, light_consts::lux, Atmosphere, AtmosphereEnvironmentMapLight, - FogVolume, VolumetricFog, VolumetricLight, + FogVolume, SunDisk, VolumetricFog, VolumetricLight, }, pbr::{ AtmosphereMode, AtmosphereSettings, DefaultOpaqueRendererMethod, ExtendedMaterial, @@ -72,6 +72,7 @@ fn atmosphere_controls( keyboard_input: Res>, mut planet_atmosphere: Query<(&mut Atmosphere, &mut GlobalTransform)>, mut camera_settings: Query<&mut AtmosphereSettings, With>, + mut sun_disks: Query<&mut SunDisk, With>, atmosphere_presets: Res, mut game_state: ResMut, mut camera_exposure: Query<&mut Exposure, With>, @@ -81,16 +82,22 @@ fn atmosphere_controls( for (mut atmosphere, mut transform) in &mut planet_atmosphere { *atmosphere = Atmosphere::earth(atmosphere_presets.earth.clone()); *transform = GlobalTransform::from_translation(-Vec3::Y * atmosphere.inner_radius); - println!("Switched to Earth atmosphere"); } + for mut sun_disk in &mut sun_disks { + sun_disk.angular_size = SunDisk::EARTH.angular_size; + } + println!("Switched to Earth atmosphere"); } if keyboard_input.just_pressed(KeyCode::Digit4) { for (mut atmosphere, mut transform) in &mut planet_atmosphere { *atmosphere = Atmosphere::mars(atmosphere_presets.mars.clone()); *transform = GlobalTransform::from_translation(-Vec3::Y * atmosphere.inner_radius); - println!("Switched to Mars atmosphere"); } + for mut sun_disk in &mut sun_disks { + sun_disk.angular_size = SunDisk::MARS.angular_size; + } + println!("Switched to Mars atmosphere"); } if keyboard_input.just_pressed(KeyCode::Digit1) { @@ -229,6 +236,7 @@ fn setup_terrain_scene( }, Transform::from_xyz(1.0, 0.4, 0.0).looking_at(Vec3::ZERO, Vec3::Y), VolumetricLight, + SunDisk::EARTH, )); // spawn the fog volume