Shaders · Chapter 2 of 11

Shaders: The Shader Graph

Written for version 2.7.0

Find the shader graph in the Rig Editor and learn to work in it: make a graph material, add nodes, wire ports, set values and read the output.

The last chapter explained what a shader is: a recipe that every pixel runs to find its own colour. This chapter shows where that recipe lives in Kilona and how to work on it. The recipe is called a shader graph, and you edit it in the Rig Editor on iPad.

Make a graph material

In the Rig Editor a material decides how a surface looks, and every material is a shader graph. The two ready-made kinds, PBR and Unlit, are graphs that have already been wired for you. A graph material is one you wire yourself.

Tap + beside Materials and choose New Graph Material. It arrives selected, with nothing wearing it yet, and its graph docks under the viewport. Hide the Selection Panel for room, then drag the three starter nodes apart.
  1. Open a rig. In the Selection Panel, scroll the Model group down to Materials.
  2. Tap + beside Materials and choose New Graph Material.
  3. The new material is called Graph Material and is already selected. Its panel on the right says Type: Graph, and its graph appears in a pane under the viewport.
  4. Give the material to a node so you can see it: select the node, find Material in its panel and choose Graph Material. The materials chapter of the Rig Editor path shows this step by step.
The three starter nodes sit on top of one another

A new graph material begins as Color into PBR into Surface Output, but the three nodes are placed so close that they overlap. Drag each one sideways by its title before you start. The pane is also narrow while both side panels are open, so hide the Selection Panel with its button in the top bar when you work on a graph.

Open the graph

Select a material and its graph docks in a pane under the viewport: the material's name, + and the full screen arrows in its bar, the tool rail on the canvas, the inspector on the right. Back returns from full screen.
  • The pane shows the graph of whichever material is selected. Select a PBR or Unlit material and you see its ready-made graph.
  • The bar along the top of the pane carries the material's name, a + that adds a node, and two arrows that open the graph full screen.
  • Full screen gives the graph the whole iPad, with the inspector down the right side. Back, at the top left, returns to the rig.
  • Drag the bar between the viewport and the pane to make the pane taller or shorter.

Move around the canvas

  • The dotted area is the canvas. It is far larger than the pane, and you slide and zoom it to reach your nodes.
  • Two fingers always work: drag with two fingers to slide the canvas, and pinch to zoom.
  • One finger on empty canvas does what the rail on the left says. Pan, the top button, slides the canvas. Select, the dashed square, drags a box round several nodes. Zoom, the magnifier, zooms as you drag.
  • Drag a node by its body to move it, whichever tool is lit. With several nodes selected, dragging one moves them all.
  • The canvas remembers where you left it for each material.

Add a node

A node is one step of the recipe. It takes values in on its left side, does one job, and hands the result out on its right side.

Tap empty canvas and the Add Node card opens there. Open a folder, here Procedural, and tap a node, here Checker. It lands where you tapped. Dragging its Out dot onto Base Color puts the pattern on the ball.
  1. Tap an empty part of the canvas. The Add Node card opens where you tapped.
  2. Open a folder, or type in the search field at the top.
  3. Tap a node. It lands where your first tap was and is selected.
  4. The + in the pane's bar opens the same card and puts the new node in the middle of the view.
FolderWhat its nodes are for
ShadingPBR, the node that turns colours and numbers into a lit surface
InputFacts each pixel is given: its UV, its position, which way the surface faces, where the camera is, the clock
ParametersValues you choose: Float (a number), Color, Bool (on or off) and Texture Object (a picture)
MaterialThe material's own settings and texture slots from its panel, as nodes. The ready-made PBR and Unlit graphs are built from these
MathArithmetic and shaping, in five subfolders: Common, Trigonometry, Exponential, Geometric and Derivatives
LogicQuestions with a yes or no answer, such as Is Greater, and Conditional, which picks one of two values
Blend & CompositingBlend, which lays one colour over another with a blend mode
ColorChanging colour: Hue/Saturation/Value, Color Ramp, Float Curve, Invert Color and others
ChannelsTaking a group of numbers apart and putting one together: Split Vector, Construct Vector, Swizzle
CoordinatesMoving, scaling, turning and bending the UV before a pattern uses it
ProceduralPatterns made by maths alone: Gradient, Checker, Wave and several kinds of noise
Texture ProcessingSample Texture and Soft Sample Texture, which read a picture at a UV
HalftonePrint style screens of dots and lines
UtilitySubgraph, Sticky Note and Discard
Search looks where you are standing

At the top level the search field looks through every node. Inside a folder it only looks through that folder, and its placeholder says so. If a node does not turn up, tap All in the trail under the search field and search again.

Ports and types

The dots on the sides of a node are ports. Ports on the left are inputs, where values arrive. Ports on the right are outputs, where the result leaves. The colour of a dot tells you what kind of value passes through it.

A dot's colour is its type. Grey is a Float, a single number. Green is a Vector 2, two numbers. Yellow is a Vector 3, three numbers. Blue is a Vector 4, four numbers. Pink is a Texture, a whole picture.
TypeDotWhat it carries
FloatGreyOne number, such as a brightness or a size
Vector 2GreenTwo numbers together, most often a UV
Vector 3YellowThree numbers together: a colour as red, green and blue, or a direction, or a position
Vector 4BlueFour numbers together: a colour with its opacity
TexturePinkA whole picture. It only joins another pink dot
  • A filled dot has a wire on it. A hollow input has none and uses its own value.
  • Many Math nodes, such as Add and Multiply, take whatever you give them: wire in a Float and they work on one number, wire in a colour and they work on all three at once. Their dots are drawn grey whatever is passing through.

