Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bevy 0.13 Update #68

Merged
merged 12 commits into from
Feb 23, 2024
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "bevy_atmosphere"
description = "A procedural sky plugin for bevy"
version = "0.8.1"
version = "0.9.0"
edition = "2021"
authors = ["JonahPlusPlus <[email protected]>"]
license = "MIT OR Apache-2.0"
Expand All @@ -11,7 +11,7 @@ repository = "https://github.com/JonahPlusPlus/bevy_atmosphere"
exclude = ["/assets/", "/examples/", "/.github/"]

[dependencies]
bevy = { version = "0.12", default-features = false, features = [
bevy = { version = "0.13", default-features = false, features = [
"bevy_asset",
"bevy_render",
"bevy_pbr",
Expand All @@ -20,8 +20,8 @@ bevy_atmosphere_macros = { path = "macros", version = "0.4" }
cfg-if = "1.0"

[dev-dependencies]
bevy_spectator = "0.4"
bevy = { version = "0.12", features = ["bevy_core_pipeline", "x11"] }
bevy_spectator = "0.5"
bevy = { version = "0.13", features = ["bevy_core_pipeline", "x11"] }

[features]
default = ["basic", "all_models"]
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ For more information on the technicalities, you can check out the [technical doc

| bevy | bevy_atmosphere |
|------|-----------------|
| 0.13 | 0.9 |
| 0.12 | 0.8 |
| 0.11 | 0.7 |
| 0.10 | 0.6 |
Expand Down
12 changes: 6 additions & 6 deletions examples/cycle.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use bevy::prelude::*;
use bevy::{pbr::light_consts::lux::AMBIENT_DAYLIGHT, prelude::*};
use bevy_atmosphere::prelude::*;
use bevy_spectator::{Spectator, SpectatorPlugin};

Expand Down Expand Up @@ -43,7 +43,7 @@ fn daylight_cycle(

if let Some((mut light_trans, mut directional)) = query.single_mut().into() {
light_trans.rotation = Quat::from_rotation_x(-t);
directional.illuminance = t.sin().max(0.0).powf(2.0) * 100000.0;
directional.illuminance = t.sin().max(0.0).powf(2.0) * AMBIENT_DAYLIGHT;
}
}
}
Expand All @@ -64,30 +64,30 @@ fn setup_environment(

// Simple transform shape just for reference
commands.spawn(PbrBundle {
mesh: meshes.add(Mesh::from(shape::Cube { size: 1.0 })),
mesh: meshes.add(Cuboid::default()),
material: materials.add(StandardMaterial::from(Color::rgb(0.8, 0.8, 0.8))),
..Default::default()
});

// X axis
commands.spawn(PbrBundle {
mesh: meshes.add(Mesh::from(shape::Cube { size: 0.5 })),
mesh: meshes.add(Cuboid::new(0.5, 0.5, 0.5)),
material: materials.add(StandardMaterial::from(Color::rgb(0.8, 0.0, 0.0))),
transform: Transform::from_xyz(1., 0., 0.),
..Default::default()
});

// Y axis
commands.spawn(PbrBundle {
mesh: meshes.add(Mesh::from(shape::Cube { size: 0.5 })),
mesh: meshes.add(Cuboid::new(0.5, 0.5, 0.5)),
material: materials.add(StandardMaterial::from(Color::rgb(0.0, 0.8, 0.0))),
transform: Transform::from_xyz(0., 1., 0.),
..Default::default()
});

// Z axis
commands.spawn(PbrBundle {
mesh: meshes.add(Mesh::from(shape::Cube { size: 0.5 })),
mesh: meshes.add(Cuboid::new(0.5, 0.5, 0.5)),
material: materials.add(StandardMaterial::from(Color::rgb(0.0, 0.0, 0.8))),
transform: Transform::from_xyz(0., 0., 1.),
..Default::default()
Expand Down
2 changes: 1 addition & 1 deletion examples/detection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fn setup(mut commands: Commands) {

fn update(
mut commands: Commands,
mouse: Res<Input<MouseButton>>,
mouse: Res<ButtonInput<MouseButton>>,
primary_camera_query: Query<Entity, With<PrimaryCamera>>,
) {
let Ok(primary_camera) = primary_camera_query.get_single() else {
Expand Down
22 changes: 11 additions & 11 deletions examples/gradient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,67 +20,67 @@ fn setup(mut commands: Commands) {
));
}

fn change_gradient(mut commands: Commands, keys: Res<Input<KeyCode>>) {
if keys.just_pressed(KeyCode::Key1) {
fn change_gradient(mut commands: Commands, keys: Res<ButtonInput<KeyCode>>) {
if keys.just_pressed(KeyCode::Digit1) {
info!("Changed to Atmosphere Preset 1 (Default Gradient)");
commands.insert_resource(AtmosphereModel::new(Gradient::default()));
} else if keys.just_pressed(KeyCode::Key2) {
} else if keys.just_pressed(KeyCode::Digit2) {
info!("Changed to Atmosphere Preset 2 (Cotton Candy)");
commands.insert_resource(AtmosphereModel::new(Gradient {
ground: Color::rgb(1.0, 0.5, 0.75),
horizon: Color::WHITE,
sky: Color::rgb(0.5, 0.75, 1.0),
}));
} else if keys.just_pressed(KeyCode::Key3) {
} else if keys.just_pressed(KeyCode::Digit3) {
info!("Changed to Atmosphere Preset 3 (80's Sunset)");
commands.insert_resource(AtmosphereModel::new(Gradient {
sky: Color::PURPLE,
horizon: Color::PINK,
ground: Color::ORANGE,
}));
} else if keys.just_pressed(KeyCode::Key4) {
} else if keys.just_pressed(KeyCode::Digit4) {
info!("Changed to Atmosphere Preset 4 (Winter)");
commands.insert_resource(AtmosphereModel::new(Gradient {
ground: Color::rgb(0.0, 0.1, 0.2),
horizon: Color::rgb(0.3, 0.4, 0.5),
sky: Color::rgb(0.7, 0.8, 0.9),
}));
} else if keys.just_pressed(KeyCode::Key5) {
} else if keys.just_pressed(KeyCode::Digit5) {
info!("Changed to Atmosphere Preset 5 (Nether)");
commands.insert_resource(AtmosphereModel::new(Gradient {
ground: Color::BLACK,
horizon: Color::rgb(0.2, 0.0, 0.0),
sky: Color::rgb(0.5, 0.1, 0.0),
}));
} else if keys.just_pressed(KeyCode::Key6) {
} else if keys.just_pressed(KeyCode::Digit6) {
info!("Changed to Atmosphere Preset 6 (Golden)");
commands.insert_resource(AtmosphereModel::new(Gradient {
ground: Color::ORANGE_RED,
horizon: Color::ORANGE,
sky: Color::GOLD,
}));
} else if keys.just_pressed(KeyCode::Key7) {
} else if keys.just_pressed(KeyCode::Digit7) {
info!("Changed to Atmosphere Preset 7 (Noir)");
commands.insert_resource(AtmosphereModel::new(Gradient {
ground: Color::BLACK,
horizon: Color::BLACK,
sky: Color::WHITE,
}));
} else if keys.just_pressed(KeyCode::Key8) {
} else if keys.just_pressed(KeyCode::Digit8) {
info!("Changed to Atmosphere Preset 8 (Midnight)");
commands.insert_resource(AtmosphereModel::new(Gradient {
ground: Color::BLACK,
horizon: Color::BLACK,
sky: Color::MIDNIGHT_BLUE,
}));
} else if keys.just_pressed(KeyCode::Key9) {
} else if keys.just_pressed(KeyCode::Digit9) {
info!("Changed to Atmosphere Preset 9 (Greenery)");
commands.insert_resource(AtmosphereModel::new(Gradient {
ground: Color::rgb(0.1, 0.2, 0.0),
horizon: Color::rgb(0.3, 0.4, 0.1),
sky: Color::rgb(0.6, 0.8, 0.2),
}));
} else if keys.just_pressed(KeyCode::Key0) {
} else if keys.just_pressed(KeyCode::Digit0) {
info!("Reset Atmosphere to Default");
commands.remove_resource::<AtmosphereModel>();
}
Expand Down
8 changes: 4 additions & 4 deletions examples/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ fn setup(mut commands: Commands) {
));
}

fn change_model(mut commands: Commands, keys: Res<Input<KeyCode>>) {
if keys.just_pressed(KeyCode::G) {
fn change_model(mut commands: Commands, keys: Res<ButtonInput<KeyCode>>) {
if keys.just_pressed(KeyCode::KeyG) {
info!("Changed to Gradient atmosphere model");
commands.insert_resource(AtmosphereModel::new(Gradient::default()));
} else if keys.just_pressed(KeyCode::N) {
} else if keys.just_pressed(KeyCode::KeyN) {
info!("Changed to Nishita atmosphere model");
commands.insert_resource(AtmosphereModel::new(Nishita::default()));
} else if keys.just_pressed(KeyCode::Key0) {
} else if keys.just_pressed(KeyCode::Digit0) {
info!("Reset atmosphere model to default");
commands.remove_resource::<AtmosphereModel>();
}
Expand Down
22 changes: 11 additions & 11 deletions examples/nishita.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,66 +19,66 @@ fn setup(mut commands: Commands) {
));
}

fn change_nishita(mut commands: Commands, keys: Res<Input<KeyCode>>) {
if keys.just_pressed(KeyCode::Key1) {
fn change_nishita(mut commands: Commands, keys: Res<ButtonInput<KeyCode>>) {
if keys.just_pressed(KeyCode::Digit1) {
info!("Changed to Atmosphere Preset 1 (Sunset)");
commands.insert_resource(AtmosphereModel::new(Nishita {
sun_position: Vec3::new(0., 0., -1.),
..default()
}));
} else if keys.just_pressed(KeyCode::Key2) {
} else if keys.just_pressed(KeyCode::Digit2) {
info!("Changed to Atmosphere Preset 2 (Noir Sunset)");
commands.insert_resource(AtmosphereModel::new(Nishita {
sun_position: Vec3::new(0., 0., -1.),
rayleigh_coefficient: Vec3::new(1e-5, 1e-5, 1e-5),
..default()
}));
} else if keys.just_pressed(KeyCode::Key3) {
} else if keys.just_pressed(KeyCode::Digit3) {
info!("Changed to Atmosphere Preset 3 (Magenta)");
commands.insert_resource(AtmosphereModel::new(Nishita {
rayleigh_coefficient: Vec3::new(2e-5, 1e-5, 2e-5),
..default()
}));
} else if keys.just_pressed(KeyCode::Key4) {
} else if keys.just_pressed(KeyCode::Digit4) {
info!("Changed to Atmosphere Preset 4 (Strong Mie)");
commands.insert_resource(AtmosphereModel::new(Nishita {
mie_coefficient: 5e-5,
..default()
}));
} else if keys.just_pressed(KeyCode::Key5) {
} else if keys.just_pressed(KeyCode::Digit5) {
info!("Changed to Atmosphere Preset 5 (Larger Scale)");
commands.insert_resource(AtmosphereModel::new(Nishita {
rayleigh_scale_height: 16e3,
mie_scale_height: 2.4e3,
..default()
}));
} else if keys.just_pressed(KeyCode::Key6) {
} else if keys.just_pressed(KeyCode::Digit6) {
info!("Changed to Atmosphere Preset 6 (Weak Intensity)");
commands.insert_resource(AtmosphereModel::new(Nishita {
sun_intensity: 11.0,
..default()
}));
} else if keys.just_pressed(KeyCode::Key7) {
} else if keys.just_pressed(KeyCode::Digit7) {
info!("Changed to Atmosphere Preset 7 (Half Radius)");
commands.insert_resource(AtmosphereModel::new(Nishita {
ray_origin: Vec3::new(0., 6372e3 / 2., 0.),
planet_radius: 6371e3 / 2.,
atmosphere_radius: 6471e3 / 2.,
..default()
}));
} else if keys.just_pressed(KeyCode::Key8) {
} else if keys.just_pressed(KeyCode::Digit8) {
info!("Changed to Atmosphere Preset 8 (Sideways World)");
commands.insert_resource(AtmosphereModel::new(Nishita {
ray_origin: Vec3::new(6372e3, 0., 0.),
..default()
}));
} else if keys.just_pressed(KeyCode::Key9) {
} else if keys.just_pressed(KeyCode::Digit9) {
info!("Changed to Atmosphere Preset 9 (Inverted Mie Direction)");
commands.insert_resource(AtmosphereModel::new(Nishita {
mie_direction: -0.758,
..default()
}));
} else if keys.just_pressed(KeyCode::Key0) {
} else if keys.just_pressed(KeyCode::Digit0) {
info!("Reset Atmosphere to Default");
commands.remove_resource::<AtmosphereModel>();
}
Expand Down
22 changes: 11 additions & 11 deletions examples/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fn setup(mut commands: Commands) {
fn change_resolution(
mut commands: Commands,
settings: Option<ResMut<AtmosphereSettings>>,
keys: Res<Input<KeyCode>>,
keys: Res<ButtonInput<KeyCode>>,
) {
if keys.just_pressed(KeyCode::Space) {
#[cfg(feature = "bevy/trace")]
Expand All @@ -43,25 +43,25 @@ fn change_resolution(
});
}
info!("Toggled dithering");
} else if keys.just_pressed(KeyCode::Key1) {
} else if keys.just_pressed(KeyCode::Digit1) {
change(commands, settings, 8); // 8x8
} else if keys.just_pressed(KeyCode::Key2) {
} else if keys.just_pressed(KeyCode::Digit2) {
change(commands, settings, 16); // 16x16
} else if keys.just_pressed(KeyCode::Key3) {
} else if keys.just_pressed(KeyCode::Digit3) {
change(commands, settings, 32); // 32x32
} else if keys.just_pressed(KeyCode::Key4) {
} else if keys.just_pressed(KeyCode::Digit4) {
change(commands, settings, 64); // 64x64
} else if keys.just_pressed(KeyCode::Key5) {
} else if keys.just_pressed(KeyCode::Digit5) {
change(commands, settings, 128); // 128x128
} else if keys.just_pressed(KeyCode::Key6) {
} else if keys.just_pressed(KeyCode::Digit6) {
change(commands, settings, 256); // 256x256
} else if keys.just_pressed(KeyCode::Key7) {
} else if keys.just_pressed(KeyCode::Digit7) {
change(commands, settings, 512); // 512x512
} else if keys.just_pressed(KeyCode::Key8) {
} else if keys.just_pressed(KeyCode::Digit8) {
change(commands, settings, 1024); // 1024x1024
} else if keys.just_pressed(KeyCode::Key9) {
} else if keys.just_pressed(KeyCode::Digit9) {
change(commands, settings, 2048); // 2048x2048
} else if keys.just_pressed(KeyCode::Key0) {
} else if keys.just_pressed(KeyCode::Digit0) {
commands.remove_resource::<AtmosphereSettings>(); // Removes settings, goes back to defaults
info!("Removed AtmosphereSettings");
}
Expand Down
13 changes: 5 additions & 8 deletions examples/splitscreen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
//! Used to demonstrate how multiple skyboxes could be made for a local multiplayer game

use bevy::{
core_pipeline::clear_color::ClearColorConfig,
prelude::*,
render::{camera::Viewport, view::RenderLayers},
window::WindowResized,
Expand Down Expand Up @@ -38,8 +37,8 @@ fn setup(
) {
// Plane
commands.spawn(PbrBundle {
mesh: meshes.add(Mesh::from(shape::Plane::from_size(100.0))),
material: materials.add(Color::rgb(0.3, 0.5, 0.3).into()),
mesh: meshes.add(Plane3d::new(Vec3::Y).mesh().size(100.0, 100.0)),
material: materials.add(Color::rgb(0.3, 0.5, 0.3)),
..default()
});

Expand Down Expand Up @@ -83,13 +82,11 @@ fn setup(
camera: Camera {
// Renders the right camera after the left camera, which has a default priority of 0
order: 1,
..default()
},
camera_3d: Camera3d {
// Don't clear on the second camera because the first camera already cleared the window
clear_color: ClearColorConfig::None,
..default()
},
camera_3d: Camera3d::default(),
..default()
},
RenderLayers::from_layers(&[0, 2]),
Expand Down Expand Up @@ -136,14 +133,14 @@ fn set_camera_viewports(

fn switch_camera(
mut settings: ResMut<SpectatorSettings>,
keys: Res<Input<KeyCode>>,
keys: Res<ButtonInput<KeyCode>>,
left_camera: Query<Entity, (With<LeftCamera>, Without<RightCamera>)>,
right_camera: Query<Entity, With<RightCamera>>,
) {
let left_camera = left_camera.single();
let right_camera = right_camera.single();

if keys.just_pressed(KeyCode::E) {
if keys.just_pressed(KeyCode::KeyE) {
if let Some(spectator) = settings.active_spectator {
if spectator == left_camera {
settings.active_spectator = Some(right_camera);
Expand Down
4 changes: 2 additions & 2 deletions macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ exclude = ["/assets/", "/examples/", "/.github/"]
proc-macro = true

[dependencies]
proc-macro-crate = "2.0"
bevy_macro_utils = "0.12"
proc-macro-crate = "3.1"
bevy_macro_utils = "0.13"

syn = "2.0"
proc-macro2 = "1.0"
Expand Down
Loading