rerun icon indicating copy to clipboard operation
rerun copied to clipboard

LineStrips3D with UI point radius is not independent of zoom

Open Henrik-Norgren opened this issue 9 months ago • 1 comments

When rendering LineStrips3D with UI point radius, the result is (contrary to what documentation says) not independent of zoom level. The lines get much thicker when zooming in. This can be seen when running the example code from line_strips3d.hpp. This is also made clear when comparing with the the built-in infinite grid, which does seem to be rendered correctly. See screenshots below.

As a sidenote, the rendering also seems to be much more aliased compared to the infinite grid. Again, see screenshot below.

To Reproduce Run the Linestrips3D example: Image

Then zoom in pretty close. Might be more obvious with a smaller radius, like 1.0.

Expected behavior Same thickness regardless of zoom level. Basically, the same behavior as the infinite grid lines.

Screenshots A zoomed in view where the red line here has a ui point radius of 1.0 (same as the gray grid line next to it, yet clearly much thicker): Image

The red line here goes upwards toward the camera and is clearly thicker at the top compared to the bottom: Image

An example of the aforementioned aliasing, with the line and the grid line at similar size and angle, yet the grid line looks much smoother: Image

Desktop (please complete the following information):

  • OS: Windows 11

Rerun version 0.22.1

Henrik-Norgren avatar Mar 19 '25 16:03 Henrik-Norgren

Thank you for filing this issue!

This should have at least been documented as a limitation when the line renderer was originally set up as it's a direct consequence of how it implements ui sizes right now.

In a nutshell for each vertex we determine the required scene size to achieve a given thickness. Now if the vertices lie very far away from each other (or worse like here relatively far behind the camera) things can get weird: the out of view vertex reports a relatively large size and the in view in the middle of the screen a small one thus creating this strange gradient. I believe the correct solution would be to span up the line completely in screen space if ui-radii are involved. I.e. the "skeleton" points should first be transformed to screen space (preserving depth, so intersections still work correctly) and then the spanning of the line's quad can happen from there on in 2D. The tricky part is that means that perspective divide happens in the vertex shader already (affecting fragment shader interpolation), but I don't think that should be much of an issue in this case 🤔

As a sidenote, the rendering also seems to be much more aliased compared to the infinite grid. Again, see screenshot below.

that is unfortunately expected. For various technical reasons the rendering of the infinite grid works fundamentally different which allows for near perfect anti-aliasing.

The line rendering instead relies on 4x MSAA with alpha-to-coverage sampling for cutouts at the end. That's essentially just jargon for "a lot worse but more flexible". I hope we get the time to implement something higher quality there eventually, but it's an orthogonal issue

Wumpf avatar Mar 19 '25 18:03 Wumpf