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

Add Wireframe2d plugin #10489

Closed
wants to merge 2 commits into from
Closed

Conversation

SludgePhD
Copy link
Contributor

@SludgePhD SludgePhD commented Nov 10, 2023

Objective

Solution

  • This PR implements a solution by duplicating the 3D wireframe module, creating a 2d variant of it.
  • It may be better to move both of them into a common crate that depends on both bevy_pbr and bevy_sprite, and let them share code and types. Opinions welcome!

Changelog

Added

  • Added Wireframe2d plugin for drawing 2D meshes as wireframes.

@SludgePhD
Copy link
Contributor Author

SludgePhD commented Nov 10, 2023

This currently has a bug where the wireframe appears behind the object. I had to remove the line that fixes this in the 3D wireframe because the depth_stencil state is None here:

descriptor.depth_stencil.as_mut().unwrap().bias.slope_scale = 1.0;

Fixed this problem by applying a depth bias with a new Material2d::depth_bias function (mirroring the existing one in the 3D Material trait).

@alice-i-cecile alice-i-cecile added C-Feature A new feature, making something new possible A-Gizmos Visual editor and debug gizmos labels Nov 12, 2023
github-merge-queue bot pushed a commit that referenced this pull request Nov 25, 2023
# Objective

It is currently impossible to control the relative ordering of two 2D
materials at the same depth. This is required to implement wireframes
for 2D meshes correctly
(#5881).

## Solution

Add a `Material2d::depth_bias` function that mirrors the existing 3D
`Material::depth_bias` function.

(this is pulled out of #10489)

---

## Changelog

### Added

- Added `Material2d::depth_bias`

## Migration Guide

`PreparedMaterial2d` has a new `depth_bias` field. A value of 0.0 can be
used to get the previous behavior.
tectin0 added a commit to tectin0/magic_guns that referenced this pull request Dec 17, 2023
added basic mesh display +
copied `colored_mesh2d` shader from example +
tried wireframe plugin but not working with 2D:
bevyengine/bevy#10489
@TotalKrill
Copy link
Contributor

This looks quite sound, and quite useful, for example if one is trying to draw roads in 2D, and wanna figure out why their meshes are not meshing

I rebased it and you can find the rebase here: https://github.com/TotalKrill/bevy/tree/wireframe2d

@SludgePhD
Copy link
Contributor Author

There's also #12135 now, which has more maintainer attention, so that'll probably be merged instead

@TotalKrill
Copy link
Contributor

Look at that wish I had known, could have saved me some minutes, maybe close this one then, to help declutter

@SludgePhD SludgePhD closed this Mar 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Gizmos Visual editor and debug gizmos C-Feature A new feature, making something new possible
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wireframe for 2D meshes
3 participants