-
Notifications
You must be signed in to change notification settings - Fork 344
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
base: main
Are you sure you want to change the base?
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. |
/// Space between grid lines spacing of one line to the next in scene units. | ||
spacing: rerun.blueprint.components.GridSpacing ("attr.rerun.component_optional", nullable, order: 2000); |
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.
The data model lgtm overall 👍🏻 The spacing is slightly ambiguous? Is that the small lines or big lines. For some reason, my (randomly picked) default mental model was that the spacing refers to the big lines, but looking at the screenshots it seems that it's for the small lines. Maybe just clarify that in the doc string.
And then we're good. (That is, until someone requests arbitrary sub-line count to cover for inch/feet/whatever.
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.
thank you!
it's about the small lines. The big lines are right now a hardcoded visual gimmick to deal with zooming out, shows every 10th line
but yeah I can totally see where that confusion comes from!
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
Related
re_renderer
#8230What
Adds new line grid property to the 3D view and enables it by default.
Feedback on variable & type names
welcomeneeded!Docs says it all:
Properties in the viewer:
Examples of the grid in action (in default settings):
Bad case - it's below:
Changes to World grid renderer since original PR
Testing
Draft TODO