-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
3D editor grid improvements #45594
3D editor grid improvements #45594
Conversation
@@ -5217,6 +5217,29 @@ void Node3DEditor::_init_indicators() { | |||
indicator_mat->set_flag(StandardMaterial3D::FLAG_SRGB_VERTEX_COLOR, true); | |||
indicator_mat->set_transparency(StandardMaterial3D::Transparency::TRANSPARENCY_ALPHA_DEPTH_PRE_PASS); | |||
|
|||
Ref<Shader> grid_shader = memnew(Shader); | |||
grid_shader->set_code("\n" |
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.
Sending the first "\n"
to the next line should play nicer with clang-format (indent everything with 2 tabs, instead of indent everything with 2 tabs after the open parenthesis.
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.
Style nitpick, otherwise looks great to me.
a8af1cf
to
bfd388c
Compare
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.
oops sorry, I was trying to comment and I closed it. I meant that you might want to enable depth write and set the priority so it draws before other objects with transparency, this way they can work together. |
I don't think this is a must, but it would be nice to have. Reducing the high line density and hiding the edges of the grid are two separate issues to me, but I can try to add it while we are at it.
I can see it making a difference when the camera is far from the grid plane. Probably not noticeable in most of the projects I guess, so I will bring it back to 200. |
This commit adds a view-dependant fade to the 3D viewport grid. It fades out at steep view angles to hide the solid regions that appear far from the camera. I also included a fade to hide the grid borders. I added some improvements to the dynamic grid when the camera is in orthogonal mode. It properly handles zoom now, and the grid center is now set to the intersection point between the grid plane and the camera forward ray, keeping the grid always visible.
bfd388c
to
73e62df
Compare
I updated the PR to add a distance based fade, the grid edges should not be visible now. I fixed the style issues too. |
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.
Did some testing, this is great!
This should be merged soon and cherry-picked for 3.2.4. Since we are introducing the infinite grid in 3.2.4, then we may as well make it as nice as possible from the start.
Thanks! |
Cherry-picked for 3.2.4. |
This commit adds a view-dependant fade to the 3D viewport grid. It fades out at steep view angles to hide the solid color regions that appear far from the camera.
I also improved the dynamic grid when the camera is in orthogonal mode by properly handling zoom, and moving the grid center to the intersection point between the grid plane and the camera forward ray.
I increased the default grid size from 200 to 400, so it's harder to reach the edge of the grid, and you don't even notice the grid is actually dynamic. I don't think it will have a significant performance impact, but I might be wrong.
Also, while working on this PR I noticed the dynamic grid system only works for one viewport. All 3D viewports render the same grid, which only cares about the first viewport. That means the rest of viewports may have a grid completely out of view, or with a wrong zoom level.
Fixing the multiple viewports issue is a bit involved, so I think it should be done in a separate PR.
Small comparison
Before:
After: