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

Fix line & points (& depth clouds points) radii being unaffected by scale & projection via Pinhole #4199

Merged
merged 3 commits into from
Nov 13, 2023

Conversation

Wumpf
Copy link
Member

@Wumpf Wumpf commented Nov 10, 2023

What

Longstanding issue!

Shader only fix, in the future the scale factor shouldn't be extracted on the fly for every vertex out of the transform and instead passed in, but I wanted to keep the change minimal. The added vertex shading cost is unlikely to matter all that much short term.
(also was very nice iterating on this and get before/after screenshots ;))

Throw-away test script for this:

import numpy as np
import rerun as rr

rr.init("scale fix test!!!", spawn=True)

#############################
# #2494 & #1219
#############################
rr.log("world/camera", rr.ViewCoordinates.RDF, timeless=True)
rr.log(
    "world/camera/image",
    rr.Pinhole(
        image_from_camera=np.array([[500, 0, 250], [0, 500, 250], [0, 0, 1]]),
        width=500,
        height=500,
    ),
)
rr.log("world/camera/image/rgb", rr.Image(np.ones((500, 500, 3))))
rr.log(
    "world/camera/image/points",
    rr.Points2D(np.random.uniform(0, 500, (30, 2)), radii=1),
)

#############################
# #1223
#############################
rr.log(
    "scaling_stuff/points_unscaled",
    rr.Points3D(
        np.random.uniform(0, 1, (30, 3)),
        radii=0.1,
    ),
)
rr.log(
    "scaling_stuff/points_scaled",
    rr.Points3D(
        np.random.uniform(0, 1, (30, 3)),
        radii=0.1,
    ),
    rr.Transform3D(scale=2.0, translation=[2, 2, 2]),
)


rr.log(
    "scaling_stuff/lines_unscaled",
    rr.LineStrips3D([[0, 1, 0], [0, 1, 1], [0, 0, 3]], radii=0.1),
)
rr.log(
    "scaling_stuff/lines_scaled",
    rr.LineStrips3D([[0, 1, 0], [0, 1, 1], [0, 0, 3]], radii=0.1),
    rr.Transform3D(scale=2.0, translation=[2, 2, 2]),
)

Result:

Before:
image

After:
image

This not only fixes issues with 2D->3D but also with 3D->2D.
Here we add the 3D points to the 2D camera and set a world space size for the points:

Before:
image

After:
image

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 demo.rerun.io (if applicable)
  • The PR title and labels are set such as to maximize their usefulness for the next release's CHANGELOG

@Wumpf Wumpf added 🪳 bug Something isn't working 🔺 re_renderer affects re_renderer itself user-request This is a pressing issue for one of our users labels Nov 10, 2023
@Wumpf Wumpf force-pushed the andreas/fix-2d-in-3d-radii-scale branch from 155f465 to b7bf95c Compare November 10, 2023 16:57
@jleibs jleibs self-requested a review November 13, 2023 14:12
@Wumpf Wumpf merged commit 6ee3c6a into main Nov 13, 2023
37 checks passed
@Wumpf Wumpf deleted the andreas/fix-2d-in-3d-radii-scale branch November 13, 2023 14:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🪳 bug Something isn't working include in changelog 🔺 re_renderer affects re_renderer itself user-request This is a pressing issue for one of our users
Projects
None yet
2 participants