Changing UI resolution scale messes up nodes snapping #109572
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
4 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#109572
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
System Information
Operating system: Windows-10-10.0.25393-SP0 64 Bits
Graphics card: NVIDIA GeForce RTX 2080 SUPER/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 536.23
Blender Version
Broken: version: 4.0.0 Alpha, branch: main, commit date: 2023-06-30 00:04, hash:
e73a9a6a7d7b
Worked: Never AFAIK
Short description of error
When you have a node tree all snapped to grid and is perfectly organized, you move it and it all moves in an organized manner. But say you change your UI resoltuion scale, or line width; the perfectly organized node tree is not organized anymore 🥲. Now it may seem that this bug is really rare, but it's really infuriating when you open someone's file and you mess up the node tree in seconds by just moving.
Exact steps for others to reproduce the error
I created a small video that demonstrates the bug, but basically the steps are.
Hi, thanks for the report. Maybe scale_factor is taken into consideration for snapping? I'm not sure if this is a bug or intended behavior.
I mean it might be intended behavior, but it's a bit weird since when you change a computer that has a different monitor it will "change" your file so it's really frustrating.
Will confirm for now.
This happens because the snap increment is based on
U.widget_unit
(seeED_node_grid_size()
), which takes into account the dpi, UI scale and line width. Therefore it does not scale linearly with the resolution scale and doesn't match the the way the node editor itself scales.Here's a graph showing how the scaling of U.widget in relation to the resolution scale (dpi of 96 and default line width) deviates from linear scaling:
So I think
widget_unit
just isn't a good fit for this, since it doesn't really represent the way the node editor scales with the resolution scale.I can also reproduce this by just moving the blender window between my laptop screen and external monitor with different dpi. So I think it's fair to call this a bug.
Yes, U.widget_unit shouldn't be used for much at all. It is useful for us when calculating how wide an actual button is. And probably isn't terrible to use for large things like how wide a dialog is.
In almost all cases it could/should be replaced with (20 x UI_SCALE_FAC) and the result will be something that scales properly and smoothly with UI scale. The exceptions are few and far between, basically if the thing really should get bigger/smaller with changes to Line Width.
@costa
Do you mind attaching to this report a sample blend file with such a "well-organized node tree that is snapped to grid"? That way it can act as something to test with.
@Harley
Sure a sample blend file, I organized just some ndoes on my main 4K monitor and then I moved the blender window to my secondary 1080p monitor and aligned it again.
@costa
Sorry to be pedantic, but I want to make sure we are looking at the same things. So hoping you can load this blend file and then carefully describe the problems you see, more clearly than "not organized anymore".
When I view that file I know there are probably a lot of things that could potentially bug you. When changing scale and looking at the actual sizes and positioning of the nodes they behave as I would expect. As line thickness is changed (line width to thin or thick) I do see the nodes change their vertical sizes, but that is expected since the border areas around each input will change.
Separate from the node sizes and placement I am certainly seeing weirdness with the grid itself. As Leon mentions above the grid is changing with line width when it shouldn't. The spacing of the grid should only depend on UI_SCALE_FAC. It is the sizes of the grid dots that should only change with line width.
@Harley
No problem at all, I didn't notice I wasn't clear enough. I created a video of the problem that demonstrates the issue. :)
The reason this bug is so annoying is because my system has a 4K monitor and a FHD, sometimes I create my nodetree on the 4K and sometimes on the other. I use grid snapping all the time so everything is aligned and organized, but if I move the nodes to another monitor the whole alignment and organization is messed up everything will move and won't sync with the previous grid.
Another reason is when I work on another computer it will mess up the aligned to grid nodetree.
I think I understand this issue now, but would love someone to confirm the following ideas, like @lone_noel.
First, an aside. I do think we should change the grid size so that it does not change with line width. That would look something like this:
With the above the snapping grid stays put as you change line width, with only the grid dots changing size. However, this change does not affect this bug report at all...
If you look at the video carefully, everything is spaced nicely at the start. The resolution scale is then changed at 0:04, and at that point the nodes resize and they are all still perfectly aligned. Following is a capture from the video at 0:04 when the nodes are at the new size, with the same nice spacing:
It is only when all the selected nodes are moved together that the spacing changes weirdly at 0:05. So it isn't the sizing of these that is broken but what happens when multiple items are moved when snapping is set to Grid. And that behavior shown is currently by design.
The nodes are not sized to be perfect multiples of the grid size. When we move ONE node at a time it will snap nicely to the grid. But select multiple nodes and move them and we snap each individual node to the grid. This means that some of the nodes will pass a snapping point when others are not near them. This will necessarily cause the nodes to move individually and that will mean that they will move closer and further apart.
I only see two solutions to this. The first is don't have snapping set to grid if you want to move multiple selected items and want them to remain with the same spacing.
The other would be for us to change what happens when snapping multiple items to the grid and only consider ONE node, the active one. I think that might cause more trouble that it is worth though. The active node might be in the middle of the pack and therefore where it is snapping might not make a lot of sense. Perhaps only snap based on the node at the top-left of a selection, but selections aren't always so neat as illustrated here. Selecting just two nodes, far from each other, you might want to be able to snap to locations relative to both.
So I think my advice would be to not move multiple selected nodes while snapping to grid and expect them to keep the same relative distances from each other.
I did some more investigation and I found a weird problem that happens without even moving without moving the nodes.
Here I just scale the resoltion scale between 0.5 and 2.0 and You can see the spacing between the nodes changes.
Thanks for the investigation, @Harley.
Yeah, this seems good!
I think your analysis of the current behavior is spot on, but I think your patch above actually does pretty much fix, what the bug is about.
Yes, the nodes are snapped individually and when they are placed freely on the canvas, the different alignment with the grid can cause them to move closer or further apart.
But once all the nodes are aligned with the grid, they do keep snapping to the grid in sync (barring some potential rounding edge cases, I suppose...)
What the video shows is how nodes that are aligned to the grid, suddenly aren’t anymore after changing the scale/line width, which causes them to realign (and sometimes change spacing) when snapping during transform.
Since your patch would keep the nodes and the grid aligned, when changing the resolution scale/line width/dpi, they also wouldn’t change spacing during transform afterward.
Yeah, it’s a bit unfortunate limitation right now.
I can think of a way to keep the snapping of multiple individually snapping nodes in sync, but looking at the transform operator that doesn’t seem to be easily implementable with how it’s currently set up.
Yes, this is expected behavior. Nodes don't have a fixed height. They are as tall as they need to be to contain the layout of the buttons. Since the buttons are based on the
widget_unit
which scales incrementally rather than strictly linearly, the height of the nodes varies a bit.I'd love it, if in the long run we changed the layout system for nodes so that they are sized more consistently. Changing the UI preferences shouldn't make it so people have to adjust their node layouts.
@lone_noel
I'll post a PR about the node snapping grid sizing issue. But I don't think I can do so as a fix for this, mostly because they was showing the changes from the movement of multiple nodes and not just about changing size. There are quite a few sizing issues here as you've noticed. LOL
I'll try to make another PR that removes the consideration of line width for node positioning. I've tried before and it got a bit tricky as there are some places where line width has to be considered, just because the wires and the connections get larger. I think the strategy has to include comparing screenshots of the result at exactly 1x and 2x resolution scales to make sure those don't change at all. Might help.
@Harley Hey, I can't find the # but I if I remember I think you fixed it, right?
I did fix the only part of this report that is fixable. The snapping now scales positions correctly with UI scale, and the line width now only changes the sizes of the dots. That fixes most weirdness reported here.
Not fixed, but not fixable, is something also shown in this report. Nodes are snapped individually, so moving multiples at once while snapping is on will change spacing as they move as different items snap as they hit snapping points. This is pretty normal. About the only way to change this is to snap only one node when moving multiples, but many people would dislike that. So basically don’t expect to move multiple items together with snapping on and expect them to keep relative distances static - each item snaps
In general this is true, but specifically for moving nodes (rather than rotating or scaling) it can be fixed by applying the snapping to both the initial node location as well as the offset nodes are moved by. Basically first aligning all nodes to the grid so they can then be moved as a block.
I wonder if we really want this though. I'm kinda fond of being able to adjust specific spacing for nodes that aren't aligned with the grid, yet. Even though it can be a bit finicky.
example diff