Code Monkey home page Code Monkey logo

bevy_firework's Introduction

Crates.io Crates.io CI

Bevy Firework ๐ŸŽ†

Bevy firework is a particle system plugin where particles are simulated on the CPU and use GPU batching for rendering. This allows each particle system to be rendered in a single draw call (rather than one per particle).

While not as fast as a pure GPU-based particle system, this provides a massive speed-up from the naive approach to CPU-based particles (making it possible to render tens of thousands of particles without noticeable framerate drops) and maintains much of the flexibility of CPU-based particle systems (e.g. easy access to physics data for particle collision, simplified particle system animation).

collision example pbr example sparks example

Current features

  • Billboarded particles.
  • Configurable integration with Bevy's PBR rendering (i.e. particles can receive shadows, are affected by fog and lighting changes).
  • Particle collision with arbitrary bevy_xpbd colliders.
  • WASM and WebGL compatible.
  • Soft particle edges.
  • Animated properties: certain parameters can be defined as a custom curve to express changes over a particle's lifetime:
    • Scale
    • Color
  • Randomized properties: certain properties can be randomized, so that they are randomly sampled for every particle:
    • Particle lifetime
    • Initial linear velocity
    • Initial radial velocity
    • Initial scale
  • Emission shapes:
    • Point
    • Disk
    • Sphere
  • One-shot emission mode, or continuous emission.

Current limitations

  • Can't use custom images for particles.

Version table

bevy_firework bevy bevy_utilitarian
0.1 0.12 0.2
0.2 0.12 0.3
0.3 0.13 0.4

bevy_firework's People

Contributors

affinator avatar mbrea-c avatar rparrett avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

bevy_firework's Issues

Crash if Msaa is disabled/enabled after adding the plugin

Reproduction

Change the main function in the pbr example to:

    let mut app = App::new();
    app.add_plugins(DefaultPlugins);
    app.add_plugins(ParticleSystemPlugin)
        .add_systems(Startup, setup);
    app.insert_resource(Msaa::Off);
    app.run();

Expected

The example runs normally, but with Msaa disabled.

Actual result

The example crashes

Reasoning

Currently we setup the texture bindings that the plugin uses at plugin build time, but those bindings are dependent on whether Msaa is enabled or not. They need to be recreated whenever the Msaa resource changes.
This is the reason for the third crash in #11

Add integration tests

We should have some integration tests that at least runs the examples (or similar) for X seconds to verify that they do not crash.

This would have prevented bugs such as #11

Allow spawning particle systems with an initial disabled state

I have a particle effect that I would like to turn on/off without removing any live particles.

I don't want the particle system to be active immediately though. I currently find myself having to write a system to disable a particular ParticleSpawnerData immediately after bevy_firework adds it.

2D support

Right now I can see this only works for 3d rendering and with 3d physics (bevy_xpbd_3d) would it be possible to make it 3d/2d agnostic?

Panic in wasm builds

Version tested

Tested v0.3.0.

Bisected to aa0b278

Info

AdapterInfo { name: "ANGLE (Apple, ANGLE Metal Renderer: Apple M1 Max, Unspecified Version)", vendor: 4203, device: 0, device_type: IntegratedGpu, driver: "", driver_info: "", backend: Gl }

Reproduction

With wasm-server-runner:
cargo run --example sparks --target=wasm32-unknown-unknown

Panic

(index):159 panicked at /Users/me/.cargo/registry/src/index.crates.io-6f17d22bba15001f/glow-0.13.1/src/web_sys.rs:3184:9:
Tex storage 2D multisample is not supported

Stack:

Error
    at imports.wbg.__wbg_new_abda76e883ba8a5f (http://127.0.0.1:1334/api/wasm.js:482:13)
    at __wbg_new_abda76e883ba8a5f externref shim (http://127.0.0.1:1334/api/wasm.wasm:wasm-function[331084]:0x5b9d84a)
    at console_error_panic_hook::Error::new::h8a92a4862c5a1462 (http://127.0.0.1:1334/api/wasm.wasm:wasm-function[237327]:0x56ded84)
    at console_error_panic_hook::hook_impl::hbd888f2d619deb19 (http://127.0.0.1:1334/api/wasm.wasm:wasm-function[45590]:0x37de1ad)
    at console_error_panic_hook::hook::h7220c272d9834ace (http://127.0.0.1:1334/api/wasm.wasm:wasm-function[289425]:0x59fb7f3)
    at core::ops::function::Fn::call::h9b1dea7da821a03f (http://127.0.0.1:1334/api/wasm.wasm:wasm-function[256753]:0x58310b1)
    at std::panicking::rust_panic_with_hook::h6b00a1542b7e827c (http://127.0.0.1:1334/api/wasm.wasm:wasm-function[94864]:0x459e600)
    at std::panicking::begin_panic_handler::{{closure}}::hcb858dc6b4beb4ae (http://127.0.0.1:1334/api/wasm.wasm:wasm-function[123059]:0x4ac35eb)
    at std::sys_common::backtrace::__rust_end_short_backtrace::hbb248f505066e51b (http://127.0.0.1:1334/api/wasm.wasm:wasm-function[333575]:0x5ba5b70)
    at rust_begin_unwind (http://127.0.0.1:1334/api/wasm.wasm:wasm-function[264653]:0x58aca92)

Notes

With Msaa disabled with

    app.add_plugins(DefaultPlugins)
        .insert_resource(Msaa::Off)
        .add_plugins(ParticleSystemPlugin)

there's a different panic:

wgpu error: Validation Error

Caused by:
    In Device::create_bind_group
      note: label = `Firework Uniform Bindgroup`
    Texture binding 1 expects multisampled = true, but given a view with samples = 1

And just a note: For the pbr example, Msaa must be disabled before the ParticleSystemPlugin is added, otherwise, there's a different panic:

wgpu error: Validation Error

Caused by:
    In Device::create_render_pipeline
      note: label = `Firework Pipeline`
    Error matching ShaderStages(FRAGMENT) shader requirements against the pipeline
    Shader global ResourceBinding { group: 1, binding: 1 } is not available in the pipeline layout
    Texture class Depth { multi: true } doesn't match the shader Depth { multi: false }

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.