diff --git a/Cargo.toml b/Cargo.toml index 465a1e6..be2aebb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -53,13 +53,13 @@ webgl2 = ["bevy/webgl2"] webgpu = ["bevy/webgpu"] [dependencies] -bevy = { version = "0.18.0", default-features = false, features = [ +bevy = { version = "0.19", default-features = false, features = [ "bevy_asset", "bevy_render", "bevy_pbr", ] } -bevy_easings = { version = "0.18", optional = true } -bevy-inspector-egui = { version = "0.36", optional = true } +bevy_easings = { version = "0.19", optional = true } +bevy-inspector-egui = { version = "0.37", optional = true } [dev-dependencies] -bevy = { version = "0.18.0", features = ["3d", "free_camera"] } +bevy = { version = "0.19", features = ["3d", "free_camera"] } diff --git a/examples/cube.rs b/examples/cube.rs index a021e9f..73b0967 100644 --- a/examples/cube.rs +++ b/examples/cube.rs @@ -82,7 +82,7 @@ fn setup( commands.spawn(( PointLight { intensity: 1600.0, // lumens - roughly a 100W non-halogen incandescent bulb - shadows_enabled: true, + shadow_maps_enabled: true, ..default() }, Transform::from_xyz(4.0, CUBE_SIZE + 8.0, 4.0), diff --git a/examples/icosphere.rs b/examples/icosphere.rs index 7efad6f..a088a48 100644 --- a/examples/icosphere.rs +++ b/examples/icosphere.rs @@ -114,7 +114,7 @@ fn setup( commands.spawn(( PointLight { intensity: 1600.0, // lumens - roughly a 100W non-halogen incandescent bulb - shadows_enabled: true, + shadow_maps_enabled: true, ..default() }, Transform::from_xyz(4.0, RADIUS + 8.0, 4.0), diff --git a/examples/ocean.rs b/examples/ocean.rs index 83c430f..6fb4c70 100644 --- a/examples/ocean.rs +++ b/examples/ocean.rs @@ -4,6 +4,7 @@ use bevy::light::NotShadowCaster; use bevy::mesh::*; use bevy::prelude::*; +use bevy::world_serialization::WorldAssetRoot; mod pirates; use pirates::*; @@ -56,7 +57,7 @@ fn setup_simple_ocean( /// Setup some simple ships. fn setup_simple_ships(mut commands: Commands, asset_server: Res) { // Spawn ships. - let scene = SceneRoot(asset_server.load("models/Kenney_pirate/ship_dark.gltf#Scene0")); + let scene = asset_server.load("models/Kenney_pirate/ship_dark.gltf#Scene0"); let ship = Ship::new(-0.400, -3.8, 2.5, -1.4, 1.4); // "Randomly" place the ships. @@ -66,7 +67,7 @@ fn setup_simple_ships(mut commands: Commands, asset_server: Res) { commands.spawn(( ship.clone(), Name::new(format!("Ship {x}")), - scene.clone(), + WorldAssetRoot(scene.clone()), Transform::from_xyz(-20.0 + (f * 7.8), 0.0, 20.0 + f2) .with_rotation(Quat::from_rotation_y(f)), )); diff --git a/examples/pirates.rs b/examples/pirates.rs index 497e79d..3c29652 100644 --- a/examples/pirates.rs +++ b/examples/pirates.rs @@ -16,6 +16,7 @@ use bevy::anti_alias::taa::TemporalAntiAliasing; use bevy::camera_controller::free_camera::{FreeCamera, FreeCameraPlugin}; #[cfg(feature = "debug")] use bevy::color::palettes::css::*; +use bevy::light::atmosphere::ScatteringMedium; use bevy::mesh::*; use bevy::pbr::wireframe::{Wireframe, WireframePlugin}; #[cfg(not(feature = "atmosphere"))] @@ -32,12 +33,12 @@ use bevy::{ }; use bevy::{ app::AppExit, - camera::Exposure, + camera::{Exposure, Hdr}, input::{common_conditions, keyboard::KeyCode}, light::{light_consts::lux, FogVolume, VolumetricLight}, - pbr::ScatteringMedium, prelude::*, - render::{render_resource::TextureFormat, view::Hdr}, + render::render_resource::TextureFormat, + world_serialization::WorldAssetRoot, }; use bevy_water::*; @@ -434,14 +435,14 @@ pub fn setup_orb( /// Create a simple 3D camera pub fn make_camera<'a>( commands: &'a mut Commands, - _scattering_mediums: &mut Assets, + _mediums: &mut Assets, _asset_server: &AssetServer, ) -> EntityCommands<'a> { // Sun commands.spawn(( Sun, DirectionalLight { - shadows_enabled: true, + shadow_maps_enabled: true, illuminance: if cfg!(feature = "atmosphere") { // lux::RAW_SUNLIGHT is recommended for use with this feature, since // other values approximate sunlight *post-scattering* in various @@ -493,7 +494,7 @@ pub fn make_camera<'a>( { cam.insert(( // Earthlike atmosphere - Atmosphere::earthlike(_scattering_mediums.add(ScatteringMedium::default())), + Atmosphere::earth(mediums.add(ScatteringMedium::earth())), // Can be adjusted to change the scene scale and rendering quality AtmosphereSettings::default(), // The directional light illuminance used in this scene @@ -548,7 +549,9 @@ pub fn make_camera<'a>( ..default() }, Skybox { - image: _asset_server.load("environment_maps/table_mountain_2_puresky_4k_cubemap.ktx2"), + image: Some( + _asset_server.load("environment_maps/table_mountain_2_puresky_4k_cubemap.ktx2"), + ), brightness: 2000.0, ..default() }, @@ -575,17 +578,16 @@ pub fn make_camera<'a>( /// set up a simple 3D camera pub fn setup_camera( mut commands: Commands, - mut scattering_mediums: ResMut>, + mut mediums: ResMut>, asset_server: Res, ) { - make_camera(&mut commands, &mut scattering_mediums, &asset_server); + make_camera(&mut commands, &mut mediums, &asset_server); } /// Spawn some dutch ships. pub fn setup_ships(mut commands: Commands, asset_server: Res) { // Spawn ships. - let scene = - SceneRoot(asset_server.load("models/dutch_ship_medium_1k/dutch_ship_medium_1k.gltf#Scene0")); + let scene = asset_server.load("models/dutch_ship_medium_1k/dutch_ship_medium_1k.gltf#Scene0"); let ship = Ship::new(-0.400, -8.0, 9.0, -2.0, 2.0); // "Randomly" place the ships. @@ -601,7 +603,7 @@ pub fn setup_ships(mut commands: Commands, asset_server: Res) { )) .with_children(|parent| { parent.spawn(( - scene.clone(), + WorldAssetRoot(scene.clone()), // Rotate ship model to line up with rotation axis. Transform::from_rotation(Quat::from_rotation_y(std::f32::consts::FRAC_PI_2)), )); diff --git a/examples/pirates_bevy_sky.rs b/examples/pirates_bevy_sky.rs index 1f5dba7..234773a 100644 --- a/examples/pirates_bevy_sky.rs +++ b/examples/pirates_bevy_sky.rs @@ -9,22 +9,23 @@ use bevy::camera_controller::free_camera::{FreeCamera, FreeCameraPlugin}; use bevy::color::palettes::css::*; use bevy::mesh::*; use bevy::pbr::wireframe::{Wireframe, WireframePlugin}; -use bevy::render::view::Hdr; use bevy::{ anti_alias::fxaa::Fxaa, app::AppExit, - camera::Exposure, + camera::{Exposure, Hdr}, core_pipeline::tonemapping::Tonemapping, input::keyboard::KeyCode, light::{ - light_consts::lux, AtmosphereEnvironmentMapLight, CascadeShadowConfigBuilder, FogVolume, - VolumetricFog, VolumetricLight, + light_consts::lux, Atmosphere, AtmosphereEnvironmentMapLight, CascadeShadowConfigBuilder, + FogVolume, VolumetricFog, VolumetricLight, }, - pbr::{Atmosphere, AtmosphereMode, AtmosphereSettings, ScatteringMedium, ScreenSpaceReflections}, + pbr::{AtmosphereMode, AtmosphereSettings, ScreenSpaceReflections}, post_process::bloom::Bloom, prelude::*, render::render_resource::TextureFormat, + world_serialization::WorldAssetRoot, }; +use bevy::light::atmosphere::ScatteringMedium; use std::f32::consts::PI; use bevy_water::*; @@ -283,7 +284,7 @@ pub fn setup_ocean( commands.spawn(( Sun, DirectionalLight { - shadows_enabled: true, + shadow_maps_enabled: true, // lux::RAW_SUNLIGHT is recommended for use with this feature, since // other values approximate sunlight *post-scattering* in various // conditions. RAW_SUNLIGHT in comparison is the illuminance of the @@ -434,7 +435,7 @@ pub fn setup_orb( /// Create a simple 3D camera pub fn make_camera<'a>( commands: &'a mut Commands, - scattering_mediums: &mut Assets, + mediums: &mut Assets, _asset_server: &AssetServer, ) -> EntityCommands<'a> { // camera @@ -443,7 +444,7 @@ pub fn make_camera<'a>( Hdr, Transform::from_xyz(-1.2, 5.15, 0.0).looking_at(Vec3::Y * 5.0, Vec3::Y), // Earthlike atmosphere - Atmosphere::earthlike(scattering_mediums.add(ScatteringMedium::default())), + Atmosphere::earth(mediums.add(ScatteringMedium::earth(256, 256))), // Can be adjusted to change the scene scale and rendering quality AtmosphereSettings::default(), // The directional light illuminance used in this scene @@ -482,17 +483,16 @@ pub fn make_camera<'a>( /// set up a simple 3D camera pub fn setup_camera( mut commands: Commands, - mut scattering_mediums: ResMut>, + mut mediums: ResMut>, asset_server: Res, ) { - make_camera(&mut commands, &mut scattering_mediums, &asset_server); + make_camera(&mut commands, &mut mediums, &asset_server); } /// Spawn some dutch ships. pub fn setup_ships(mut commands: Commands, asset_server: Res) { // Spawn ships. - let scene = - SceneRoot(asset_server.load("models/dutch_ship_medium_1k/dutch_ship_medium_1k.gltf#Scene0")); + let scene = asset_server.load("models/dutch_ship_medium_1k/dutch_ship_medium_1k.gltf#Scene0"); let ship = Ship::new(-0.400, -8.0, 9.0, -2.0, 2.0); // "Randomly" place the ships. @@ -508,7 +508,7 @@ pub fn setup_ships(mut commands: Commands, asset_server: Res) { )) .with_children(|parent| { parent.spawn(( - scene.clone(), + WorldAssetRoot(scene.clone()), // Rotate ship model to line up with rotation axis. Transform::from_rotation(Quat::from_rotation_y(std::f32::consts::FRAC_PI_2)), )); diff --git a/examples/pirates_taa.rs b/examples/pirates_taa.rs index 9c8224f..d87b8a4 100644 --- a/examples/pirates_taa.rs +++ b/examples/pirates_taa.rs @@ -1,7 +1,8 @@ //! Showcases dynamic ocean material + dynamic Sun/Atmosphere. //! Most of the daylight cycle code taken from the examples of `bevy_atmosphere`. -use bevy::{anti_alias::taa::TemporalAntiAliasing, pbr::ScatteringMedium, prelude::*}; +use bevy::{anti_alias::taa::TemporalAntiAliasing, prelude::*}; +use bevy::light::atmosphere::ScatteringMedium; mod pirates; use pirates::*; @@ -21,10 +22,10 @@ fn main() { /// set up a simple 3D scene fn setup_camera_taa( mut commands: Commands, - mut scattering_mediums: ResMut>, + mut mediums: ResMut>, asset_server: Res, ) { // camera - let mut cam = make_camera(&mut commands, &mut scattering_mediums, &asset_server); + let mut cam = make_camera(&mut commands, &mut mediums, &asset_server); cam.insert((Msaa::Off, TemporalAntiAliasing::default())); } diff --git a/examples/simple.rs b/examples/simple.rs index 9c3a420..4a1e872 100644 --- a/examples/simple.rs +++ b/examples/simple.rs @@ -75,7 +75,7 @@ fn setup( commands.spawn(( PointLight { intensity: 1600.0, // lumens - roughly a 100W non-halogen incandescent bulb - shadows_enabled: true, + shadow_maps_enabled: true, ..default() }, Transform::from_xyz(4.0, WATER_HEIGHT + 8.0, 4.0), diff --git a/examples/uvsphere.rs b/examples/uvsphere.rs index b6af696..f8e3d1f 100644 --- a/examples/uvsphere.rs +++ b/examples/uvsphere.rs @@ -88,7 +88,7 @@ fn setup( commands.spawn(( PointLight { intensity: 1600.0, // lumens - roughly a 100W non-halogen incandescent bulb - shadows_enabled: true, + shadow_maps_enabled: true, ..default() }, Transform::from_xyz(4.0, RADIUS + 8.0, 4.0), diff --git a/examples/wave_direction.rs b/examples/wave_direction.rs index 3c3a0d0..650a272 100644 --- a/examples/wave_direction.rs +++ b/examples/wave_direction.rs @@ -92,7 +92,7 @@ fn setup( commands.spawn(( DirectionalLight { illuminance: 10000.0, - shadows_enabled: true, + shadow_maps_enabled: true, ..default() }, Transform::from_xyz(4.0, 10.0, 4.0).looking_at(Vec3::ZERO, Vec3::Y), diff --git a/src/image_utils.rs b/src/image_utils.rs index 23e17ab..9fbafa6 100644 --- a/src/image_utils.rs +++ b/src/image_utils.rs @@ -2,7 +2,7 @@ use bevy::{ image::ImageSampler, prelude::*, render::render_resource::{ - AddressMode, FilterMode, SamplerDescriptor, TextureFormat, TextureViewDescriptor, + AddressMode, MipmapFilterMode, SamplerDescriptor, TextureFormat, TextureViewDescriptor, TextureViewDimension, }, }; @@ -63,7 +63,7 @@ impl ImageReformat { address_mode_u: AddressMode::Repeat, address_mode_v: AddressMode::Repeat, address_mode_w: AddressMode::Repeat, - mipmap_filter: FilterMode::Linear, + mipmap_filter: MipmapFilterMode::Linear, ..default() }; Self::new(commands, asset_server, name, ImageAction::Sampler(sampler)) @@ -77,7 +77,7 @@ fn reformat_image( mut images: ResMut>, ) -> Result { for (entity, reformat) in &query { - if let Some(image) = images.get_mut(&reformat.image) { + if let Some(mut image) = images.get_mut(&reformat.image) { match &reformat.action { ImageAction::Reformat(format) => { info!("Reformat {}", reformat.name); @@ -86,9 +86,8 @@ fn reformat_image( ImageAction::Cubemap => { if image.texture_descriptor.array_layer_count() == 1 { info!("Reinterpret 2D image {}", reformat.name); - image.reinterpret_stacked_2d_as_array( - image.texture_descriptor.size.height / image.texture_descriptor.size.width, - )?; + let layers = image.texture_descriptor.size.height / image.texture_descriptor.size.width; + image.reinterpret_stacked_2d_as_array(layers)?; image.texture_view_descriptor = Some(TextureViewDescriptor { dimension: Some(TextureViewDimension::Cube), ..default() diff --git a/src/water.rs b/src/water.rs index 726465c..09a9461 100644 --- a/src/water.rs +++ b/src/water.rs @@ -476,7 +476,7 @@ pub fn apply_wave_direction( water_tiles: Query<(&MeshMaterial3d, &WaveDirection)>, ) { for (material_handle, wave_dir) in water_tiles.iter() { - if let Some(mat) = materials.get_mut(&material_handle.0) { + if let Some(mut mat) = materials.get_mut(&material_handle.0) { mat.extension.wave_dir_a = wave_dir.dir_a(); mat.extension.wave_dir_b = wave_dir.dir_b(); mat.extension.wave_blend = wave_dir.blend();