Add line width and quad support for wireframes.#22986
Add line width and quad support for wireframes.#22986alice-i-cecile merged 11 commits intobevyengine:mainfrom
Conversation
| } else { | ||
| PolygonMode::Fill | ||
| }; | ||
| descriptor.immediate_size = 32; // color(16) + line_width(4) + smoothing(4) + pad(8) |
There was a problem hiding this comment.
Is it possible to do like size_of::<T> where T is the struct that will be used for the immediates.
IceSentry
left a comment
There was a problem hiding this comment.
That's a lot more code than I expected for the feature but I couldn't figure out a way to make it simpler.
I believe it should be possible to run this new mode in browers but this can be done in a follow up.
LGTM
atlv24
left a comment
There was a problem hiding this comment.
Looks pretty good. There's no non-planar quad rejection logic and I'm sure someone will eventually complain about that and make a bug report, but I think that's fine.
I am not aware of a way to do this with less code, at least on the shader side.
Note that wgpu has triangle barycentric support now, which allows fast paths for the usecase of drawing filled-in wireframe-like material effects in one pass. This api has about the same level of platform support as raytracing however.
Co-authored-by: atlv <email@atlasdostal.com>
|
CI failures are real but simple; please ping me when they're fixed :) Do we want a release note for this? It is very cool, but I don't know if it will be as widely exciting as doing the same for gizmos would be. |
Head branch was pushed to by a user without write access
I don't really care personally. We could slip it in if we're feeling like we want to pad out the release notes. Maybe we could add the tag and cut it later? |
Adds support for line width (stroke) and quad topology for wireframes.
The triangle line fast path stays the same, but we add a new "wide" draw function path that uses a specialized vertex shader in order to do the following via vertex pulling from the appropriate mesh slab:
Doing this in the vertex shader allows us to avoid needing to de-dupe on the CPU or spend additional bandwidth uploading a mesh copy at the expense of a bit of extra shading.
Right now, we have to break batches on the mesh when in the "wide" path, meaning we don't get full advantage of MDI, but this is mostly because we don't have a great way to support per-draw data. This could be fixed in the future.
Examples: