bevy_atmosphere/collection/
gradient.rs

1use crate::model::Atmospheric;
2use bevy::{prelude::*, render::render_resource::ShaderType};
3
4/// The Gradient sky model.
5///
6/// A simple gradient for creating a stylized environment.
7#[derive(Atmospheric, ShaderType, Reflect, Debug, Clone)]
8#[uniform(0, Gradient)]
9#[internal("shaders/gradient.wgsl")]
10pub struct Gradient {
11    /// Sky Color (Default: `Color::srgb(0.29, 0.41, 0.50)`).
12    /// <div style="background-color:rgb(29%, 41%, 50%); width: 10px; padding: 10px; border: 1px solid;"></div>
13    ///
14    ///
15    /// The color of the top.
16    pub sky: LinearRgba,
17    /// Horizon Color (Default: `Color::srgb(0.48, 0.62, 0.69)`).
18    /// <div style="background-color:rgb(48%, 62%, 69%); width: 10px; padding: 10px; border: 1px solid;"></div>
19    ///
20    ///
21    /// The color of the sides.
22    pub horizon: LinearRgba,
23    /// Ground Color (Default: `Color::srgb(0.71, 0.69, 0.57)`).
24    /// <div style="background-color:rgb(71%, 69%, 57%); width: 10px; padding: 10px; border: 1px solid;"></div>
25    ///
26    ///
27    /// The color of the bottom.
28    pub ground: LinearRgba,
29}
30
31impl Default for Gradient {
32    fn default() -> Self {
33        Self {
34            sky: Color::srgb(0.29, 0.41, 0.50).into(),
35            horizon: Color::srgb(0.48, 0.62, 0.69).into(),
36            ground: Color::srgb(0.71, 0.69, 0.57).into(),
37        }
38    }
39}
40
41impl From<&Gradient> for Gradient {
42    fn from(gradient: &Gradient) -> Self {
43        gradient.clone()
44    }
45}