-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
showcasing the Material2d abtraction with a new example: 2d/mesh2d_material.rs #3610
Conversation
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.
Looks good to me!
Co-authored-by: Jakob Hellermann <[email protected]>
This PR adds a new example. Adding module and item level doc comments, as described in:
would be really useful to those who will browse examples. |
@eliotbo would you be interested in updating this PR to the newer Material api using AsBindGroup. We do get people asking about 2d materials from time to time so having an example could be useful instead of just telling them to copy the 3d version. |
done in #10542 |
Objective
Solution
The new 2d/mesh2d_material example is a modified version of the shader/shader_material example, where the Material trait is replaced by the Material2d trait. In the new example, users will be able to add fields to the Custom2dMaterial struct without having to change the Material2d and RenderAsset implementations, provided that bevy_crevice supports the type of said fields. This is achieved by 1) deriving AsStd140 on Custom2dMaterial, 2) setting the binding size with Custom2dMaterial::std140_size_static(), and 3) converting the entirety of the Custom2dMaterial data into std140 format with the derived as_std140() method. Of course, as users modify the Custom2dMaterial struct, they must also change the corresponding struct inside the shader script, but this exercise is left to them.