Skip to content
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

[Merged by Bors] - Materials and MaterialPlugin #3428

Closed
wants to merge 4 commits into from

Conversation

cart
Copy link
Member

@cart cart commented Dec 24, 2021

This adds "high level" Material and SpecializedMaterial traits, which can be used with a MaterialPlugin<T: SpecializedMaterial>. MaterialPlugin automatically registers the appropriate resources, draw functions, and queue systems. The Material trait is simpler, and should cover most use cases. SpecializedMaterial is like Material, but it also requires defining a "specialization key" (see #3031). Material has a trivial blanket impl of SpecializedMaterial, which allows us to use the same types + functions for both.

This makes defining custom 3d materials much simpler (see the shader_material example diff) and ensures consistent behavior across all 3d materials (both built in and custom). I ported the built in StandardMaterial to MaterialPlugin. There is also a new MaterialMeshBundle<T: SpecializedMaterial>, which PbrBundle aliases to.

@cart cart added the A-Rendering Drawing game state to the screen label Dec 24, 2021
@cart cart added this to the Bevy 0.6 milestone Dec 24, 2021
@github-actions github-actions bot added the S-Needs-Triage This issue needs to be labelled label Dec 24, 2021
@cart cart removed the S-Needs-Triage This issue needs to be labelled label Dec 24, 2021
@alice-i-cecile
Copy link
Member

This looks very nice; the code is surprisingly easy to follow and this seems straightforward to customize (as far as these things go). Docs are pretty decent (other than the nit I left): most of this is going to be better served by googling "what's a bind group" for now. Unfortunately we don't have any great tools for testing rendering code yet. At least the example is there :)

crates/bevy_pbr/src/material.rs Show resolved Hide resolved
crates/bevy_pbr/src/material.rs Outdated Show resolved Hide resolved
@cart
Copy link
Member Author

cart commented Dec 25, 2021

bors r+

bors bot pushed a commit that referenced this pull request Dec 25, 2021
This adds "high level" `Material` and `SpecializedMaterial` traits, which can be used with a `MaterialPlugin<T: SpecializedMaterial>`. `MaterialPlugin` automatically registers the appropriate resources, draw functions, and queue systems. The `Material` trait is simpler, and should cover most use cases. `SpecializedMaterial` is like `Material`, but it also requires defining a "specialization key" (see #3031). `Material` has a trivial blanket impl of `SpecializedMaterial`, which allows us to use the same types + functions for both.

This makes defining custom 3d materials much simpler (see the `shader_material` example diff) and ensures consistent behavior across all 3d materials (both built in and custom). I ported the built in `StandardMaterial` to `MaterialPlugin`. There is also a new `MaterialMeshBundle<T: SpecializedMaterial>`, which `PbrBundle` aliases to.
@bors bors bot changed the title Materials and MaterialPlugin [Merged by Bors] - Materials and MaterialPlugin Dec 25, 2021
@bors bors bot closed this Dec 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants