Allow `Material2dPipeline<M>` softly allow error instead of early return
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 22h
- Merged PRs (30d)
- 161
Description
## What problem does this solve or what need does it fill?
I'm doing 2D vector graph rendering and don't need uv/normals (basically what `bevy_lyon_prototype` is doing now), but need a material for masking. Before the recent material rework with #5053 and #5312 , a custom pipeline would suffice. After the new material system is landed, I think I could use a custom material, and take advantage of the `SpecializeMeshPipelines>` instead of manually copy all the code of them just to remove uv/normal vertex data. Because the new Material2dPipeline is quite different and contains a lot of new code, copy-pasting them seems so dumb.
But the problem is, `Material2dPipeline` wraps a `Mesh2dPipeline`, which currently asks for vertex position, uv, normals to create the default layout. If any of the 3 is missing, an error is returned, which makes `Material2dPipeline::::specialize` to return before calling `M::specialize`, which makes my approach fail. [Code here](https://github.com/bevyengine/bevy/blob/main/crates/bevy_sprite/src/mesh2d/material.rs#L231)
## What solution would you like?
I think maybe Material2dPipeline could just log the error and continue, at least call `M::specialize()`? Currently the error is propagated to `SpecializedMeshPipelines` and is also logged. So I think this is tolerable?
## What alternative(s) have you considered?
1. Rethink the whole thing about specialization and make it even easier to customize everything.
2. Make `Mesh2dPipeline` accept optional uv / normal.
## Additional context
N/A
Contributor guide
Assessment
This issue has not been assessed yet.