Expand description
A procedural sky plugin for the Bevy game engine.
Provides a framework for creating and using atmospheric models.
§“basic” Example
use bevy::prelude::*;
use bevy_atmosphere::prelude::*;
fn main() {
App::new()
.add_plugins((DefaultPlugins, AtmospherePlugin))
.add_systems(Startup, setup)
.run();
}
fn setup(mut commands: Commands) {
commands.spawn((Camera3d::default(), AtmosphereCamera::default()));
}
How the sky is rendered is described by an Atmospheric
model.
bevy_atmosphere provides a collection of models to use, but you can create your own as well.
To read and modify the atmospheric model, use the Atmosphere<T>
and
AtmosphereMut<T>
system params or
the AtmosphereModel
resource.
fn read_nishita(atmosphere: Atmosphere<Nishita>) {
let sun_position = atmosphere.sun_position;
println!("Sun is at {sun_position}");
}
fn write_gradient(mut atmosphere: AtmosphereMut<Gradient>) {
atmosphere.horizon = LinearRgba::RED;
}
fn check_model(atmosphere: Res<AtmosphereModel>) {
if let Some(nishita) = atmosphere.to_ref::<Nishita>() {
println!("Sun is at {}", nishita.sun_position);
} else {
println!("Model isn't Nishita");
}
}
Use the AtmosphereSettings
resource to change how the sky is rendered.
use bevy_atmosphere::settings::AtmosphereSettings;
AtmosphereSettings {
// changes the resolution (should be a multiple of 8)
resolution: 1024,
// turns off dithering
dithering: false,
..default()
}
When using the detection
feature, you can use SkyboxCreationMode
to control the size of the generated skybox.
use bevy_atmosphere::settings::{AtmosphereSettings, SkyboxCreationMode};
AtmosphereSettings {
// Will use the camera projections `far` value or `1000.0` as a fallback
skybox_creation_mode: SkyboxCreationMode::FromProjectionFarWithFallback(1000.0),
..default()
}
To see more examples, view the “examples” directory.
Modules§
- collection
- Provides a collection of atmospheric models.
- model
- Provides the
Atmospheric
trait andAtmosphereModel
resource. - pipeline
- Provides types and logic for a compute pipeline that renders the procedural sky texture.
- plugin
- Provides a
Plugin
for making skyboxes with procedural sky textures. - prelude
use bevy_atmosphere::prelude::*;
to import the most commonly used items.- settings
- Provides
AtmosphereSettings
resource, a type that controls how the sky is rendered. - skybox
- Provides types and data needed for rendering a skybox.
- system_
param - Provides system params for easy reading/modifying of
Atmospheric
models.