bevyengine / bevy

A refreshingly simple data-driven game engine built in Rust
https://bevyengine.org
Apache License 2.0
35.26k stars 3.48k forks source link

Can't upgrade to 0.14, impossible to render `AlphaMask3d` phase items without mesh #14004

Closed djeedai closed 2 months ago

djeedai commented 3 months ago

Bevy version

main

What you did

Repro branch : https://github.com/djeedai/bevy_hanabi/tree/bevy_main

Run:

cargo --offline r --example billboard --no-default-features --features="bevy/zstd bevy/ktx2 bevy/bevy_winit bevy/bevy_pbr bevy/png 3d "

The billboard particles are missing. GPU debugger shows there's no draw call.

Discussion on Discord and comments on related migration guide bug.

Hanabi (bevy_hanabi) renders some particle effect through the AlphaMask3d pass via a custom render pipeline based on compute shaders and vertex/fragment shaders. There's no mesh involved (except from a single quad shared by all particles, which could even be removed). After migrating, I noted that AlphaMask3d uses BinnedRenderPhase, unlike all other phases Hanabi uses which go through SortedRenderPhase. The design of the 2 is quite different, and it seems BinnedRenderPhase is coupled with mesh asset rendering.

This makes it impossible to ugprade Hanabi.

What went wrong

Render phase items AlphaMask3d are silently discarded, because (I think) GetFullBatchData::get_binned_index() returns None, since the phase item enqueued doesn't have a mesh.

kurtkuehnert commented 2 months ago

I was trying to upgrade bevy terrain to Bevy 0.14 and I am facing the same issue. My pipeline uses a compute shader generated mesh, so my mesh asset ID is set to invalid in the Opaque3D phase item. This causes my items to not be drawn as well.

djeedai commented 2 months ago

@kurtkuehnert there's a discussion happening on Discord now (see here and below messages, and can walk your way up from replies too). I think we'll post a recommendation here once the various folks discussing have reached a consensus on the best approach. So far there's I think 4+ crates facing the same issue. It's also considered a 0.14 blocker, so should get traction.

djeedai commented 2 months ago

Confirming that Hanabi works again. Thanks for the fix!