Skip to content

Working with Operator Graphs

Thomas Mann edited this page Mar 30, 2016 · 1 revision

Creating Operators

As described earlier the ''Operator Workspace'' shows the currently active Operator, e.g. "Home". There are several ways to add new Operators to it: With the Quick Create Window, with the Library View and by copy and pasting.

Connecting Operators to Graphs

Most Operator-Definitions focus on a very precise purpose, like creating a cube, or moving things around, rending a scene into an image-buffer, or blurring images. Similar to Lego-blocks, the real power of Operators emerges by combining them in countless ways.

In Tooll – different from many similar applications – information flows from the bottom to the top. An Operator has it's inputs at the bottom, and provides outputs on its upper side. This might seem counterintuitive, but it will make large graphs easier to read: You start with the final result and only drill down into the dirty details at the bottom, when tweaking details. You will get used to this in no time.

Let's build a small graph:

  1. Click on the background of of the ''Operator Workspace'' to clear the selection.
  2. Press [TAB] to open the ''Quick Create Window'', search for "Cube" and press [Enter] to create it.
  3. Again, press [TAB] and search and create a [Transform]-Operator.

Voila: The output of [Cube] is automatically connected to the .Scene input of the [Transform]-Operator. So far, the scene looks identical, because in its default-state, [Transform] doesn't do anything. But now you can play with the parameters to rotate the cube and change its position.

Let's also adjust the parameters of the [Cube]:

  1. With the [Transform]-Operator selected, enable the "Locked" checkbox in the top ''Selection View''.
  2. Select the [Cube].
  3. Adjust its size parameters.

You can see how both the selection view and the final result are being updated immediate.

Adding more operators to a scene

Let's assume you want to add a [Torus] to your scene. You already know how to add Operators, so this part is easy:

  1. Press [Tab] to open the Quick Create Window
  2. Search for "Torus"
  3. Press Enter

But now the ''Selection View'' shows either the Torus or the Cube. You need something to combine both. This glue is the [Group]-Operator:

  1. Click the ''Workspace'' background to clear the selection.
  2. Create a [Group].
  3. In the Section-View toggle the 'Lock'-checkbox to set the [Group] as the new final output.
  4. Drag the output nose of the [Transform], (which should still connected to the Cube) onto the [Group]
  5. Drag a connection from the output nose of the [Torus] onto the right side of the [Group]

You might notice that you can either replace a existing connection by using its slot, or adding new connections left and right of existing connections. These "empty" slots are indicated with a darker color.

Also notice, that this only works for "multi"-inputs of Operators like [Group] or [Replicate]. The [Transform]-Operator only features a ''single'' .Scene-input that can hold only one connection at a time.

Splitting Connections

Okay, your graph now consists of a group with a transformed [Cube] and a [Torus] with its original position. To move the [Torus] as well, we will need to add another [Transform]-Operator above it:

  1. Select the [Transform]-Operator by clicking it once.
  2. Copy it with by pressing CTRL+C
  3. Paste a copy by pressing CTRL+V

You now have two options to wire up the torus: Either create two new connections or by splitting the existing connection. The later one is a handy short-cut that will save you a lot of time later. So, let's try it:

  1. Make sure connection between [Torus] and [Transform] is visible as a line (e.g. move them apart)
  2. While holding down the [CTRL]-key, drag the new Transform-Operator on the connection. The connection line will light up when the mouse-pointer is touching it.
  3. Release the mouse-key, to split the connection with the [Transform]-Operator.

"Shaking Off" Operators

Frequently you also want to do the opposite of splitting: Removing an Operator from a connection. You can do this "wiggling" the operator in question. It might take some practice, though.

Copies vs. Instances

Let's assume you want to add several copies of the [Cube] to your scene. We already know, how to duplicate Operators by Copy and Pasting. Let's try it:

  1. Start dragging on workspace the background, to select the [Cube] and its [Transform] with a fence-selection.
  2. Press CTRL+C to copy them
  3. Press CTRL+V to paste a copy of both operators
  4. Drag a connection for the new Transform's output nose onto the right side of the [Group].

It looks like we're building up a reversed tree: A single Operator at the top spreading out in detailed roots at the bottom. However, technically speaking tooll doesn't work with a tree, but something called "Directional Asynchronous Graph" or DAG. You don't have to learn or even understand this term. What's important are the consequences for this:

  1. An Operator-output can have more than one connection
  2. You can't build cycles. Eg. you can't connect the output of the [Group] to the input of the [Transform]. (If you try do this, you will get a warning.)

Tooll starts to evaluate the graph from the top node (our [Group]). Then it checks if any of its inputs or parameters needs to be updated. It finds the [Transform]-Operator. This one does the same, and looks at the [Cube] which finally renders a 3d-model of a cube. Since there is nothing more to do at this leave [Group] proceeds to the next input connection and does so until the complete graph has been processed. The technical term for this process is "evaluating the graph". It's a central mechanism of tooll and includes many technical details like caching and managing resources to improve performance, but this is a much as most people need to know.

What is important, however, was the first aspect: An output can have several Connections. With this we can rebuild our graph like this:

  1. Select the 2nd [Cube], (but not its [Transform])
  2. Press [DEL] to remove it.
  3. Drag a connection from the output-nose of the 1st [Cube] onto the second [Transform]

This is interesting: The graph now renders two copies of the same [Cube]. If you adjust the .Size and .Color-Parameters, both instances get updated. Because the cube-geometry is cached this setup not only renders much fasters. It sometimes comes in handy to adjust parameters of a single object that gets replicated several times.

Properties during evaluation of the graph

Let's make our scene a bit more complex:

  1. Select the [Group] and add a [Transform] above it.
  2. With the new [Transform] selected, create a [Camera] above.
  3. Lock the upper ''Selection View'' to the [Camera].
  4. Rotate the [Camera] in the upper Selection view by dragging with the Left-MouseButton.
  5. Move the Camera with the [W], [A], [S], [D] keys.

Note how your scene is being shown from a new perspective, when the [Camera] is used. Also note how the .Position and .Target-parameters of the [Camera] are being updated when rotating the view. And how both ''selection views'' are update simultaneously.

Now try to rotate your complete scene by selecting the upper [Transform] and adjust its ".Rotate"-parameters. Do you see how the upper [Transform] affects the complete scene while the [Transform]s above the [Cube] and [Torus] operator adjust their respective position?

How does this work? You don't have to understand the math behind it. But what's important is that Tooll uses a property that defines where an object is rendered in the scene. And this property is affected by ALL the [Transform]-operators above it. There are many properties like this: for setting materials, textures, variables and even time. We will discuss all of them in Materials, Lighting and Shading.

Let's try this out adding some color to our scene:

  1. Make sure the connection between [Camera] and [Transform] is visible.
  2. Select the [Transform]
  3. Use the ''Quick Create Window'' to add a [Material] Operator above the [Transform]
  4. Click on the Color-Thumb of the .Diffuse parameter.
  5. Use the ''Color Picker'' to change it to an orange tone.

You can see that the color of all of our objects gets changed. (If you changed the .Color-parameters of the [Cube]s and [Torus], CTRL-click the values to reset them).

Just like with [Transform], we can override the material-property of a sub-tree by inserting another [Material] operator:

  1. Insert a [Material] operator between the Torus and the [Transform].
  2. Change the .Diffuse parameter of the transform to blue.

There is an important difference between the material and transform properties: While the transformations get accumulated, each [Material] operator overrides the previous, instead of being blended.