-
Notifications
You must be signed in to change notification settings - Fork 369
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
Properly scale radii for 2D parts shown in 3D space view's pinhole image plane #4196
Conversation
@@ -96,3 +97,30 @@ where | |||
|
|||
Ok(()) | |||
} | |||
|
|||
fn get_radii_scale_factor( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -23,6 +23,7 @@ use re_viewer_context::{ | |||
/// Context objects for a single entity in a spatial scene. | |||
pub struct SpatialSceneEntityContext<'a> { | |||
pub world_from_entity: glam::Affine3A, | |||
pub radii_scale_factor: Option<f32>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs a docstring: what is it? And what is the difference between None
and Some(1.0)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that we don't apply scale factors from transforms this PR is not doing anything wrong per se. But the correct solution is ofc to, well, apply scales from arbitrary transforms!
Meaning, today we also have the bug that if you apply a scale transform to a pointcloud/lines it will just move points further apart/together (or scale length of lines), it however never changes the thickness of lines or points which is desriable whenever their radius is given in world units (remember: We do both)
This can be done fully inside the shader without hurting any rust code. Have it working now, just need to test it a bit more to see if I missed something
My upcoming version will also fix |
…cale & projection via Pinhole (#4199) ### What Longstanding issue! * Fixes #1223 * Fixes #1219 * Fixes #2494 * Replaces #4196 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: ```py 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](https://github.com/rerun-io/rerun/assets/1220815/29d8f98a-c2f9-4503-84c7-83fc7a8814ff) After: ![image](https://github.com/rerun-io/rerun/assets/1220815/3d555ad9-790f-446f-a3c0-d72904db7a84) 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](https://github.com/rerun-io/rerun/assets/1220815/038c6826-d6ee-4e00-93f4-2a964bc56abe) After: ![image](https://github.com/rerun-io/rerun/assets/1220815/132ba0d6-9906-4f22-b4f6-c6ced82e3748) ### Checklist * [x] I have read and agree to [Contributor Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and the [Code of Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md) * [x] I've included a screenshot or gif (if applicable) * [x] I have tested [demo.rerun.io](https://demo.rerun.io/pr/4199) (if applicable) * [x] The PR title and labels are set such as to maximize their usefulness for the next release's CHANGELOG - [PR Build Summary](https://build.rerun.io/pr/4199) - [Docs preview](https://rerun.io/preview/7465b1650dd9be5c712c994827ced405c142edad/docs) <!--DOCS-PREVIEW--> - [Examples preview](https://rerun.io/preview/7465b1650dd9be5c712c994827ced405c142edad/examples) <!--EXAMPLES-PREVIEW--> - [Recent benchmark results](https://ref.rerun.io/dev/bench/) - [Wasm size tracking](https://ref.rerun.io/dev/sizes/)
What
fix_radii_2d_pinhole.mp4
Checklist