Rig Editor · Chapter 11 of 12
Rig Editor: Shader FX Tutorial
Written for version 2.7.0
Four hands-on recipes with the shader graph: a pulsing glow, a pattern with no texture, a dissolve, and a soft glow on a render layer.
The Materials chapter gave a surface its look and opened the shader graph for the first time, and the Rendering chapter covered the engines, lights and render layers. This chapter puts the two to work. You follow four short recipes and finish with a material that pulses, a pattern made with no picture at all, a surface that dissolves, and a soft glow added to a layer.
Materials, the Materials list, and a first look at the shader graph pane.
The two engines, lights, render layers and snapshots.
What a shader graph is
A shader is a small program that decides the colour of every point the editor draws. You do not write it. You build it from nodes: boxes that each make or change one value. A wire carries a value from one node to the next, and the last node in the chain is what you see. That chain is the shader graph.
| Word | What it means here |
|---|---|
| Shader | The recipe that turns a point on a surface into a colour on screen |
| Node | One box in the graph. It makes a value, such as a colour or a pattern, or changes the values wired into it |
| Port | A dot on the side of a node. Inputs are on the left, outputs on the right |
| Wire | A line from an output port to an input port. The value flows along it, left to right |
| Procedural | Made by maths instead of taken from a picture, so it never runs out of detail and needs no texture |
| Emissive | Light a surface gives off by itself, like a screen or a lamp |
| Alpha | How solid a point is: 1 is solid, 0 is not there at all. The graph calls it Opacity |
One editor, two places
- A material has a graph that decides how a surface looks. Recipes 1 to 3 use it. It ends in a node called Surface Output.
- A render layer can have a Shader FX graph, which changes the finished picture of that layer after it is drawn. Recipe 4 uses it. It ends in the same node, under the name Layer Output.
- A material's graph has the Shading and Material folders and a full Input folder, which know about the surface, the lights and the camera.
- A layer's graph works on a flat picture. Shading and Material go, Input keeps only its two clocks, and a Layer folder appears, with Layer Source and the blurs.
- Everything else is shared: the maths, colour, pattern and coordinate nodes work in both.
The moves you will use
| To | Do this |
|---|---|
| Open a graph | Tap a material in the Materials list. Its graph docks under the viewport |
| Work full screen | Tap the arrows at the right end of the graph's header. Back returns to the rig |
| Add a node | Tap an empty part of the canvas, open a folder and tap the node. It lands where you tapped. You can also type in the search field |
| Wire two nodes | Drag from an output dot, on the right of a node, to an input dot, on the left of another |
| Replace a wire | Drop a new wire on an input that already has one. An input holds one wire |
| Remove a wire | Drag it off its input dot and let go over empty canvas |
| Change a value | Tap the node. The inspector on the right lists a number for every input that has no wire. Drag a number up or down, or tap it to open the number editor |
| Move a node | Drag it by its body |
| Delete a node | Tap it, then tap the bin in the header. The button beside the bin duplicates it |
| Move around | Drag empty canvas with one finger to pan, or use two fingers to pan and zoom |
| Step back | Undo, in the top bar, steps back through graph edits like any other change |
The colour of a dot is the kind of value it carries. Grey is one number, yellow is a colour or a direction, green is a pair of numbers. A grey output can go into any input, because one number can stand for red, green and blue alike. A yellow output cannot go into a grey input: the wire will not land. One output can feed many inputs, but an input takes a single wire.
Before the first recipe
- In Node mode, tap Add, then Mesh, then UV Sphere, and tap Add on its card. Any mesh will do. The pictures here use a sphere called Orb standing beside the robot.
- In the Selection Panel, tap + beside Materials and choose New Graph Material. It is called Graph Material and arrives selected.
- Tap the sphere. In the detail panel, scroll to Material and choose Graph Material from the menu.
- Tap Graph Material in the Materials list again. Its graph docks under the viewport with three nodes: Color, PBR and Surface Output.
- The three nodes arrive on top of one another, so the graph looks like a single box. Drag them apart until you can see the wires: Color into PBR, PBR into Surface Output.
Recipe 1: a pulsing glow
You will make the sphere glow and fade as if it were breathing. The PBR node has two inputs for this. Emissive is the colour the surface gives off, and Emissive Strength multiplies it. Drive the strength with the clock and the glow moves.
- Tap the Color node. In the inspector, tap the Color swatch and choose a dark grey. A glow shows best on a dark surface.
- Tap empty canvas, open Parameters and tap Color. A second Color node appears. In the inspector, type Glow in its Label field and set its colour to a warm orange.
- Drag from RGB on the Glow node to Emissive on the PBR node. The sphere now glows steadily.
- Tap empty canvas, open Input and tap Elapsed Time. Its one output, Seconds, counts up for as long as the editor is open.
- Tap empty canvas, open Math, then Common, and tap Ping-Pong.
- Drag from Seconds on Elapsed Time to Value on Ping-Pong.
- Drag from Out on Ping-Pong to Emissive Strength on PBR. The glow starts to rise and fall.
Why it works: Elapsed Time only ever grows, which is no use as a brightness. Ping-Pong folds it back on itself, so its output climbs from 0 to its Scale and down again, over and over. With Scale at 1 that takes two seconds. Emissive Strength multiplies the Glow colour by that number, so at 0 the surface is dark and at 1 it gives off the full colour.
- To make it faster, put a Multiply node, from Math then Common, between the two: Seconds into A, a number such as 3 for B, and Out into Value on Ping-Pong.
- For a softer pulse that eases in and out, use Sin, from Math then Trigonometry, in place of Ping-Pong, and follow it with Scale And Offset, from Math then Common, with Scale 0.5 and Offset 0.5. Sin swings between -1 and 1, and Scale And Offset moves that to 0 and 1.
- To change the colour later, you do not need the graph. Glow is listed under Graph Inputs in the material's panel.
- The pulse runs in the viewport all the time. A snapshot is a still image, so it catches one moment of it.
An emissive surface is bright by itself, but in the regular viewport it does not shine on the things around it and has no halo. Recipe 4 adds the halo.
Recipe 2: a pattern with no texture
A procedural pattern is worked out by maths at every point, so there is no picture to import and it stays sharp however close you look. The Noise node makes soft grey clouds: a single number from 0 to 1 at each point. A Color Ramp turns that number into a colour.
- Make another graph material and give it to the sphere, as before. Drag its three nodes apart.
- Tap empty canvas, open Procedural and tap Noise.
- Tap empty canvas, open Color and tap Color Ramp.
- Drag from Out on Noise to Fac on Color Ramp.
- Drag from Color on Color Ramp to Base Color on PBR. The wire from the Color node is replaced, and the sphere shows black and white clouds.
- Tap the Color Ramp node. The inspector lists its two stops, each a colour and a position. Tap the first swatch and choose a deep blue, then the second and choose a pale green.
Why it works: Fac is the number the ramp looks up. Where Noise gives 0 the surface takes the first stop's colour, where it gives 1 the second, and in between a mix of the two. Add Stop puts another colour in the ramp, up to eight, and Pos moves a stop along it. Stops close together make a hard edge between two colours.
Tune it from Graph Inputs
- Tap empty canvas, open Parameters and tap Float. A Float is a single number, and every Float, Color and Bool node in a graph is also listed in the material's panel.
- In the inspector, type Pattern Size in its Label field and set Value to 5.
- Drag from Out on the Float node to Scale on Noise.
- Tap the old Color node, which is no longer wired to anything, and tap the bin.
- Look at the detail panel. Under Graph Inputs there is now a Pattern Size row. Drag its number: lower gives large soft shapes, higher gives fine grain.
A new Float node holds 0. Wire it into Scale before you set it and the pattern vanishes into one flat colour, because a pattern with a scale of 0 has no detail. Set the value first, or set it straight after.
- The rows under Graph Inputs take their names from each node's Label. A node with no label is listed by its kind, such as Float or Color.
- The rows are in the order of the nodes on the canvas, top to bottom. Move a node up and its row moves up.
- A Color Ramp's stops are not Graph Inputs. To change colours from the panel, build the colours from two Color nodes and a Mix (Lerp) node instead: one colour into A, the other into B, Noise into T.
- Try the other nodes in Procedural in place of Noise: Voronoi Noise makes cells, Wave makes bands or rings, Gradient a smooth sweep and Checker squares.
- On the Noise node itself, Detail (Octaves) adds finer layers of cloud and Distortion swirls them.
- To make a pattern drift, add Scroll Coords from Coordinates and wire its UV output into UV on Noise. Speed sets how fast it moves.
Recipe 3: a dissolve
Alpha is how solid each point of a surface is. Surface Output takes it through its Opacity input. If a pattern drives Opacity, parts of the surface can vanish while the rest stays. This recipe carries on from the pattern material of recipe 2.
- Drag from Out on Noise to Opacity on Surface Output. Noise now feeds two inputs. Nothing changes on the sphere yet, because a new material's Alpha is Opaque, which ignores Opacity.
- In the material's detail panel, turn on Double Sided, so that the inside of the sphere is drawn where the outside is cut away.
- Tap Alpha and choose Mask. A Cutoff row appears under it, set to 0.5, and holes open in the sphere.
- Drag Cutoff. At 0 the whole sphere is there. As it rises, more is eaten away, and at 1 nothing is left.
Why it works: with Alpha on Mask, every point whose Opacity is lower than Cutoff is thrown away and the rest is drawn solid. Noise gives a different number at every point, so raising Cutoff removes the low parts of the pattern first and the high parts last. Because the same Noise also colours the surface, the darkest blue goes first.
| Alpha | What Opacity does |
|---|---|
| Opaque | Nothing. The surface is solid whatever is wired in |
| Mask | Cuts the surface away with a hard edge wherever Opacity is below Cutoff |
| Blend | Fades the surface: 1 is solid, 0.5 is half see through, 0 is invisible. For glass or a ghost, wire a Float into Opacity and set it to a value such as 0.4 |
Recipe 4: a soft glow on a layer
A material's graph can only change the surface it is on. A halo spreads past the edge of the object, so it has to be added to the finished picture. That is what a layer's Shader FX is for. A render layer draws some of your nodes into an image of its own, and its Shader FX graph then changes that image. Give the sphere the pulsing material from recipe 1 first.
- In the Selection Panel, tap + beside Layers. A layer called Layer appears above Main.
- Tap the sphere. In its panel, under Rendering, tap the plus beside Add to Layer and choose Layer.
- Tap Layer in the Layers list. The viewport now shows only what is on that layer, and the detail panel shows the layer's settings.
- Scroll the detail panel to Post FX Passes and turn on Shader FX.
- Look at the new graph. Layer Source is the layer's picture as it was drawn, and Layer Output is what comes out of the pass. They start wired straight through, so nothing changes yet.
- Tap empty canvas, open Layer and tap Gaussian Blur. It gives a blurred copy of the layer's picture.
- Tap empty canvas, open Blend & Compositing and tap Blend. In the inspector, set Mode to Screen.
- Drag from Color on Layer Source to Base on Blend, and from Color on Gaussian Blur to the input named Blend.
- Drag from Out on Blend to Color on Layer Output. The sphere brightens, but the glow stops dead at its edge.
- Tap empty canvas, open Math, then Common, and tap Max.
- Drag from Alpha on Layer Source to A on Max, and from Alpha on Gaussian Blur to B.
- Drag from Out on Max to Opacity on Layer Output. The glow now spreads past the edge.
- Tap Gaussian Blur and raise Radius (px) from 8 to about 24 for a wider halo.
Why it works: Screen is a blend mode that only ever brightens, so the blurred copy adds light on top of the sharp picture. The blur reaches past the sphere's outline, but a layer's picture is see through there, and Opacity decides what is kept. Max takes the larger of the sharp alpha and the blurred alpha, so the soft edge of the blur survives.
- FX Preview, under the layer in the Selection Panel, switches the viewport between Pre, the layer as it was drawn, and Shader, the result of the pass. Use it to compare.
- The other nodes in the Layer folder are used the same way: Directional Blur smears in one direction, Zoom Blur and Spin Blur smear from a centre, Chromatic Aberration splits the colours at the edges, and Layer Depth gives how far away each point is.
- For a plain colour change, put a node from the Color folder between Layer Source and Layer Output, such as Hue/Saturation/Value or Brightness/Contrast.
- Float, Color and Bool nodes in a layer's graph appear in the layer's panel under Shader FX Inputs.
- The pin in the graph's header keeps this graph in the pane while you select other things.
- Filter FX, the second switch under Post FX Passes, is another graph of ready made image filters that runs after Shader FX.
Put the layer in your picture
A layer of your own is not laid over the screen. It draws into an image, and that image is a texture you can use, named after the layer with Target on the end. Main, the layer you see and the one a snapshot is taken of, shows it only where a material uses that texture. So if the glow seems to vanish when you tap Main, nothing is lost: it is still on its layer.
- Tap Main in the Layers list to see the whole picture again.
- Add a Plane and turn it to face the camera.
- Tap + beside Materials and choose New Unlit Material. Give it to the plane.
- In the material's panel, under Texture Slots, tap Base Color and choose Layer Target.
- Set Alpha to Blend, so the empty part of the layer's picture stays see through.
The node folders
| Folder | What it is for | Nodes to know |
|---|---|---|
| Shading | Turns colours and numbers into a lit surface. Material graphs only | PBR |
| Input | Facts about the surface, the camera and the clock. A layer graph keeps only the two clocks | UV Coord, World Position, World Normal, Rim / Fresnel, Elapsed Time, Delta Time |
| Layer | The layer's picture and effects on it. Layer graphs only | Layer Source, Layer UV, Layer Size, Layer Depth, Gaussian Blur, Directional Blur, Zoom Blur, Spin Blur, Chromatic Aberration |
| Parameters | Values you set, which also appear in the panel | Float, Color, Bool, Texture Object |
| Material | The material's own settings and texture slots, as nodes. Material graphs only | Material Base Color, Material Roughness, Material Emissive |
| Math | Sums on numbers and colours, in the subfolders Common, Trigonometry, Exponential, Geometric and Derivatives | Add, Multiply, Mix (Lerp), Clamp, Remap, Smoothstep, Ping-Pong, Sin |
| Logic | Comparisons, and a choice between two values | Is Greater, And, Not, Conditional |
| Blend & Compositing | Lays one colour over another | Blend, with modes such as Add, Multiply, Screen and Overlay |
| Color | Changes a colour, or turns a number into one | Color Ramp, Hue/Saturation/Value, Brightness/Contrast, Saturation, Invert Color, Luminance, RGB Curves |
| Channels | Takes a value apart or builds one | Split Vector, Construct Vector3 |
| Coordinates | Moves, turns and scales where a pattern lands | Offset Coords, Scale Coords, Rotate Coords, Scroll Coords, Mapping |
| Procedural | Patterns made by maths | Noise, Voronoi Noise, Wave, Gradient, Checker |
| Texture Processing | Reads a picture | Sample Texture, Soft Sample Texture |
| Halftone | Print style screens of dots and lines | Dot Screen, Line Screen, CMYK Halftone |
| Utility | Tidying, and cutting points away | Sticky Note, Subgraph, Discard |
When it does not look right
| What you see | What to check |
|---|---|
| Nothing changes on the model | The node may not be wearing this material. Its row in the Materials list shows how many places use it, in orange when none do. Then follow the wires: only what reaches Surface Output is drawn |
| A wire will not land | A yellow output cannot go into a grey input. Put Luminance, from Color, or Split Vector, from Channels, in between to get a single number |
| The model went plain grey | The inspector says the graph failed to compile, and the mesh shows plain PBR until it is fixed. Undo takes you back to the last graph that worked |
| It is black | A Color Ramp with nothing wired into Fac gives its first stop, which starts black. A Float still at 0 that feeds a Multiply or a Scale turns everything after it to nothing. Emissive Strength at 0 switches the glow off |
| It is flat and ignores the lights | A colour wired straight into Surface Output is unlit. Wire it into Base Color on a PBR node, and PBR into Surface Output |
| The pattern is smeared or one flat colour | Patterns are laid out by the mesh's UVs. Unwrap the mesh, as in the UV chapter |
| It is not animating | Something must lead from Elapsed Time to Surface Output. Check that Scale on Ping-Pong is not 0. A snapshot never moves |
| No holes, or no see through | Alpha in the material's panel is still Opaque |
| The layer effect is not visible | Tap the layer, or the Shader FX row under it, and set FX Preview to Shader. Check that the node is on that layer, in its Rendering section. If the layer's panel says the graph failed to compile, the pass is skipped until it is fixed |
| The layer glow is cut off at the outline | Opacity on Layer Output is still wired from Alpha on Layer Source. Use the Max node as in recipe 4 |
| A value is missing from Graph Inputs | Only Float, Color, Bool and Texture Object nodes are listed |
In the Ray Traced engine
- Graph materials are used by both engines, so the first three recipes carry over.
- Under Ray Traced, Main is ray traced and every layer of your own is still drawn Physically Based, with its Shader FX. The layer rows say PBR.
- A few nodes behave differently when ray traced. Delta Time is always 0. The three nodes in the Derivatives subfolder of Math give 0. Material Occlusion gives 1, because ray tracing works out that shading for itself.
- Discard, in Utility, does not cut anything away when ray traced. Cut with Opacity and Alpha set to Mask, as in recipe 3.
- Main gets a pass of its own under Ray Traced. Tap Main in the Layers list and its panel has Post FX Pass with a Filter FX switch, which grades the finished ray traced picture.
Named save points you can return to, and how they differ from Undo.
Tell us which recipe and which step did not match what you saw, and the nodes you had wired. A screenshot of the graph helps.