From d66c53a0a674009307c00ce1380f81c23a413daf Mon Sep 17 00:00:00 2001 From: Jerome Humbert Date: Tue, 12 Nov 2024 20:44:34 +0000 Subject: [PATCH] Upgrade to Bevy v0.15.0 --- CHANGELOG.md | 12 + Cargo.toml | 94 +++--- README.md | 10 +- examples/2d.rs | 42 ++- examples/activate.rs | 88 +++--- examples/billboard.rs | 40 ++- examples/circle.rs | 46 ++- examples/expr.rs | 19 +- examples/firework.rs | 20 +- examples/force_field.rs | 89 +++--- examples/gradient.rs | 34 +- examples/init.rs | 40 +-- examples/instancing.rs | 35 +-- examples/lifetime.rs | 47 +-- examples/multicam.rs | 76 ++--- examples/ordering.rs | 83 +++-- examples/portal.rs | 18 +- examples/puffs.rs | 45 ++- examples/random.rs | 30 +- examples/ribbon.rs | 20 +- examples/spawn.rs | 49 ++- examples/spawn_on_command.rs | 77 +++-- examples/visibility.rs | 48 ++- examples/worms.rs | 20 +- gpu_tests/empty_effect.rs | 5 +- run_examples.bat | 42 +-- src/asset.rs | 12 +- src/attributes.rs | 122 +++++--- src/gradient.rs | 13 +- src/graph/expr.rs | 40 ++- src/lib.rs | 39 ++- src/modifier/mod.rs | 2 +- src/plugin.rs | 8 +- src/render/batch.rs | 13 +- src/render/buffer_table.rs | 30 +- src/render/effect_cache.rs | 73 ++++- src/render/mod.rs | 584 ++++++++++++++++++++++------------- src/render/vfx_common.wgsl | 22 +- src/render/vfx_indirect.wgsl | 4 +- src/spawn.rs | 6 +- src/test_utils.rs | 2 +- src/time.rs | 12 +- 42 files changed, 1169 insertions(+), 942 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cdc98521..41565eb7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,18 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Added + +- Added a `TextureLayout::get_slot_by_name()` helper to retrieve the index of a texture slot. + +### Changed + +- Compatible with Bevy 0.15 +- Renamed `Module::add_texture()` to `add_texture_slot()` for clarity. + The actual texture is bound to the slot through the `MaterialEffect` component. + ## [0.13.1] 2024-11-16 ### Fixed diff --git a/Cargo.toml b/Cargo.toml index 509e6ae8..bbf7dd53 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "bevy_hanabi" -version = "0.13.1" +version = "0.14.0-dev" authors = ["Jerome Humbert "] edition = "2021" description = "Hanabi GPU particle system for the Bevy game engine" @@ -16,10 +16,10 @@ autoexamples = false [features] default = ["2d", "3d", "serde", "gpu_tests", "examples_world_inspector"] -# Enable support for rendering through a 2D camera (Camera2dBundle) +# Enable support for rendering through a 2D camera (Camera2d) 2d = [] -# Enable support for rendering through a 3D camera (Camera3dBundle) +# Enable support for rendering through a 3D camera (Camera3d) 3d = [] # Enable serializing and deserializing of assets. This doesn't work on WASM, @@ -54,29 +54,48 @@ ron = "0.8" bitflags = "2.3" typetag = { version = "0.2", optional = true } thiserror = "1.0" -# Same versions as Bevy 0.14 (bevy_render) -wgpu = "0.20" -naga = "0.20" -naga_oil = { version = "0.14", default-features = false, features = ["test_shader"] } +# Same versions as Bevy 0.15 (bevy_render) +wgpu = { version = "23.0.1", default-features = false, features = [ + "wgsl", + "dx12", + "metal", + "naga-ir", + "fragile-send-sync-non-atomic-wasm", +] } +naga = { version = "23", features = ["wgsl-in"] } +naga_oil = { version = "0.16", default-features = false, features = ["test_shader"] } [dependencies.bevy] -version = "0.14" +version = "0.15" default-features = false -features = [ "bevy_core_pipeline", "bevy_render", "bevy_asset", "x11" ] +features = [ + "bevy_core_pipeline", + "bevy_render", + "bevy_asset", + "x11", + # Bug in Bevy 0.15 [16563] + "png" +] [package.metadata.docs.rs] all-features = true [dev-dependencies] +# TEMP - Waiting for crates to update to Bevy 0.15... # For world inspector; required if "examples_world_inspector" is used. -bevy-inspector-egui = "0.27" -bevy_egui = { version = "0.30", default-features = false, features = [ - "manage_clipboard", "open_url" -] } -egui = "0.29" +#bevy-inspector-egui = "0.27" +#bevy_egui = { version = "0.30", default-features = false, features = [ +# "manage_clipboard", "open_url" +#] } +#egui = "0.29" + +bevy_sprite = "0.15" +bevy_text = "0.15" +bevy_ui = "0.15" +bevy_window = "0.15" # For glTF animations (Fox.glb) -bevy_gltf = { version = "0.14", features = [ "bevy_animation" ] } +bevy_gltf = { version = "0.15", features = [ "bevy_animation" ] } # For procedural texture generation in examples noise = "0.9" @@ -85,88 +104,89 @@ futures = "0.3" [[example]] name = "firework" -required-features = [ "bevy/bevy_winit", "bevy/bevy_pbr", "3d" ] +required-features = [ "bevy/bevy_winit", "bevy/bevy_window", "bevy/bevy_pbr", "3d" ] [[example]] name = "portal" -required-features = [ "bevy/bevy_winit", "bevy/bevy_pbr", "3d" ] +required-features = [ "bevy/bevy_winit", "bevy/bevy_window", "bevy/bevy_pbr", "3d" ] [[example]] name = "expr" -required-features = [ "bevy/bevy_winit", "bevy/bevy_pbr", "3d" ] +required-features = [ "bevy/bevy_winit", "bevy/bevy_window", "bevy/bevy_pbr", "3d" ] [[example]] name = "spawn" -required-features = [ "bevy/bevy_winit", "bevy/bevy_pbr", "3d" ] +required-features = [ "bevy/bevy_winit", "bevy/bevy_window", "bevy/bevy_pbr", "3d" ] [[example]] name = "multicam" -required-features = [ "bevy/bevy_winit", "bevy/bevy_pbr", "3d" ] +required-features = [ "bevy/bevy_winit", "bevy/bevy_window", "bevy/bevy_pbr", "3d" ] [[example]] name = "visibility" -required-features = [ "bevy/bevy_winit", "bevy/bevy_pbr", "3d" ] +required-features = [ "bevy/bevy_winit", "bevy/bevy_window", "bevy/bevy_pbr", "3d" ] [[example]] name = "random" -required-features = [ "bevy/bevy_winit", "bevy/bevy_pbr", "3d" ] +required-features = [ "bevy/bevy_winit", "bevy/bevy_window", "bevy/bevy_pbr", "3d" ] [[example]] name = "spawn_on_command" -required-features = [ "bevy/bevy_winit", "bevy/bevy_pbr", "3d" ] +required-features = [ "bevy/bevy_winit", "bevy/bevy_window", "bevy/bevy_pbr", "3d" ] [[example]] name = "activate" -required-features = [ "bevy/bevy_winit", "bevy/bevy_pbr", "bevy/bevy_ui", "bevy/default_font", "3d" ] +required-features = [ "bevy/bevy_winit", "bevy/bevy_window", "bevy/bevy_pbr", "bevy/bevy_ui", "bevy/default_font", "3d" ] [[example]] name = "force_field" -required-features = [ "bevy/bevy_winit", "bevy/bevy_pbr", "3d" ] +required-features = [ "bevy/bevy_winit", "bevy/bevy_window", "bevy/bevy_pbr", "3d" ] [[example]] name = "lifetime" -required-features = [ "bevy/bevy_winit", "bevy/bevy_pbr", "3d" ] +required-features = [ "bevy/bevy_winit", "bevy/bevy_window", "bevy/bevy_pbr", "3d" ] [[example]] name = "init" -required-features = [ "bevy/bevy_winit", "bevy/bevy_pbr", "3d" ] +required-features = [ "bevy/bevy_winit", "bevy/bevy_window", "bevy/bevy_pbr", "3d" ] [[example]] name = "instancing" -required-features = [ "bevy/bevy_winit", "bevy/bevy_pbr", "bevy/png", "3d" ] +required-features = [ "bevy/bevy_winit", "bevy/bevy_window", "bevy/bevy_pbr", "bevy/png", "3d" ] [[example]] name = "gradient" -required-features = [ "bevy/bevy_winit", "bevy/bevy_pbr", "bevy/png", "3d" ] +required-features = [ "bevy/bevy_winit", "bevy/bevy_window", "bevy/bevy_pbr", "bevy/png", "3d" ] [[example]] name = "circle" -required-features = [ "bevy/bevy_winit", "bevy/bevy_pbr", "bevy/png", "3d" ] +required-features = [ "bevy/bevy_winit", "bevy/bevy_window", "bevy/bevy_pbr", "bevy/png", "3d" ] [[example]] name = "billboard" -required-features = [ "bevy/bevy_winit", "bevy/bevy_pbr", "bevy/png", "3d" ] +required-features = [ "bevy/bevy_winit", "bevy/bevy_window", "bevy/bevy_pbr", "bevy/png", "3d" ] [[example]] name = "2d" -required-features = [ "bevy/bevy_winit", "bevy/bevy_sprite", "2d" ] +required-features = [ "bevy/bevy_winit", "bevy/bevy_window", "bevy/bevy_sprite", "2d" ] [[example]] name = "worms" -required-features = [ "bevy/bevy_winit", "bevy/bevy_pbr", "bevy/png", "3d" ] +required-features = [ "bevy/bevy_winit", "bevy/bevy_window", "bevy/bevy_pbr", "bevy/png", "3d" ] [[example]] name = "ribbon" -required-features = [ "bevy/bevy_winit", "bevy/bevy_pbr", "3d" ] +required-features = [ "bevy/bevy_winit", "bevy/bevy_window", "bevy/bevy_pbr", "3d" ] [[example]] name = "ordering" -required-features = [ "bevy/bevy_winit", "bevy/bevy_pbr", "3d" ] +required-features = [ "bevy/bevy_winit", "bevy/bevy_window", "bevy/bevy_pbr", "3d" ] [[example]] name = "puffs" required-features = [ "bevy/bevy_winit", + "bevy/bevy_window", "bevy/bevy_pbr", "bevy/bevy_scene", "bevy/bevy_gltf", @@ -179,6 +199,10 @@ required-features = [ name = "empty_effect" path = "gpu_tests/empty_effect.rs" harness = false +required-features = [ + "bevy/bevy_winit", + "bevy/bevy_window", +] [workspace] resolver = "2" diff --git a/README.md b/README.md index 4221df86..81759ea4 100644 --- a/README.md +++ b/README.md @@ -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.14-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.15-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. @@ -190,8 +190,8 @@ This list contains the major fixed features provided by 🎆 Hanabi. Beyond that - [x] Trails / Ribbons - [x] Camera support - [x] Render layers - - [x] 2D cameras ([`Camera2dBundle`](https://docs.rs/bevy/0.14.0/bevy/core_pipeline/core_2d/struct.Camera2dBundle.html)) only - - [x] 3D cameras ([`Camera3dBundle`](https://docs.rs/bevy/0.14.0/bevy/core_pipeline/core_3d/struct.Camera3dBundle.html)) only + - [x] 2D cameras ([`Camera2d`](https://docs.rs/bevy/0.15.0/bevy/core_pipeline/core_2d/struct.Camera2d.html)) only + - [x] 3D cameras ([`Camera3d`](https://docs.rs/bevy/0.15.0/bevy/core_pipeline/core_3d/struct.Camera3d.html)) only - [x] Simultaneous dual 2D/3D cameras - [x] Multiple viewports (split screen) - [x] HDR camera and bloom @@ -213,8 +213,8 @@ This list contains the major fixed features provided by 🎆 Hanabi. Beyond that | Feature | Default | Description | |---|:-:|---| -| `2d` | ✔ | Enable rendering through 2D cameras ([`Camera2dBundle`](https://docs.rs/bevy/0.14.0/bevy/core_pipeline/core_2d/struct.Camera2dBundle.html)) | -| `3d` | ✔ | Enable rendering through 3D cameras ([`Camera3dBundle`](https://docs.rs/bevy/0.14.0/bevy/core_pipeline/core_3d/struct.Camera3dBundle.html)) | +| `2d` | ✔ | Enable rendering through 2D cameras ([`Camera2d`](https://docs.rs/bevy/0.15.0/bevy/core_pipeline/core_2d/struct.Camera2d.html)) | +| `3d` | ✔ | Enable rendering through 3D cameras ([`Camera3d`](https://docs.rs/bevy/0.15.0/bevy/core_pipeline/core_3d/struct.Camera3d.html)) | | `serde`* | ✔ | Use `serde` to derive `Serialization` and `Deserialization` on asset-related types. | (*) `serde` is not compatible with WASM (due to the `typetag` dependency not being available on `wasm`). diff --git a/examples/2d.rs b/examples/2d.rs index 7b4fded2..868f8db9 100644 --- a/examples/2d.rs +++ b/examples/2d.rs @@ -4,11 +4,7 @@ //! tweaked at runtime via the egui inspector to move the 2D rendering layer of //! particle above or below the reference square. -use bevy::{ - prelude::*, - render::camera::ScalingMode, - sprite::{MaterialMesh2dBundle, Mesh2dHandle}, -}; +use bevy::{prelude::*, render::camera::ScalingMode}; use bevy_hanabi::prelude::*; mod utils; @@ -29,26 +25,24 @@ fn setup( mut materials: ResMut>, ) { // Spawn a 2D camera - let mut camera = Camera2dBundle::default(); - camera.projection.scale = 1.0; - camera.projection.scaling_mode = ScalingMode::FixedVertical(1.); - commands.spawn(camera); + let mut proj = OrthographicProjection::default_2d(); + proj.scale = 1.0; + proj.scaling_mode = ScalingMode::FixedVertical { + viewport_height: 1., + }; + commands.spawn((Camera2d::default(), proj)); // Spawn a reference white square in the center of the screen at Z=0 - commands - .spawn(MaterialMesh2dBundle { - mesh: meshes - .add(Rectangle { - half_size: Vec2::splat(0.1), - }) - .into(), - material: materials.add(ColorMaterial { - color: Color::WHITE, - ..Default::default() - }), + commands.spawn(( + Mesh2d(meshes.add(Rectangle { + half_size: Vec2::splat(0.1), + })), + MeshMaterial2d(materials.add(ColorMaterial { + color: Color::WHITE, ..Default::default() - }) - .insert(Name::new("square")); + })), + Name::new("square"), + )); // Create a color gradient for the particles let mut gradient = Gradient::new(); @@ -110,8 +104,8 @@ fn setup( .insert(Name::new("effect:2d")); } -fn update_plane(time: Res