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

Line strips are no longer a disconnected series of quads #8065

Merged
merged 15 commits into from
Nov 12, 2024

Conversation

Wumpf
Copy link
Member

@Wumpf Wumpf commented Nov 11, 2024

What

Fixes a long standing issue that the segments of a line have small gaps between them.

Other than originally planned, the solution employed here is entirely based on fragment shader discard + elongation of the line. This can cause some slight artifacts for 3D lines but it's quite hard to spot those issues. Otherwise the biggest drawback of this is that we have more overdraw which gonna be tricky to deal with once we add transparency. On the flip side this is fairly simple and can re-use some of the round cap handling code - round caps no longer use the "trailing triangle" we had for every strip internally, and instead use the quad extension, actually leading to better looking round caps.

⚠️ To allow loops to "just work", all line segments & line strips start and end now with extended round caps. I.e. if your line has a radius of 1 and goes from (0,0,0) to (100,0,0), then what's drawn goes from (-1,0,0) to (101,0,0). Before we didn't have caps on this, so we essentially drew a square starting at (0,0,0) whereas now it's more capsule like (it does not exactly behave like a capsule under perspective though).

Line loops on map view:
Before:
image

After:
image

RRT Star:
Before:
image

After:
image

3D line snippet snippet:
Before:
image

After:
image

Failure Example in #7191
Before - confusingly broken:
image

After - pretty bad rendering performance due to quite massive overdraw of alpha tested geometry, but no longer broken.
image

(After: setting the radius to something large, but sane)
image

re_renderer 2D demo. Left before, right after. Note that "shaded lines" look a lot better now as a sideffect, with shading of arrows slightly broken. Afaik we don't use this anywhere in Rerun today though.
However, rounded caps are higher quality now in general.

Screenshot 2024-11-11 at 11 10 29

Things that were several segments before can now be strips. No visual change there:

Rectangles:
image

Frustum:
image

Box wireframes:

This fixes a regression! In 0.19 those boxes had disconnected lines, in 0.18 this still worked since they were separate segments with rounded corners.

Before (regression):
image

After:
image


Due to aforementioned always-round-caps, a list of segments can now look indistinguishable from a single strip:

image

Under more extreme circumstances it is still (!) possible to have boxes exhibit some artifacts:

image

This is due to the quasi-capsule nature of our line segments. Calculating a world position from ray-capsule intersection would yield the correct result. What's actually happening right now is that we interpolate the world position over the spanned quad (which is a lot cheaper).

Checklist

  • I have read and agree to Contributor Guide and the Code of Conduct
  • I've included a screenshot or gif (if applicable)
  • I have tested the web demo (if applicable):
  • The PR title and labels are set such as to maximize their usefulness for the next release's CHANGELOG
  • If applicable, add a new check to the release checklist!
  • If have noted any breaking changes to the log API in CHANGELOG.md and the migration guide

To run all checks from main, comment on the PR with @rerun-bot full-check.

Testing

  • Tested on WebGL
  • Tested on WebGPU

@Wumpf Wumpf added 🔺 re_renderer affects re_renderer itself 📺 re_viewer affects re_viewer itself include in changelog labels Nov 11, 2024
@Wumpf Wumpf changed the title Segments of a line strip are now visually connected Line strips are no longer a disconnected series of quads Nov 11, 2024
@@ -47,6 +47,9 @@ const FLAG_CAP_START_EXTEND_OUTWARDS: u32 = 32u;
const FLAG_COLOR_GRADIENT: u32 = 64u;
Copy link
Member Author

Choose a reason for hiding this comment

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

all the really important changes are in this file

Comment on lines +36 to +41
if uniforms.blend_with_background == 0 {
// To not apply this hack needlessly and account for alpha from alpha to coverage, we have to ignore alpha values if blending is disabled.
color = vec4f(color.rgb, 1.0);
} else {
color = vec4f(color.rgb * color.a, color.a);
}
Copy link
Member Author

@Wumpf Wumpf Nov 11, 2024

Choose a reason for hiding this comment

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

improves alpha to coverage artifact suppression story. In other words this gets non-map views to where they were in 0.19
Tbh. I'm not 100% sure why I did get still artifacts for boxes in 3D without this, but it also didn't feel that surprising.

@Wumpf Wumpf marked this pull request as ready for review November 11, 2024 14:53
@emilk
Copy link
Member

emilk commented Nov 11, 2024

with arrows slightly broken. Afaik we don't use this anywhere in Rerun today though

What about https://rerun.io/docs/reference/types/archetypes/arrows2d ?

@Wumpf
Copy link
Member Author

Wumpf commented Nov 11, 2024

@emilk I should have formulated that more clearly (fixed now!): the shading specifically is slightly broken (see pic). But we don't have the shading ever enabled in Rerun, we made that an opt-in operation

edit: also, the text previously confused left/right when referring to before/after

@abey79 abey79 self-requested a review November 12, 2024 07:36
Copy link
Member

@abey79 abey79 left a comment

Choose a reason for hiding this comment

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

Very nice! Can't say I follow all details in the shader code, but I tested it a bit it seems to work great.

@emilk
Copy link
Member

emilk commented Nov 12, 2024

Make sure to test this on WebGL and WebGPU!

@Wumpf
Copy link
Member Author

Wumpf commented Nov 12, 2024

Make sure to test this on WebGL and WebGPU!

Did! On the Mac only mostly though

@Wumpf Wumpf merged commit 03cb015 into main Nov 12, 2024
37 of 39 checks passed
@Wumpf Wumpf deleted the andreas/line-joints branch November 12, 2024 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
include in changelog 🔺 re_renderer affects re_renderer itself 📺 re_viewer affects re_viewer itself
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LineStrips2D radii not working as expected for real world data Add round joints to line strips
3 participants