Wire and unwire

Drag from an output dot to an input dot. An input holds one wire, so a new one replaces the old. Drag a wire off its input and let go to remove it. A Vector 2 will not go into a Vector 3 input: the wire falls away.
  • A wire always starts at an output, on the right of a node, and ends at an input, on the left of another.
  • An output can feed as many inputs as you like. An input holds one wire, and dropping a second on it replaces the first.
  • To remove a wire, drag it off its input and let go over empty canvas. To move it, drag it off and drop it on another input.
  • A wire takes the colour of the output it comes from.
When a wire will not attach

An input accepts its own type or a Float. A Float fits anywhere, because the one number is copied into every slot: wire a Float into a colour input and you get a grey. A group of numbers will not go into an input of a different size, so a UV, which is two numbers, cannot go straight into a colour input, which wants three. The wire simply falls away when you let go.

To getFromUse
One numberA group of numbersSplit Vector, which gives X, Y, Z and W each as a Float
A colourUp to three numbersConstruct Vector3, with a Float into each of X, Y and Z
A UVTwo numbersConstruct Vector2
The same numbers in another orderA group of numbersSwizzle 2, Swizzle 3 or Swizzle 4

The inspector: values and wires

Select Checker and the inspector lists Scale, its one input without a wire. Drag on the number and the squares on the ball follow. Wire a Float node into Scale and the row leaves the inspector: the wire is in charge now.
  • Tap a node to select it. A blue outline appears round it and the inspector, on the right of the pane, shows what can be set on it.
  • Every input can get its value in one of two ways: from a wire, or from a number you set in the inspector. The inspector only lists inputs that have no wire.
  • To change a number, drag up or down on it. Tap it instead to open the number editor and type.
  • Some nodes also have menus in the inspector, such as Type on Gradient or Mode on Blend.
  • With nothing selected, the inspector counts the nodes and connections in the graph.
Where did my number go?

If a value you set earlier has vanished from the inspector, that input now has a wire on it. Drag the wire off and the row comes back with the number it had before.

The output node

Every material graph has exactly one Surface Output. It is the end of the recipe: whatever reaches it is what you see. It has no outputs, it cannot be deleted, and it is not in the Add Node card because there is always one already.

A colour wired straight into Surface Output is unlit: flat, the same in any light, so the ball looks like a disc. Sent through a PBR node first, the same colour is lit and shaded, and Roughness and Metalness change how.
InputWhat it means
ColorThe colour of this pixel. Wire a PBR node in for a surface that reacts to light, or any other colour for a flat, unlit one
OpacityHow solid this pixel is, from 0, see through, to 1, solid. It only shows when the material's Alpha is set to Blend or Mask in its panel

The PBR node is what makes a surface look real. You give it a Base Color and, if you like, Metalness, Roughness, a Normal, an Emissive glow and more, and the renderer lights the result. It must be wired straight into Surface Output's Color to do its work. The Materials chapter of this path goes through its inputs one by one.

The graph failed to compile

If a graph cannot be built, for example because a Math node has been given a UV on one input and a colour on another, the inspector says so in red when no node is selected, and the model shows plain PBR until the wiring is fixed. Undo takes you back to the last graph that worked.

Graph Inputs

Graph Inputs sits at the foot of the material's panel, with a row for each Float and Color node. Type a Label in the node's inspector to name its row. Then change the number or the colour right there in the panel.
  • You will often want to change a colour or a number later without opening the graph. Every Float, Color, Bool and Texture Object node in a graph is also listed in the material's panel, under Graph Inputs.
  • Select the Float, Color, Bool or Texture Object node and type a Label in the inspector. The row in the panel takes that name. Without a Label the row is simply called Float or Color.
  • The rows are listed in the order the nodes sit on the canvas, top to bottom.
  • Changing a row in the panel changes the node's value in the graph. They are the same value.

Delete, duplicate and undo

Select a node and the pane's bar gains Duplicate and a red trash. The trash removes the node and its wires, and the input it fed falls back to its own value. Undo, in the Rig Editor's top bar, puts everything back.
  • With a node selected, Duplicate and the trash appear in the pane's bar and at the foot of the tool rail.
  • Deleting a node removes its wires too.
  • A duplicate lands just below and to the right of the original, with the same wires coming into it.
  • Undo and Redo are the two arrows in the Rig Editor's top bar. Adding a node, wiring, deleting, and one whole drag of a number each count as one step.

Subgraphs and notes

When a graph grows crowded, select a group of nodes and tap the grouping button at the foot of the tool rail: they fold into one Subgraph node, which you can name and open again with Enter Subgraph in its inspector. A subgraph has at most eight inputs and four outputs, and you can also add an empty one from the Utility folder. Sticky Note, also in Utility, is a yellow note for writing yourself a reminder on the canvas. It does nothing to the picture.

Something unclear?

Tell us which step you were on, what you tapped or dragged, and what the graph or the model did instead of what you expected.

Send Feedback