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

use Material for wireframes #5314

Merged
merged 13 commits into from
Oct 10, 2023

Conversation

IceSentry
Copy link
Contributor

@IceSentry IceSentry commented Jul 14, 2022

Objective

  • Use the Material abstraction for the Wireframes
    • Right now this doesn't have many benefits other than simplifying some of the rendering code
    • We can reuse the default vertex shader and avoid rendering inconsistencies
    • The goal is to have a material with a color on each mesh so this approach will make it easier to implement
  • Originally done in Configurable colors for wireframe #5303 but I decided to split the Material part to it's own PR and then adding per-entity colors and globally configurable colors will be a much simpler diff.

Solution

  • Use the new Material abstraction for the Wireframes

Notes

It's possible this isn't ideal since this adds a Handle<WireframeMaterial> to all the meshes compared to the original approach that didn't need anything. I didn't notice any performance impact on my machine.

This might be a surprising usage of Material at first, because intuitively you only have one material per mesh, but the way it's implemented you can have as many different types of materials as you want on a mesh.

Migration Guide

WireframePipeline was removed. If you were using it directly, please create an issue explaining your use case.

@IceSentry IceSentry added the A-Rendering Drawing game state to the screen label Jul 14, 2022
@alice-i-cecile alice-i-cecile added C-Code-Quality A section of code that is hard to understand or change C-Usability A targeted quality-of-life change that makes Bevy easier to use M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide labels Jul 14, 2022
@alice-i-cecile
Copy link
Member

I'm on board with this direction; unifying this is nice.

@IceSentry
Copy link
Contributor Author

@alice-i-cecile from a user perspective there is no breaking change right now

@IceSentry
Copy link
Contributor Author

It's the same WireframePlugin and Wireframe Component that was used before, it's just the internals that changed, so I don't think it counts as breaking.

@IceSentry IceSentry removed the M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide label Jul 14, 2022
@IceSentry IceSentry added the M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide label Jul 14, 2022
@nicopap nicopap mentioned this pull request Nov 14, 2022
3 tasks
@IceSentry IceSentry force-pushed the wireframe-material-no-color branch 2 times, most recently from f3ef677 to 6b12dc9 Compare January 15, 2023 23:26
@alice-i-cecile alice-i-cecile removed the M-Needs-Migration-Guide A breaking change to Bevy's public API that needs to be noted in a migration guide label Jan 15, 2023
@JMS55 JMS55 added this to the 0.11 milestone Feb 17, 2023
@mockersf mockersf mentioned this pull request Apr 25, 2023
@JMS55 JMS55 modified the milestones: 0.11, 0.12 Jun 11, 2023
@robtfm robtfm self-requested a review August 14, 2023 20:05
@github-actions
Copy link
Contributor

Example alien_cake_addict failed to run, please try running it locally and check the result.

@DGriffin91
Copy link
Contributor

It may be worth turning the original version without the material into an example since it was a good reference for rendering something simple without using the material system.

@IceSentry
Copy link
Contributor Author

IceSentry commented Aug 14, 2023

I think the mesh2d_manual example serves that purpose pretty well. Maybe we should have a 3d version

@alice-i-cecile
Copy link
Member

How does this relate to #5303?

@IceSentry
Copy link
Contributor Author

How does this relate to #5303?

I think it was just me trying to aggressively reduce the size of the PR and have the customizable color in it's own PR

@IceSentry
Copy link
Contributor Author

I realized we don't need the vertex shader anymore since we can use the vertex shader from the Material api. This also fixed a bug where wireframes are broken in DX12 because of some vertex shader issues.

@IceSentry
Copy link
Contributor Author

IceSentry commented Oct 4, 2023

There's now a few conflicts because of the wireframe override PR. I personally think the api of that PR is flawed so I I'll submit a PR with an API that isn't a breaking change and should create less conflict with this PR.

I think we should decided if we want to merge this PR first since it will make it easier for me to resolve conflicts #10023

@IceSentry
Copy link
Contributor Author

I fixed the conflicts with the NoWireframe feature. I believe this is ready for a final review.

@IceSentry
Copy link
Contributor Author

