← All ideas
  • Published 22 Jun 2018

Auto-center nodes of newly created materials in shader editor.

When you create a new material, a shader and output node are set in the node editor. When you edited a material before that, your view might not be centered at the new node setup. In 2.79 and earlier, one could tell by the scroll bars where to look at, but now the bars are hidden unless you hover over them. Either we should show them constantly in the node editor, or the view should be centered, which i prefer.

100%

Development Status: Open

Upvote 4 Downvote 0
grinsegold
22 Jun 2018

5 Comments

nahakaja

I agree with grinsegold's suggestion. The Node Editor needs only something as simple as a fixed origin marker at a nominal 'origin' position in the editor. That way, when adding a new material, the user can ensure they position the node setup approximately around this marker.

1
jojolafertasse1

When you open an old blend file and all the materials have their node trees moved out of center, it is very tedious searching for the nodes each time you select another material. So I made a script to recenter all nodes and now when I import it in a text editor of my blend file I just run it to solve the problem.

"

import bpy

for item in bpy.data.worlds, bpy.data.materials:

for mat in item:
    if mat.use_nodes:
        min_x = 100000.0
        max_x = -100000.0
        min_y = 100000.0
        max_y = -100000.0
        nodes = mat.node_tree.nodes

        for node in nodes:
            (x, y) = node.location
            if x < min_x:
                min_x = x
            if x > max_x:
                max_x = x
            if y < min_y:
                min_y = y
            if y > max_y:
                max_y = y

        mid_x = (max_x+min_x) / 2
        mid_y = (max_y+min_y) / 2

        for node in nodes:
            (x, y) = node.location
            new_loc = (x-mid_x, y-mid_y)
            node.location = new_loc

"

jason

Are you talking about changing the view back to the center of the Node Editor workspace, or just placing the nodes at an arbitrary place that happens to be the center of the current view?

grinsegold Author

@Jason van Gumster: I don't care as long as i don't have to search the nodes or to press a set of keys to bring them to the center of view.

jason

@grinsegold: Well... here are the trade-offs:

  • Status quo: In the 3D View, new assets are added where ever the 3D cursor is... likewise for the Dope Sheet, Graph Editor, and VSE (in those cases, it's the time cursor). The Node Editor doesn't have the concept of a cursor, so the default is to locate objects close to the workspace's origin. The downside here, as you've noted, is that the view is not always centered on the workspace origin, so you can sometimes switch to a node setup that looks empty, but isn't... there are just no nodes in your current view area.
  • Reframe on switch : This is roughly the same as a macro that automatically presses the <kbd>Home</kbd> key whenever you change node setups. Upside is that you always see nodes when you switch. Downside is that if you were focused on one particular section of one node network, you totally lose that framing when you switch networks. Maybe node networks can be tagged with data to remember their individual framing, but I'm not sure how much overhead that would add. My guess is not much, but little "not muches" do tend to add up.
  • Arbitrary placement at view center: Although the Node Editor has its own coordinate space for the work area, most people don't pay much attention to that. So when you switch node networks, you could move the whole node network to center up on the current view. The upsides and downsides here are roughly the same as the Reframe solution, but with the added complication that this solution could potentially get very unwieldy for large node networks. This is probably the least ideal solution.

That's what I could think of on the fly. Probably reframing on switch is the best solution, but only if each node setup can retain its own workspace view. Otherwise, I anticipate that a lot of artists are going to get upset when Blender "turns the page" on them when they switch networks.