[Visual Shader] Fix nodes' relative positions changed in a different display scale.#97620
[Visual Shader] Fix nodes' relative positions changed in a different display scale.#97620akien-mga merged 1 commit intogodotengine:masterfrom
Conversation
|
accidently closed by renaming branch, reopen now |
Geometror
left a comment
There was a problem hiding this comment.
I was concerned that the positions of each node would change in the resource file each time your scale changes (problematic for teams), but this is not the case. However, the size does change. In case you have the time, could you check why this is happening? Otherwise I think it would be fine to merge without the size fix.
The positions in the resource file will not change by display scale with or without this fix. The editor stores the top-left position to file. But, with a bigger scale, all nodes will be rendered larger, which makes them overlap with each other. Which makes the same graph look very different on different display scales. Shaders made by creators with a larger scale (may have a hiDPI display) show more sparse than normal on a smaller display scale and vice versa. This fix makes no change to the stored position but applies scale to the nodes' position on canvas to avoid this case. |
| @@ -281,6 +281,8 @@ class VisualShaderEditor : public ShaderEditor { | |||
| VBoxContainer *param_vbox = nullptr; | |||
| VBoxContainer *param_vbox2 = nullptr; | |||
|
|
|||
| float cached_theme_base_scale = 1.0f; | |||
There was a problem hiding this comment.
Why not just use EDSCALE instead of this separately cached scale?
There was a problem hiding this comment.
Well, I think eventually we will remove the EDSCALE macro for DPI per-monitor awareness
|
This is a really good fix for a problem that is recurrent when more that one person is working on the same visual script. I would really appreciate it if someone would retarget this to 4.5 or 4.6. I would very much like to integrate it to my own Godot build, even if it is not quite finished. |
… a different display scale.
Done, you can test it. |
|
We will very soon try to test this out on 4.5.1. |
|
This might be merged for 4.6, it's currently on the 4.x milestone, it will probably be cherry-picked for a 4.5.x version like 4.5.2 |
|
Thanks for the quick answer, I did not know there was a 4.5.2. |
Geometror
left a comment
There was a problem hiding this comment.
Retested, still works.
There is still the problem with VS nodes derived from VisualShaderNodeResizableBase like Expression (see my earlier comment), however this isn't a regression, so I think we can merge as is. As others have mentioned, this is a rather important fix for larger teams where several people work on the same VisualShader.
|
Godot's Editor UI still handles DisplayScale in a very messy way. The best approach may be to use density-independent pixels at the GUI framework level. This fix isn't perfect. As it stands, a major overhaul of the GUI is needed to remove the use of pixels as the unit of measurement for UI components. We also need to remove the EDSCALE macro to support per-monitor Display Scale. |
|
Thanks! |
|
Cherry-picked for 4.5.2. |



Node positions are not affected by theme scale but their sizes are. Fix this by multiplying GraphElements' positions by the theme scale.
Fix #97484 .
It is worth discussing whether is GraphEdit responsible for maintaining a consistent relative distance between GraphElements under different DPIs.
But in any case, before GraphEdit makes such compatibility-breaking changes, it is worthwhile to make Visual Shader Editor work properly at different DPIs.
Before:
Graph with 100% display scale:
Graph with 200% display scale:
After
Graph with 200% display scale: