djeedai / bevy_hanabi

🎆 Hanabi — a GPU particle system plugin for the Bevy game engine.
Apache License 2.0
958 stars 76 forks source link

Artifacts in `firework` example #376

Closed Seldom-SE closed 2 weeks ago

Seldom-SE commented 1 month ago

Crate versions bevy version: 0.14.2 bevy_hanabi version: main (1ad6298). It works fine on 0.12.2.

AdapterInfo { name: "AMD Radeon RX 570 Series (RADV POLARIS10)", vendor: 4098, device: 26591, device_type: DiscreteGpu, driver: "radv", driver_info: "Mesa 24.2.2-arch1.1", backend: Vulkan }

Describe the bug The firework example has artifacts. It's drawing ribbons between seemingly random particles.

Expected behavior No artifacts

To Reproduce cargo r --example firework --no-default-features --features="bevy/bevy_winit bevy/bevy_pbr 3d"

Screenshots

https://github.com/user-attachments/assets/56f9e75e-075e-40a5-b995-01ebc521e89b

djeedai commented 1 month ago

Thanks @Seldom-SE I'll keep an eye out, but unfortunately I've been using that example to work on a new feature and I've not seen this locally, so it's going to be hard to diagnose until I can repro.

DatHydroGuy commented 1 month ago

I can confirm that I am also seeing this bug with my own modified version of the fireworks example (see attached files in zip). This is with bevy 0.14.0 and bevy_hanabi 0.12.2. Windows 11. AdapterInfo { name: "NVIDIA GeForce RTX 4070 Ti", vendor: 4318, device: 10114, device_type: DiscreteGpu, driver: "NVIDIA", driver_info: "560.94", backend: Vulkan }

Moreover, I'm seeing the following errors being output in the console:

2024-09-22T14:39:54.533651Z ERROR bevy_hanabi::render: Allocator didn't allocate sequential indices (expected 3, got 5). Expect trouble! 2024-09-22T14:39:54.533817Z ERROR bevy_hanabi::render: Allocator didn't allocate sequential indices (expected 3, got 5). Expect trouble! 2024-09-22T14:39:55.068075Z ERROR bevy_hanabi::render: Allocator didn't allocate sequential indices (expected 4, got 7). Expect trouble! 2024-09-22T14:39:55.068198Z ERROR bevy_hanabi::render: Allocator didn't allocate sequential indices (expected 4, got 7). Expect trouble! 2024-09-22T14:39:55.835265Z ERROR bevy_hanabi::render: Allocator didn't allocate sequential indices (expected 5, got 10). Expect trouble! <and many more of these!>

Search for "BUG???" in the firework.rs file to see what (I think) might be the responsible line of code in my example (it's during despawning)

Also, I've noticed that the first firework doesn't visibly burst, so you'll find a weird hack in my code (search for "Weird hack") where I force a firework burst way offscreen. No idea if this is related, but I've thrown it in here in case it helps track down the issue.

Disclaimer: I'm pretty new to Rust / Bevy / Bevy_hanabi, and this code is just my way of messing around to understand how things work, so apologies if it's horrible to read.

hanabi_test.zip

wduminy commented 1 month ago

Re:

Also, I've noticed that the first firework doesn't visibly burst

I also noticed on my side that the first burst of my effect is different from this that follow.

djeedai commented 1 month ago

The first burst issue is due to Bevy's first frame having a delta time of zero I believe. Hanabi doesn't (yet) have a minimum frame time, so dt=0 breaks a bunch of time-dependent things. This happens in most examples.

djeedai commented 3 weeks ago

I can repro trivially now, not sure why. I'll investigate.

djeedai commented 3 weeks ago

FYI - @pcwalton found the likely cause and has a fix getting ready.