I don't know what's up with the CI failure. It works fine locally and it's complaining about completely unrelated parts of the codebase.

@alice-i-cecile alice-i-cecile added the S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it label Oct 10, 2023
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Oct 10, 2023
Merged via the queue into bevyengine:main with commit e05a9f9 Oct 10, 2023
22 checks passed
github-merge-queue bot pushed a commit that referenced this pull request Oct 13, 2023
# Objective

- Make the wireframe colors configurable at the global level and the
single mesh level
- Based on #5314

This video shows what happens when playing with various settings from
the example


https://github.com/bevyengine/bevy/assets/8348954/1ee9aee0-fab7-4da8-bc5d-8d0562bb34e6

## Solution

- Add a `color` field to the `WireframeMaterial`
- Use a `WireframeColor` component to configure the color per entity
- Add a `default_color` field to `WireframeConfig` for global wireframes
or wireframes with no specified color.

## Notes

- Most of the docs and the general idea for `WireframeColor` came from
[UberLambda](https://github.com/UberLambda) in #3677 but the code ended
up completely different so I created a separate branch. ~~I'm not sure
how to correctly credit them on this PR.~~ (I re-created the commit but
I added them as co-author in the commit message)

~~Closes #3677
~~Closes #5301

~~#5314 should be merged before
this PR.~~
@cart cart mentioned this pull request Oct 13, 2023
43 tasks
regnarock pushed a commit to regnarock/bevy that referenced this pull request Oct 13, 2023
# Objective

- Use the `Material` abstraction for the Wireframes
- Right now this doesn't have many benefits other than simplifying some
of the rendering code
- We can reuse the default vertex shader and avoid rendering
inconsistencies
- The goal is to have a material with a color on each mesh so this
approach will make it easier to implement
- Originally done in bevyengine#5303 but I
decided to split the Material part to it's own PR and then adding
per-entity colors and globally configurable colors will be a much
simpler diff.

## Solution

- Use the new `Material` abstraction for the Wireframes

## Notes

It's possible this isn't ideal since this adds a
`Handle<WireframeMaterial>` to all the meshes compared to the original
approach that didn't need anything. I didn't notice any performance
impact on my machine.

This might be a surprising usage of `Material` at first, because
intuitively you only have one material per mesh, but the way it's
implemented you can have as many different types of materials as you
want on a mesh.

## Migration Guide
`WireframePipeline` was removed. If you were using it directly, please
create an issue explaining your use case.

---------

Co-authored-by: Alice Cecile <[email protected]>
regnarock pushed a commit to regnarock/bevy that referenced this pull request Oct 13, 2023
# Objective

- Make the wireframe colors configurable at the global level and the
single mesh level
- Based on bevyengine#5314

This video shows what happens when playing with various settings from
the example


https://github.com/bevyengine/bevy/assets/8348954/1ee9aee0-fab7-4da8-bc5d-8d0562bb34e6

## Solution

- Add a `color` field to the `WireframeMaterial`
- Use a `WireframeColor` component to configure the color per entity
- Add a `default_color` field to `WireframeConfig` for global wireframes
or wireframes with no specified color.

## Notes

- Most of the docs and the general idea for `WireframeColor` came from
[UberLambda](https://github.com/UberLambda) in bevyengine#3677 but the code ended
up completely different so I created a separate branch. ~~I'm not sure
how to correctly credit them on this PR.~~ (I re-created the commit but
I added them as co-author in the commit message)

~~Closes bevyengine#3677
~~Closes bevyengine#5301

~~bevyengine#5314 should be merged before
this PR.~~
@IceSentry IceSentry deleted the wireframe-material-no-color branch October 18, 2023 19:37
ameknite pushed a commit to ameknite/bevy that referenced this pull request Nov 6, 2023
# Objective

- Use the `Material` abstraction for the Wireframes
- Right now this doesn't have many benefits other than simplifying some
of the rendering code
- We can reuse the default vertex shader and avoid rendering
inconsistencies
- The goal is to have a material with a color on each mesh so this
approach will make it easier to implement
- Originally done in bevyengine#5303 but I
decided to split the Material part to it's own PR and then adding
per-entity colors and globally configurable colors will be a much
simpler diff.

## Solution

- Use the new `Material` abstraction for the Wireframes

## Notes

It's possible this isn't ideal since this adds a
`Handle<WireframeMaterial>` to all the meshes compared to the original
approach that didn't need anything. I didn't notice any performance
impact on my machine.

This might be a surprising usage of `Material` at first, because
intuitively you only have one material per mesh, but the way it's
implemented you can have as many different types of materials as you
want on a mesh.

## Migration Guide
`WireframePipeline` was removed. If you were using it directly, please
create an issue explaining your use case.

---------

Co-authored-by: Alice Cecile <[email protected]>
ameknite pushed a commit to ameknite/bevy that referenced this pull request Nov 6, 2023
# Objective

- Make the wireframe colors configurable at the global level and the
single mesh level
- Based on bevyengine#5314

This video shows what happens when playing with various settings from
the example


https://github.com/bevyengine/bevy/assets/8348954/1ee9aee0-fab7-4da8-bc5d-8d0562bb34e6

## Solution

- Add a `color` field to the `WireframeMaterial`
- Use a `WireframeColor` component to configure the color per entity
- Add a `default_color` field to `WireframeConfig` for global wireframes
or wireframes with no specified color.

## Notes

- Most of the docs and the general idea for `WireframeColor` came from
[UberLambda](https://github.com/UberLambda) in bevyengine#3677 but the code ended
up completely different so I created a separate branch. ~~I'm not sure
how to correctly credit them on this PR.~~ (I re-created the commit but
I added them as co-author in the commit message)

~~Closes bevyengine#3677
~~Closes bevyengine#5301

~~bevyengine#5314 should be merged before
this PR.~~
rdrpenguin04 pushed a commit to rdrpenguin04/bevy that referenced this pull request Jan 9, 2024
# Objective

- Use the `Material` abstraction for the Wireframes
- Right now this doesn't have many benefits other than simplifying some
of the rendering code
- We can reuse the default vertex shader and avoid rendering
inconsistencies
- The goal is to have a material with a color on each mesh so this
approach will make it easier to implement
- Originally done in bevyengine#5303 but I
decided to split the Material part to it's own PR and then adding
per-entity colors and globally configurable colors will be a much
simpler diff.

## Solution

- Use the new `Material` abstraction for the Wireframes

## Notes

It's possible this isn't ideal since this adds a
`Handle<WireframeMaterial>` to all the meshes compared to the original
approach that didn't need anything. I didn't notice any performance
impact on my machine.

This might be a surprising usage of `Material` at first, because
intuitively you only have one material per mesh, but the way it's
implemented you can have as many different types of materials as you
want on a mesh.

## Migration Guide
`WireframePipeline` was removed. If you were using it directly, please
create an issue explaining your use case.

---------

Co-authored-by: Alice Cecile <[email protected]>
rdrpenguin04 pushed a commit to rdrpenguin04/bevy that referenced this pull request Jan 9, 2024
# Objective

- Make the wireframe colors configurable at the global level and the
single mesh level
- Based on bevyengine#5314

This video shows what happens when playing with various settings from
the example


https://github.com/bevyengine/bevy/assets/8348954/1ee9aee0-fab7-4da8-bc5d-8d0562bb34e6

## Solution

- Add a `color` field to the `WireframeMaterial`
- Use a `WireframeColor` component to configure the color per entity
- Add a `default_color` field to `WireframeConfig` for global wireframes
or wireframes with no specified color.

## Notes

- Most of the docs and the general idea for `WireframeColor` came from
[UberLambda](https://github.com/UberLambda) in bevyengine#3677 but the code ended
up completely different so I created a separate branch. ~~I'm not sure
how to correctly credit them on this PR.~~ (I re-created the commit but
I added them as co-author in the commit message)

~~Closes bevyengine#3677
~~Closes bevyengine#5301

~~bevyengine#5314 should be merged before
this PR.~~
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 C-Code-Quality A section of code that is hard to understand or change C-Usability A targeted quality-of-life change that makes Bevy easier to use S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants