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 option for wireframe & wireframe+solid rendering of meshes #8538

Open
dimentary opened this issue Dec 19, 2024 · 3 comments
Open

Add option for wireframe & wireframe+solid rendering of meshes #8538

dimentary opened this issue Dec 19, 2024 · 3 comments
Labels
enhancement New feature or request 🔺 re_renderer affects re_renderer itself 📺 re_viewer affects re_viewer itself

Comments

@dimentary
Copy link

dimentary commented Dec 19, 2024

Is your feature request related to a problem? Please describe.
The ability to show edges grid on top of the mesh, currently you could only show vertices on top of the mesh with the "Points3D" visualiser, which is not very informative (also you can't change points color separately from the mesh color):
Image

Describe the solution you'd like
A simple toggle that once turned on shows edges on top of the mesh surface, the result should look something like this:
Image

@dimentary dimentary added enhancement New feature or request 👀 needs triage This issue needs to be triaged by the Rerun team labels Dec 19, 2024
@Wumpf Wumpf changed the title Ability to show edges grid on 3D mesh Add option for wireframe rendering of meshes Dec 19, 2024
@Wumpf Wumpf added 🔺 re_renderer affects re_renderer itself 📺 re_viewer affects re_viewer itself and removed 👀 needs triage This issue needs to be triaged by the Rerun team labels Dec 19, 2024
@Wumpf Wumpf changed the title Add option for wireframe rendering of meshes Add option for wireframe & wireframe+solid rendering of meshes Dec 19, 2024
@Wumpf
Copy link
Member

Wumpf commented Dec 19, 2024

also you can't change points color separately from the mesh color

this will be soon addressed by tagged components, see also #6889


some notes on implementation:

Datastructures:
tbd if this should be a separate visualizer/archetype or just be a display option on Asset3D & Mesh3D. Leaning towards the later for ease of use (also the intricacies of "archetype inheritance", see #8368 might be be out too long).

Rendering:
Implementation-wise we won't be able to just simply draw the triangle mesh as wireframe since that's unfortunately not fully portable (see https://wgpu.rs/doc/wgpu/struct.Features.html#associatedconstant.POLYGON_MODE_LINE - this is a native-only wgpu feature). Using our line renderer is an option, but has too much overhead, we'd really like to use the data we already have.
Drawing from vertex+index buffer using vertex pulling (doing random buffer access in vertex & index buffer) is actually quite doable and that would allow us to render the lines on the solid mesh, avoiding issues with lines intersecting the solid mesh when both solid & wire is drawn.
https://webgpu.github.io/webgpu-samples/?sample=wireframe is a nice implementation of just that and allows to switch between two variants, one with separate line geometry (note how this requires a depth bias which can be fiddly to configure) and one using barycentric coordinates. Another cool thing we can do with this easily is to draw backfacing lines in a lighter tone (can just check winding order) when we have no solid [...].
But we can't do any of that on WebGL since it lacks random buffer access - let's check for alternatives & then decide whether it's worth feature-gating this.

@dimentary
Copy link
Author

dimentary commented Dec 19, 2024

Maybe something like precomputing a separate line mesh on the CPU and render it with a depth bias to simulate a wireframe overlay, and fallback to wgpu if that's available. Or there is a WebGL extension that somehow overcomes this limitation... just dropping ideas.

@julianschoep
Copy link

As a temporary work-around you can visualize the mesh connectivity by plotting line strips like so:

rr.log(
    "mesh_grid",
    rr.LineStrips3D(
        mesh.vertices[mesh.faces],
        colors=[0, 0, 0],
        radii=0.0005,
    ),
    timeless=True,
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request 🔺 re_renderer affects re_renderer itself 📺 re_viewer affects re_viewer itself
Projects
None yet
Development

No branches or pull requests

3 participants