Skip to content

Commit

Permalink
Merge branch 'feature/bevy-0.14'
Browse files Browse the repository at this point in the history
  • Loading branch information
Utsira committed Jul 4, 2024
2 parents dd7223c + 75e0f13 commit 71ebaa8
Show file tree
Hide file tree
Showing 17 changed files with 304 additions and 272 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ name = "voxel-generation"
required-features = ["generate_voxels"]

[dependencies]
bevy = { version = "0.13.0", default-features = false, features = [
bevy = { version = "0.14.0", default-features = false, features = [
"bevy_render",
"bevy_asset",
"bevy_pbr",
Expand All @@ -47,7 +47,7 @@ thiserror = "1.0.50"
serde = "1.0.193"

[dev-dependencies]
bevy = "0.13.0"
bevy = "0.14.0"
utilities = { path = "utilities" }
rand = "0.8.5"
async-std = { version = "1.12.0", features = ["attributes"] }
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![Latest version](https://img.shields.io/crates/v/bevy_vox_scene.svg)](https://crates.io/crates/bevy_vox_scene)
[![docs.rs](https://docs.rs/bevy_vox_scene/badge.svg)](https://docs.rs/bevy_vox_scene)
[![CI](https://github.com/Utsira/bevy_vox_scene/actions/workflows/ci.yml/badge.svg)](https://github.com/Utsira/bevy_vox_scene/actions/workflows/ci.yml)
[![dependency status](https://deps.rs/crate/bevy_vox_scene/0.13.0/status.svg)](https://deps.rs/crate/bevy_vox_scene/0.13.0)
[![dependency status](https://deps.rs/crate/bevy_vox_scene/0.14.0/status.svg)](https://deps.rs/crate/bevy_vox_scene/0.14.0)
[![Bevy tracking](https://img.shields.io/badge/Bevy%20tracking-released%20version-lightblue)](https://bevyengine.org/learn/book/plugin-development/#main-branch-tracking)
[![codecov](https://codecov.io/gh/Utsira/bevy_vox_scene/graph/badge.svg?token=29AR6PVOYP)](https://codecov.io/gh/Utsira/bevy_vox_scene)

Expand Down Expand Up @@ -34,7 +34,7 @@ All Magica Voxel material types except "cloud" are supported. Bevy's screen spac

```toml
[dependencies]
bevy_vox_scene = "0.13.0"
bevy_vox_scene = "0.14.0"
```

Then in code:
Expand Down Expand Up @@ -78,6 +78,7 @@ cargo run --example <example name>
| ------------ | -------------- | --- |
| 0.12 | 0.99.6 | 0.9, 0.10, 0.11, 0.12 |
| 0.13 | | 0.13 |
| 0.14 | | 0.14 |

## Limitations and workarounds

Expand Down
2 changes: 1 addition & 1 deletion examples/modify-scene.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ fn swim_fish(mut query: Query<(&mut Transform, &Fish)>, time: Res<Time>) {
|| (x_direction > 0.5 && transform.translation.x > tank_half_extents.x)
{
// change direction at tank edges
transform.rotate_axis(Vec3::Y, PI);
transform.rotate_axis(Dir3::Y, PI);
}
// slow down when near the edge
let slow_down = 1.0
Expand Down
2 changes: 1 addition & 1 deletion examples/ssao-model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fn main() {

app.add_plugins((DefaultPlugins, PanOrbitCameraPlugin, VoxScenePlugin))
.insert_resource(AmbientLight {
color: Color::rgb_u8(128, 126, 124),
color: Color::srgb_u8(128, 126, 124),
brightness: 0.5,
})
.add_systems(Startup, setup)
Expand Down
44 changes: 22 additions & 22 deletions examples/transmission-scene.rs
Original file line number Diff line number Diff line change
@@ -1,28 +1,24 @@
use bevy::{
core_pipeline::{
bloom::BloomSettings,
core_3d::ScreenSpaceTransmissionQuality,
experimental::taa::{TemporalAntiAliasBundle, TemporalAntiAliasPlugin},
tonemapping::Tonemapping,
},
prelude::*,
bloom::BloomSettings, core_3d::ScreenSpaceTransmissionQuality, experimental::taa::{TemporalAntiAliasBundle, TemporalAntiAliasPlugin}, tonemapping::Tonemapping
}, pbr::{VolumetricFogSettings, VolumetricLight}, prelude::*
};
use utilities::{PanOrbitCamera, PanOrbitCameraPlugin};
use bevy_vox_scene::{VoxScenePlugin, VoxelSceneBundle};

fn main() {
let mut app = App::new();

app.add_plugins((DefaultPlugins, PanOrbitCameraPlugin, VoxScenePlugin))
.add_systems(Startup, setup);

.add_systems(Startup, setup);
// *Note:* TAA is not _required_ for specular transmission, but
// it _greatly enhances_ the look of the resulting blur effects.
// Sadly, it's not available under WebGL.
#[cfg(not(all(feature = "webgl2", target_arch = "wasm32")))]
app.insert_resource(Msaa::Off)
.add_plugins(TemporalAntiAliasPlugin);

.add_plugins(TemporalAntiAliasPlugin);
app.run();
}

Expand All @@ -39,7 +35,7 @@ fn setup(mut commands: Commands, assets: Res<AssetServer>) {
..default()
},
transform: Transform::from_xyz(8.0, 1.5, 8.0).looking_at(Vec3::ZERO, Vec3::Y),
tonemapping: Tonemapping::SomewhatBoringDisplayTransform,
tonemapping: Tonemapping::BlenderFilmic,
..Default::default()
},
PanOrbitCamera::default(),
Expand All @@ -54,18 +50,22 @@ fn setup(mut commands: Commands, assets: Res<AssetServer>) {
specular_map: assets.load("pisa_specular.ktx2"),
intensity: 500.0,
},
VolumetricFogSettings::default(),
));

commands.spawn(DirectionalLightBundle {
directional_light: DirectionalLight {
illuminance: 5000.0,
shadows_enabled: true,
..Default::default()

commands.spawn((
DirectionalLightBundle {
directional_light: DirectionalLight {
illuminance: 5000.0,
shadows_enabled: true,
..Default::default()
},
transform: Transform::IDENTITY.looking_to(Vec3::new(2.5, -1., 0.85), Vec3::Y),
..default()
},
transform: Transform::IDENTITY.looking_to(Vec3::new(1.0, -2.5, 0.85), Vec3::Y),
..default()
});

VolumetricLight,
));

commands.spawn(VoxelSceneBundle {
scene: assets.load("study.vox"),
transform: Transform::from_scale(Vec3::splat(0.05)),
Expand Down
39 changes: 33 additions & 6 deletions examples/voxel-collisions.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
use std::time::Duration;

use bevy::{
core_pipeline::{bloom::BloomSettings, tonemapping::Tonemapping},
prelude::*,
time::common_conditions::on_timer,
core_pipeline::{bloom::BloomSettings, dof::{DepthOfFieldMode, DepthOfFieldSettings}, tonemapping::Tonemapping}, gizmos::gizmos, prelude::*, time::common_conditions::on_timer
};
use utilities::{PanOrbitCamera, PanOrbitCameraPlugin};
use bevy_vox_scene::{
Expand All @@ -21,9 +19,12 @@ fn main() {
App::new()
.add_plugins((DefaultPlugins, PanOrbitCameraPlugin, VoxScenePlugin))
.add_systems(Startup, setup)
.add_systems(
Update,
(spawn_snow.run_if(on_timer(snow_spawn_freq)), update_snow),
.add_systems(Update,
(
spawn_snow.run_if(on_timer(snow_spawn_freq)),
update_snow,
focus_camera,
),
)
.run();
}
Expand Down Expand Up @@ -54,6 +55,12 @@ fn setup(mut commands: Commands, assets: Res<AssetServer>) {
specular_map: assets.load("pisa_specular.ktx2"),
intensity: 500.0,
},
DepthOfFieldSettings {
mode: DepthOfFieldMode::Bokeh,
focal_distance: 8.,
aperture_f_stops: 0.003,
..default()
},
));
commands.insert_resource(Scenes {
snowflake: assets.load("study.vox#snowflake"),
Expand All @@ -66,6 +73,12 @@ fn setup(mut commands: Commands, assets: Res<AssetServer>) {
if entity.get::<VoxelModelInstance>().is_some() {
commands.insert(Scenery);
}
if let Some(name) = entity.get::<Name>() {
if name.as_str() == "workstation/computer" {
// Focus on the computer screen
commands.insert(FocalPoint(Vec3::new(0., 0., 9.)));
}
}
}),
..default()
});
Expand All @@ -77,6 +90,9 @@ struct Snowflake(Quat);
#[derive(Component)]
struct Scenery;

#[derive(Component)]
struct FocalPoint(Vec3);

fn spawn_snow(mut commands: Commands, scenes: Res<Scenes>) {
let mut rng = rand::thread_rng();
let position = Vec3::new(rng.gen_range(-30.0..30.0), 80.0, rng.gen_range(-20.0..20.0)).round()
Expand Down Expand Up @@ -152,3 +168,14 @@ fn update_snow(
}
}
}

// Focus the camera on the focal point when the camera moves
fn focus_camera(
mut camera: Query<(&mut DepthOfFieldSettings, &GlobalTransform), Changed<Transform>>,
target: Query<(&GlobalTransform, &FocalPoint)>,
) {
let Some((target_xform, focal_point)) = target.iter().next() else { return };
let Ok((mut dof, camera_xform)) = camera.get_single_mut() else { return };
let target_point = target_xform.transform_point(focal_point.0);
dof.focal_distance = camera_xform.translation().distance(target_point);
}
2 changes: 1 addition & 1 deletion examples/voxel-generation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn setup_camera(mut commands: Commands, assets: Res<AssetServer>) {
}

fn setup(world: &mut World) {
let palette = VoxelPalette::from_colors(vec![Color::BLUE, Color::ALICE_BLUE, Color::BISQUE]);
let palette = VoxelPalette::from_colors(vec![bevy::color::palettes::css::BLUE.into(), bevy::color::palettes::css::ALICE_BLUE.into(), bevy::color::palettes::css::BISQUE.into()]);
let data = SDF::cuboid(Vec3::splat(13.0))
.subtract(SDF::sphere(16.0))
.map_to_voxels(UVec3::splat(32), |d, _| match d {
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
//! # if all_names.is_empty() { return };
//! # let expected_names: HashSet<&str> = ["snowflake", "wall-tile", "brick-tile", "floor", "workstation", "workstation/keyboard" , "workstation/desk", "workstation/computer", "stairs", "glass", "tank", "tank/tetra", "tank/black-light", "tank/goldfish", "tank/wall", "tank/water", "tank/scenery"].into();
//! # assert_eq!(all_names, expected_names);
//! # exit.send(AppExit);
//! # exit.send(AppExit::Success);
//! # }
//!```

Expand Down
Loading

0 comments on commit 71ebaa8

Please sign in to comment.