-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clean up 2d render phases #12982
Clean up 2d render phases #12982
Conversation
ace2d1e
to
df23a13
Compare
75131d7
to
ddba1fd
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, simple changes and I ran a bunch of the 2D examples on Linux and everything still worked.
crates/bevy_core_pipeline/src/core_2d/main_transparent_pass_2d_node.rs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New to Bevy, but this seems relatively straight forward 👍
This PR is based on top of #12982 # Objective - Mesh2d currently only has an alpha blended phase. Most sprites don't need transparency though. - For some 2d games it can be useful to have a 2d depth buffer ## Solution - Add an opaque phase to render Mesh2d that don't need transparency - This phase currently uses the `SortedRenderPhase` to make it easier to implement based on the already existing transparent phase. A follow up PR will switch this to `BinnedRenderPhase`. - Add a 2d depth buffer - Use that depth buffer in the transparent phase to make sure that sprites and transparent mesh2d are displayed correctly ## Testing I added the mesh2d_transforms example that layers many opaque and transparent mesh2d to make sure they all get displayed correctly. I also confirmed it works with sprites by modifying that example locally. --- ## Changelog - Added `AlphaMode2d` - Added `Opaque2d` render phase - Camera2d now have a `ViewDepthTexture` component ## Migration Guide - `ColorMaterial` now contains `AlphaMode2d`. To keep previous behaviour, use `AlphaMode::BLEND`. If you know your sprite is opaque, use `AlphaMode::OPAQUE` ## Follow up PRs - See tracking issue: #13265 --------- Co-authored-by: Alice Cecile <[email protected]> Co-authored-by: Christopher Biscardi <[email protected]>
Based on top of #12982 and #13069 # Objective - Opaque2d was implemented with SortedRenderPhase but BinnedRenderPhase should be much faster ## Solution - Implement BinnedRenderPhase for Opaque2d ## Notes While testing this PR, before the change I had ~14 fps in bevymark with 100k entities. After this change I get ~71 fps, compared to using sprites where I only get ~63 fps. This means that after this PR mesh2d with opaque meshes will be faster than the sprite path. This is not a 1 to 1 comparison since sprites do alpha blending.
Objective
Currently, the 2d pipeline only has a transparent pass that is used for everything. I want to have separate passes for opaque/alpha mask/transparent meshes just like in 3d.
This PR does the basic work to start adding new phases to the 2d pipeline and get the current setup a bit closer to 3d.
Solution
ViewNode
forMainTransparentPass2dNode
Node2d::StartMainPass
,Node2d::EndMainPass
Changelog
Node2d::StartMainPass
,Node2d::EndMainPass
Migration Guide
If you were using
Node2d::MainPass
to order your own custom render node. You now need to order it relative toNode2d::StartMainPass
orNode2d::EndMainPass
.