-
Notifications
You must be signed in to change notification settings - Fork 366
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
World grid part 2/2: Integrate into Viewer #8234
Conversation
Latest documentation preview deployed successfully.
Note: This comment is updated whenever you push a commit. |
Web viewer built successfully. If applicable, you should also test it:
Note: This comment is updated whenever you push a commit. |
crates/store/re_types/definitions/rerun/blueprint/archetypes/line_grid_3d.fbs
Outdated
Show resolved
Hide resolved
0c859e6
to
d8eaa07
Compare
### Related This is the first half of * #872 The second half is here: * #8234 ### What Implements a "world grid" to be used later in the spatial views of the viewer. Haven't tested yet how suitable this is for 2D views, might need some adjustments. ## Video Youtube unfortunately compresses this a lot and Github doesn't let me upload any significant amount of video (click me) [![youtube video of world grid v1](http://img.youtube.com/vi/Ho-iGdmJi4Q/0.jpg)](http://www.youtube.com/watch?v=Ho-iGdmJi4Q "World Grid v1") ## Screenshots Analytical anti-aliasing (shown is what is supposed to be a 1ui unit == 2pixel wide line): <img width="1215" alt="image" src="https://github.com/user-attachments/assets/702b82ac-2629-4aa5-9304-0cd3c4d87fc5"> Distance has only the cardinal lines (== every tenth line). Those fade eventually as well: <img width="747" alt="image" src="https://github.com/user-attachments/assets/ebe6b2c9-37e5-4406-8d28-5260cf2940d4"> Fading is based on "how many lines coincide here" which makes fading view dependent rather than distance dependent: <img width="439" alt="image" src="https://github.com/user-attachments/assets/9bea7a42-9edc-4a7d-be19-9498a1f29fdf"> (this makes this hopefully robust for many usecases) Grid intersects non-transparent geometry (transparent geometry will be ignored in the future. previous surveying showed that this is common and not a biggy) <img width="426" alt="image" src="https://github.com/user-attachments/assets/19de2cc9-015d-4fdd-a275-096768119a9e"> Grid fades at acute viewing angles (because empirically and unsurprisingly it looks weird if we don't!) <img width="1437" alt="image" src="https://github.com/user-attachments/assets/2a05b8e5-9915-4dda-9a54-4db829e22ac3"> Tested image quality to be satisfying on high dpi (ui unit == 2 pixels) and low dpi (ui unit == pixel). ## How does it work * Draw a large shader generated plane (mostly because setting up vertex buffers is just more hassle 😄 ) * depth test enabled * depth write disabled * premultiplied alpha blend * make sure we draw this after the background (reminder: we first draw solid, then background) * Fragment shader looks at 2d coordinate on the plane and decides how "liney" it is * using screen space derivatives (ddx/ddy) we figure out how far to go on the plane to achieve a certain line thickness * fades: * fade if the line density gets too high * fade if view angle is too acute relative * ... lot's of details documented in the shader code! I considered just drawing a screen space triangle, but drawing a plane that moves with the camera has lots of advantages: * don't have to manipulate depth * faster since early z just works * less thinking required! * don't cover things above the horizon - even if only the grid is visible, less pixels will be shaded ## Known shortcomings * various hardcoded values around how fading works. Tricky to formalize this better, but likely good enough * Doesn't look equally good at all pixel widths, but decent for the range we care * every tenth line is a "cardinal line", that's nice but it stops there - "infinite" amount of cardinal lines would be nicer * Experimented with that but so far didn't get anything that was compelling. Having many order-of-magnitude lines looks way too busy imho, it needs a mechanism that limits that to two. * Blender's 2D view does this really well, but in 3D they only do two cardinals as well. ## Try it yourself Controls: - Space: Pause - G: Toggle camera mode native: ``` cargo run -p re_renderer_examples --bin world_grid ``` web: ``` cargo run-wasm -p re_renderer_examples --bin world_grid ``` ## Backend testing matrix * [x] Metal * [x] Vulkan * [x] WebGL * [x] WebGPU
d8eaa07
to
6b18472
Compare
6b18472
to
d884bd3
Compare
a34682c
to
0117aa8
Compare
### Related * split out of #8234 ### What * use `ViewProperty` util construct some more * route individual property ui via `view_property_component_ui_custom` making it easier to draw custom ui for specific view properties while still having all tooltip & extra menus be the same
aac6b34
to
87aff22
Compare
### Related * split out of #8234 ### What * use `ViewProperty` util construct some more * route individual property ui via `view_property_component_ui_custom` making it easier to draw custom ui for specific view properties while still having all tooltip & extra menus be the same
Just clicking through some examples it's clear that the grid doesn't end up at the "right" height for most of them. Wonder if it's worth explicitly settign the plane height to make those look good? |
yes, we should likely do some adjustments there on a per example basis. For some examples we may also want to turn it off |
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.
Awesome!
// TODO(#1611): The color picker for the color component doesn't show alpha values so far since alpha is almost never supported. | ||
// Here however, we need that alpha color picker! |
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.
Note: another short term quick win by rolling tagged component to view property. We could make the component ui editor white list some Archetype/Field for the transparency ui.
Related
re_renderer
#8230What
Adds new line grid property to the 3D view and enables it by default.
Furthermore...
Plane3D
component which is meant for later reuse in other contextsThe new view property is best described its fbs:
Properties in the viewer in default selection panel width
New plane controls expanded:
Examples of the grid in action (in default settings):
Bad case - grid is not fine enough and through the scene:
Bad case - grid is above the scene.
Testing
Future work