Skip to content

Allow Material2dPipeline<M> softly allow error instead of early return #5374

Open
@zimond

Description

@zimond

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<Material2dPipeline<CustomMaterial>> 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<M> 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::<M>::specialize to return before calling M::specialize, which makes my approach fail. Code here

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-RenderingDrawing game state to the screenC-UsabilityA targeted quality-of-life change that makes Bevy easier to use

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions