Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
2 changes: 1 addition & 1 deletion examples/cube.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion examples/icosphere.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
5 changes: 3 additions & 2 deletions examples/ocean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use bevy::light::NotShadowCaster;
use bevy::mesh::*;
use bevy::prelude::*;
use bevy::world_serialization::WorldAssetRoot;

mod pirates;
use pirates::*;
Expand Down Expand Up @@ -56,7 +57,7 @@ fn setup_simple_ocean(
/// Setup some simple ships.
fn setup_simple_ships(mut commands: Commands, asset_server: Res<AssetServer>) {
// 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.
Expand All @@ -66,7 +67,7 @@ fn setup_simple_ships(mut commands: Commands, asset_server: Res<AssetServer>) {
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)),
));
Expand Down
26 changes: 14 additions & 12 deletions examples/pirates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"))]
Expand All @@ -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::*;
Expand Down Expand Up @@ -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<ScatteringMedium>,
_mediums: &mut Assets<ScatteringMedium>,
_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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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()
},
Expand All @@ -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<Assets<ScatteringMedium>>,
mut mediums: ResMut<Assets<ScatteringMedium>>,
asset_server: Res<AssetServer>,
) {
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<AssetServer>) {
// 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.
Expand All @@ -601,7 +603,7 @@ pub fn setup_ships(mut commands: Commands, asset_server: Res<AssetServer>) {
))
.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)),
));
Expand Down
26 changes: 13 additions & 13 deletions examples/pirates_bevy_sky.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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<ScatteringMedium>,
mediums: &mut Assets<ScatteringMedium>,
_asset_server: &AssetServer,
) -> EntityCommands<'a> {
// camera
Expand All @@ -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
Expand Down Expand Up @@ -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<Assets<ScatteringMedium>>,
mut mediums: ResMut<Assets<ScatteringMedium>>,
asset_server: Res<AssetServer>,
) {
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<AssetServer>) {
// 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.
Expand All @@ -508,7 +508,7 @@ pub fn setup_ships(mut commands: Commands, asset_server: Res<AssetServer>) {
))
.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)),
));
Expand Down
7 changes: 4 additions & 3 deletions examples/pirates_taa.rs
Original file line number Diff line number Diff line change
@@ -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::*;
Expand All @@ -21,10 +22,10 @@ fn main() {
/// set up a simple 3D scene
fn setup_camera_taa(
mut commands: Commands,
mut scattering_mediums: ResMut<Assets<ScatteringMedium>>,
mut mediums: ResMut<Assets<ScatteringMedium>>,
asset_server: Res<AssetServer>,
) {
// 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()));
}
2 changes: 1 addition & 1 deletion examples/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion examples/uvsphere.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion examples/wave_direction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
11 changes: 5 additions & 6 deletions src/image_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use bevy::{
image::ImageSampler,
prelude::*,
render::render_resource::{
AddressMode, FilterMode, SamplerDescriptor, TextureFormat, TextureViewDescriptor,
AddressMode, MipmapFilterMode, SamplerDescriptor, TextureFormat, TextureViewDescriptor,
TextureViewDimension,
},
};
Expand Down Expand Up @@ -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))
Expand All @@ -77,7 +77,7 @@ fn reformat_image(
mut images: ResMut<Assets<Image>>,
) -> 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);
Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion src/water.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ pub fn apply_wave_direction(
water_tiles: Query<(&MeshMaterial3d<StandardWaterMaterial>, &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();
Expand Down