-
Notifications
You must be signed in to change notification settings - Fork 376
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 1/2: add world grid renderer to re_renderer
#8230
Conversation
Web viewer built successfully. If applicable, you should also test it:
Note: This comment is updated whenever you push a commit. |
// X and Y are combined like akin to premultiplied alpha operations. | ||
let intensity_combined = saturate(cardinal_and_regular.x * (1.0 - cardinal_and_regular.y) + cardinal_and_regular.y); |
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.
tbh not so sure about this anymore. Sounded like a compelling idea in Ben's article, but looking at the close-ups I actually don't like the change in color when grid lines meet.
So maybe more like
// X and Y are combined like akin to premultiplied alpha operations. | |
let intensity_combined = saturate(cardinal_and_regular.x * (1.0 - cardinal_and_regular.y) + cardinal_and_regular.y); | |
let intensity_combined = max(cardinal_and_regular.x, cardinal_and_regular.y); |
It's very subtle though either way.
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.
let intensity_combined = saturate(cardinal_and_regular.x * (1.0 - cardinal_and_regular.y) + cardinal_and_regular.y);
let intensity_combined = max(cardinal_and_regular.x, cardinal_and_regular.y);
I think the first is better at this particular angle (less Moiré). Hard to test without camera control
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.
oh wow yeah so much better, agreed
more visual refinements on the way in the follow-up pr
started integrating this into the viewer and will have adjustments to the style based on experiences in real examples. Not feeding those back in because I don't want to redo all those screenshots |
view angle fade is one of the things that isn't holding up: The implementation here is too simplistic. Also the "line density aware fade" is taking care of this well enough |
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.
// It seems that if we want to go down this path, we should ensure that there's only two levels of lines on screen at a time. | ||
const CARDINAL_LINE_FACTOR: f32 = 10.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.
For a reference: in egui_plot
I have an infinite level of lines, but with only three levels viisble at any time, with a smooth fade to avoid discontinuities: https://emilk.github.io/egui_plot/
This means no matter how small or big your plots are, you always have thicker and thinner lines to guide you
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.
have some new ideas that I want to try in the follow-up pr
the main issue I found was that having more than two "types" of lines on screen looks bad. And in a 3d perspective I found it very tricky to select the right levels. That said, maybe it's really not that hard, I want to try some more. Thanks for the link!
// X and Y are combined like akin to premultiplied alpha operations. | ||
let intensity_combined = saturate(cardinal_and_regular.x * (1.0 - cardinal_and_regular.y) + cardinal_and_regular.y); |
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.
let intensity_combined = saturate(cardinal_and_regular.x * (1.0 - cardinal_and_regular.y) + cardinal_and_regular.y);
let intensity_combined = max(cardinal_and_regular.x, cardinal_and_regular.y);
I think the first is better at this particular angle (less Moiré). Hard to test without camera control
381febc
to
16af40b
Compare
### Related * Follow-up of part 1: #8230 * Fixes #872 ### What Adds new line grid property to the 3D view and enables it by default. Furthermore... * improves the grid shader with infinite cardinal lines while showing only two types of "cardinalitities" * this is simply based on log10(camera distance from plane) and then blends between two levels of grid * improve grid's handling of extreme zoom levels. Still some instability on WebGL, but overall much more robust (less flickering/cutoff) * Introduce a general `Plane3D` component which is meant for later reuse in other contexts The new view property is best described its fbs: ```rust /// Configuration for the 3D line grid. table LineGrid3D ( "attr.rerun.scope": "blueprint" ) { /// Whether the grid is visible. /// /// Defaults to true. visible: rerun.blueprint.components.Visible ("attr.rerun.component_optional", nullable, order: 1000); /// Space between grid lines spacing of one line to the next in scene units. /// /// As you zoom out, successively only every tenth line is shown. /// This controls the closest zoom level. spacing: rerun.blueprint.components.GridSpacing ("attr.rerun.component_optional", nullable, order: 2000); /// In what plane the grid is drawn. /// /// Defaults to whatever plane is determined as the plane at zero units up/down as defined by [components.ViewCoordinates] if present. plane: rerun.components.Plane3D ("attr.rerun.component_optional", nullable, order: 3000); /// How thick the lines should be in ui units. /// /// Default is 1.0 ui unit. stroke_width: rerun.components.StrokeWidth ("attr.rerun.component_optional", nullable, order: 5000); /// Color used for the grid. /// /// Transparency via alpha channel is supported. /// Defaults to a slightly transparent light gray. color: rerun.components.Color ("attr.rerun.component_optional", nullable, order: 6000); } ``` Properties in the viewer in default selection panel width <img width="291" alt="image" src="https://github.com/user-attachments/assets/8292f7bb-e2a4-42b4-9147-7bbd72fc38c7"> New plane controls expanded: <img width="281" alt="image" src="https://github.com/user-attachments/assets/0cc19ce7-1031-4b58-bc24-7c2699d5e25b"> Examples of the grid in action (in default settings): <img width="1326" alt="image" src="https://github.com/user-attachments/assets/fe167eef-29e4-478f-a6e2-d2fb82f30a91"> <img width="1563" alt="image" src="https://github.com/user-attachments/assets/d1a878be-16b0-4c9b-873c-fcf1abcd67fd"> Bad case - grid is not fine enough and through the scene: <img width="1154" alt="image" src="https://github.com/user-attachments/assets/cb76355a-778d-4bd9-a724-b4d9b1dffd84"> Bad case - grid is above the scene. <img width="1464" alt="image" src="https://github.com/user-attachments/assets/0a150db3-f344-444a-a4a0-33c877ea38ae"> ## Testing * [x] Metal * [x] Vulkan * [x] WebGPU * [x] WebGL ## Future work * tweak some examples to disable the grid or change its spacing * Extend grid to 2d scenes
Related
This is the first half of
The second half is here:
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)
Screenshots
Analytical anti-aliasing (shown is what is supposed to be a 1ui unit == 2pixel wide line):
Distance has only the cardinal lines (== every tenth line). Those fade eventually as well:
Fading is based on "how many lines coincide here" which makes fading view dependent rather than distance dependent:
(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)
Grid fades at acute viewing angles (because empirically and unsurprisingly it looks weird if we don't!)
Tested image quality to be satisfying on high dpi (ui unit == 2 pixels) and low dpi (ui unit == pixel).
How does it work
I considered just drawing a screen space triangle, but drawing a plane that moves with the camera has lots of advantages:
Known shortcomings
Try it yourself
Controls:
native:
web:
Backend testing matrix