Skip to content

Add line width and quad support for wireframes.#22986

Merged
alice-i-cecile merged 11 commits intobevyengine:mainfrom
tychedelia:wireframe-quad-stroke
Feb 18, 2026
Merged

Add line width and quad support for wireframes.#22986
alice-i-cecile merged 11 commits intobevyengine:mainfrom
tychedelia:wireframe-quad-stroke

Conversation

@tychedelia
Copy link
Member

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:

  • Compute screen-space altitudes for our edges.
  • Find and suppress diagonals when quad topology is enabled.

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:

image Screenshot 2026-02-16 160350

@tychedelia tychedelia changed the title Add stroke and quad support for wireframes. Add line width and quad support for wireframes. Feb 17, 2026
} else {
PolygonMode::Fill
};
descriptor.immediate_size = 32; // color(16) + line_width(4) + smoothing(4) + pad(8)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to do like size_of::<T> where T is the struct that will be used for the immediates.

Copy link
Contributor

@IceSentry IceSentry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor

@atlv24 atlv24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Zeophlite Zeophlite added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes A-Rendering Drawing game state to the screen and removed S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it labels Feb 17, 2026
@github-project-automation github-project-automation bot moved this to Needs SME Triage in Rendering Feb 17, 2026
Co-authored-by: atlv <email@atlasdostal.com>
@alice-i-cecile alice-i-cecile added S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged and removed S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it labels Feb 17, 2026
@alice-i-cecile
Copy link
Member

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.

@alice-i-cecile alice-i-cecile added this to the 0.19 milestone Feb 17, 2026
auto-merge was automatically disabled February 17, 2026 20:38

Head branch was pushed to by a user without write access

@tychedelia
Copy link
Member Author

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.

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?

@alice-i-cecile alice-i-cecile added S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it and removed S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged labels Feb 17, 2026
@alice-i-cecile alice-i-cecile added this pull request to the merge queue Feb 17, 2026
Merged via the queue into bevyengine:main with commit 7cd6f4d Feb 18, 2026
40 checks passed
@github-project-automation github-project-automation bot moved this from Needs SME Triage to Done in Rendering Feb 18, 2026
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 D-Modest A "normal" level of difficulty; suitable for simple features or challenging fixes S-Ready-For-Final-Review This PR has been approved by the community. It's ready for a maintainer to consider merging it

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants