Repository: bevyengine/bevy
File: crates/bevy_light/src/directional_light.rs (Rust)

Code before:
                    cascades
                        .iter()
                        .map(|c| Frustum::from_clip_from_world(&c.clip_from_world))
                        .collect::<Vec<_>>(),
                )
            })
            .collect();
    }
}

/// This component marks a [`DirectionalLight`] entity for changing the size and intensity of the sun disk.
#[derive(Component, Clone)]
#[require(DirectionalLight)]
pub struct SunLight {
    /// The angular size (diameter) of the sun disk in radians as observed from Earth.
    pub angular_size: f32,
    /// Multiplier applied to the brightness of the sun disk in the sky.
    ///
    /// `0.0` disables the sun disk entirely while still
    /// allowing the sun's radiance to scatter into the atmosphere,
    /// and `1.0` renders the sun disk at its normal intensity.
    pub intensity: f32,
}

impl SunLight {
    pub const SUN: SunLight = SunLight {
        // 32 arc minutes is the mean size of the sun disk when the Earth is
        // exactly 1 astronomical unit from the sun.
        angular_size: 0.00930842,
        intensity: 1.0,
    };
}

impl Default for SunLight {
    fn default() -> Self {
        Self::SUN
    }
}

impl Default for &SunLight {
    fn default() -> Self {
        &SunLight::SUN
    }
}


Review comment (suggestion):
typing out `SunLight:SUN` or `SunDisk:SUN` feels a bit awkward, but I don't have a better idea. maybe `SunDisk:EARTH` ? since this is exactly 1 AU away? I am adding martian atmosphere eventually so there can be a `SunDisk:MARS` too that has different values. 

Code after:
                    cascades
                        .iter()
                        .map(|c| Frustum::from_clip_from_world(&c.clip_from_world))
                        .collect::<Vec<_>>(),
                )
            })
            .collect();
    }
}

/// Add to a [`DirectionalLight`] to control rendering of the visible solar disk in the sky.
/// Affects only the disk’s appearance, not the light’s illuminance or shadows.
/// 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`].
#[derive(Component, Clone)]
#[require(DirectionalLight)]
pub struct SunDisk {
    /// The angular size (diameter) of the sun disk in radians, as observed from the scene.
    pub angular_size: f32,
    /// Multiplier for the brightness of the sun disk.
    ///
    /// `0.0` disables the disk entirely (atmospheric scattering still occurs),
    /// `1.0` is the default physical intensity, and values `>1.0` overexpose it.
    pub intensity: f32,
}

impl SunDisk {
    /// Earth-like parameters for the sun disk.
    ///
    /// Uses the mean apparent size (~32 arcminutes) of the Sun at 1 AU distance
    /// with default intensity.
    pub const EARTH: SunDisk = SunDisk {
        angular_size: 0.00930842,
        intensity: 1.0,
    };

    /// No visible sun disk.
    ///
    /// Keeps scattering and directional light illumination, but hides the disk itself.
    pub const OFF: SunDisk = SunDisk {
        angular_size: 0.0,
        intensity: 0.0,
    };
}

impl Default for SunDisk {
    fn default() -> Self {
        Self::EARTH