bevy/crates/bevy_sprite/src/mesh2d
IceSentry 9de25ad330
Add AlphaMask2d phase (#14724)
# Objective

- Bevy now supports an opaque phase for mesh2d, but it's very common for
2d textures to have a transparent alpha channel.

## Solution

- Add an alpha mask phase identical to the one in 3d. It will do the
alpha masking in the shader before drawing the mesh.
- Uses the BinnedRenderPhase
- Since it's an opaque draw it also correctly writes to depth

## Testing

- Tested the mes2d_alpha_mode example and the bevymark example with
alpha mask mode enabled

---

## Showcase


![image](https://github.com/user-attachments/assets/9e5e4561-d0a7-4aa3-b049-d4b1247d5ed4)

The white logo on the right is rendered with alpha mask enabled.

Running the bevymark example I can get 65fps for 120k mesh2d all using
alpha mask.

## Notes

This is one more step for mesh2d improvements
https://github.com/bevyengine/bevy/issues/13265

---------

Co-authored-by: Kristoffer Søholm <k.soeholm@gmail.com>
2024-08-15 14:10:37 +00:00
..
color_material.rs Add AlphaMask2d phase (#14724) 2024-08-15 14:10:37 +00:00
color_material.wgsl Add AlphaMask2d phase (#14724) 2024-08-15 14:10:37 +00:00
material.rs Add AlphaMask2d phase (#14724) 2024-08-15 14:10:37 +00:00
mesh.rs Add AlphaMask2d phase (#14724) 2024-08-15 14:10:37 +00:00
mesh2d.wgsl Normalise matrix naming (#13489) 2024-06-03 16:56:53 +00:00
mesh2d_bindings.wgsl Swap material and mesh bind groups (#10485) 2023-11-28 22:26:22 +00:00
mesh2d_functions.wgsl Normalise matrix naming (#13489) 2024-06-03 16:56:53 +00:00
mesh2d_types.wgsl Normalise matrix naming (#13489) 2024-06-03 16:56:53 +00:00
mesh2d_vertex_output.wgsl pbr shader cleanup (#10105) 2023-10-13 19:12:40 +00:00
mesh2d_view_bindings.wgsl add tonemapping LUT bindings for sprite and mesh2d pipelines (#13262) 2024-05-28 12:09:26 +00:00
mesh2d_view_types.wgsl Refactor Globals and View structs into separate shaders (#7512) 2023-02-11 17:55:18 +00:00
mod.rs Support wireframes for 2D meshes (#12135) 2024-03-29 18:34:04 +00:00
wireframe2d.rs Consistency between Wireframe2d and Wireframe (#14720) 2024-08-13 18:57:47 +00:00
wireframe2d.wgsl Support wireframes for 2D meshes (#12135) 2024-03-29 18:34:04 +00:00