Shaders · Chapter 11 of 11

Shaders: Recipes

Written for version 2.7.0

Six complete effects, step by step: a hologram, lava, a toon look, worn painted metal, a surface that burns away, and a glitch on a layer.

The last chapter shaded a whole layer of a picture. That was the final piece: you now have values and shaping, colour, shapes, patterns, noise, time, lit materials and layer effects. This chapter puts them together in six complete effects. Each is a list of exact steps, a live result, a line on why it works, and ways to make it yours.

The six recipes. Every picture is the live result of the graph its recipe builds: five materials on a ball, and one layer effect on a layer's flat picture.

Before you start

  • Recipes 1 to 5 are materials. For each, tap + beside Materials in the Rig Editor, choose New Graph Material, give it to a model, and tap it so its graph docks under the viewport. It starts as three nodes: Color into PBR into Surface Output. Drag them apart.
  • Recipe 6 is a layer's Shader FX. It starts as Layer Source into Layer Output.
  • To add a node, tap empty canvas, open the folder named in the step, and tap the node. To wire, drag from an output dot to an input dot. To set a value, tap the node and use the inspector.
  • Leave any value a step does not mention as it is.
  • Hide the Selection Panel for room, or tap the arrows in the graph's bar to work full screen.
These go further than the tutorial

The Shader FX Tutorial in the Rig Editor path has four shorter recipes: a pulsing glow, a pattern tuned from Graph Inputs, a dissolve and a soft glow on a layer. Start there if these feel long.

Recipe 1: a hologram

A see-through shape made of light: a glowing outline and thin lines that travel up it. It is unlit, so it looks the same in any lighting, and it uses one value twice, once for colour and once for how solid the surface is.

  1. Tap the PBR node and tap the bin. An unlit surface needs no PBR.
  2. Tap the Color node. Type Tint in its Label and choose a bright cyan.
  3. Add Scroll Coords, from Coordinates. Set Speed X to 0 and Speed Y to 0.12.
  4. Add Rotate Coords, from Coordinates. Set Angle (rad) to 1.5708, a quarter turn. Wire UV on Scroll Coords to UV on Rotate Coords.
  5. Add Wave, from Procedural. Set Scale to 16. Wire UV on Rotate Coords to UV on Wave.
  6. Add Smoothstep, from Math then Common. Set Edge 0 to 0.55 and Edge 1 to 0.95. Wire Out on Wave to Value.
  7. Add Multiply, from Math then Common. Wire Out on Smoothstep to A, and set B to 0.4.
  8. Add Rim / Fresnel, from Input. Set Power to 2.2.
  9. Add Add, from Math then Common. Wire Out on Multiply to A and Rim on Rim / Fresnel to B.
  10. Add a second Multiply. Wire RGB on Tint to A and Out on Add to B.
  11. Wire Out on the second Multiply to Color on Surface Output, and Out on Add to Opacity on Surface Output.
  12. In the material's panel, set Alpha to Blend.
The finished graph, panned from left to right, beside its live result. Lines travel up the ball and the outline glows. The same value goes to Color, times the Tint, and to Opacity, so the ball is solid only where it is bright.

Why it works: Wave makes bands across the surface. Rotate Coords turns them a quarter turn so they run round the shape, and Scroll Coords slides them along. Smoothstep keeps only the top of each wave, which leaves thin lines. Rim / Fresnel is bright at the outline. Added together they are a single value, high on the lines and the edge and near 0 elsewhere. Times a colour, it is the picture. Used as Opacity with Alpha on Blend, it makes everything else see-through.

  • Change Tint under Graph Inputs for a different colour.
  • Scale on Wave is the number of lines. Speed Y on Scroll Coords is how fast they travel, and a negative number sends them down.
  • Raise B on the first Multiply for stronger lines, or lower Power on Rim / Fresnel for a thicker edge.
  • Turn on Double Sided to see the lines on the far side through the near side.
  • For a flicker, multiply the Add by a Random Noise whose Seed is wired from Elapsed Time through Multiply and Floor, as recipe 6 does.

Recipe 2: lava

Dark crust with glowing cracks that drift. The glow is real light from the surface: it goes into Emissive.

  1. Tap the Color node. Type Crust in its Label and choose a very dark brown, almost black. Leave it wired into Base Color.
  2. Add Scroll Coords, from Coordinates. Set Speed X to 0.02 and Speed Y to 0.05.
  3. Add Noise, from Procedural. Set Scale to 4, Detail (Octaves) to 4, Roughness to 0.55 and Distortion to 1.2. Wire UV on Scroll Coords to UV on Noise.
  4. Add Color Ramp, from Color. Wire Out on Noise to Fac.
  5. Tap the Color Ramp and tap Add Stop twice, for four stops. Set them, in order, to black at Pos 0.36, deep red at 0.5, orange at 0.62 and pale yellow at 0.78.
  6. Wire Color on Color Ramp to Emissive on PBR.
  7. Tap PBR. Set Roughness to 0.9 and Emissive Strength to 2.
Noise, sliding slowly, read through a four stop Color Ramp into Emissive. Raising Distortion makes the flow more twisted, and raising Scale makes the cracks finer.

Why it works: Noise gives every point a number, and the ramp turns low numbers into black and high ones into fire colours. Black gives off no light, so the low parts of the noise are plain dark crust and the high parts glow. The first stop sits at 0.36, so more than a third of the range is crust. Scroll Coords moves the place the noise reads, which makes the pattern drift.

  • Move the stops closer together for thin bright cracks, further apart for a wide soft glow.
  • Blue and white stops make plasma. Green makes something toxic.
  • Wire Out on Noise through One Minus into Roughness on PBR, so the hot parts are also the shiny parts.
  • Add a layer glow on top, from the Shader FX Tutorial, and the cracks light the air around them.

Recipe 3: a toon look

Flat bands of colour with a dark inked edge, like a drawing. The app has no toon lighting node, so the graph does its own lighting: it compares the way the surface faces with a light direction that you type in.

  1. Tap the PBR node and tap the bin.
  2. Tap the Color node. Type Ink in its Label and choose a near black.
  3. Add World Normal, from Input.
  4. Add Construct Vector3, from Channels. Set X to 0.4, Y to 0.7 and Z to 0.6. This is the direction the light comes from: a little to the right, well above, and toward you.
  5. Add Dot Product, from Math then Geometric. Wire Normal on World Normal to A and Out on Construct Vector3 to B.
  6. Add Color Ramp, from Color. Wire Out on Dot Product to Fac.
  7. Tap the Color Ramp and tap Add Stop twice. Set the four stops to a dark shadow colour at Pos 0.18, a middle colour at 0.2, the same middle colour at 0.62 and a light colour at 0.64.
  8. Add Rim / Fresnel, from Input. Set Power to 1.
  9. Add Step, from Math then Common. Set A to 0.68 and wire Rim on Rim / Fresnel to B.
  10. Add Mix (Lerp), from Math then Common. Wire Color on Color Ramp to A, RGB on Ink to B and Out on Step to T.
  11. Wire Out on Mix (Lerp) to Color on Surface Output.
Dot Product compares World Normal with a typed light direction, and a Color Ramp with its stops pushed together cuts the answer into three flat bands. Moving the light's X and Y moves the bands. Rim / Fresnel through Step inks the outline.

Why it works: Dot Product of two directions is 1 where they agree and falls to 0 where they are at right angles, which is exactly how brightly a light would fall on the surface. A ramp normally fades between its stops. Two stops almost on top of each other leave no room to fade, so the colour jumps: three flat bands. Rim / Fresnel is high at the outline, Step turns it into a hard yes or no, and Mix swaps in the ink where the answer is yes.

  • Change the three colours in the ramp for a different palette. Keep each pair of stops close together.
  • Add two more stops for a fourth band.
  • A in Step is the thickness of the ink line: lower is thicker.
  • Change X, Y and Z on Construct Vector3 to move the light.
This light is yours, not the scene's

The direction you type is the only light this material knows. It ignores the lights and the environment in your rig, and nothing casts a shadow on it. That is the price of an unlit look, and it is also why it stays so clean.

Recipe 4: worn painted metal

Paint flaking off steel. Two whole surfaces, each with its own colour, Metalness and Roughness, and a mask with a ragged edge choosing between them. One number, Wear, controls how much paint is left.

  1. Tap the Color node. Type Paint in its Label and choose a deep green.
  2. Add Noise, from Procedural. Set Scale to 5, Detail (Octaves) to 5 and Roughness to 0.6.
  3. Add Float, from Parameters. Type Wear in its Label and set Value to 0.46.
  4. Add Add, from Math then Common. Wire Out on Wear to A, and set B to 0.05.
  5. Add Smoothstep, from Math then Common. Wire Out on Wear to Edge 0, Out on Add to Edge 1, and Out on Noise to Value. This is the mask.
  6. Add Color, from Parameters. Type Metal in its Label and choose a pale grey.
  7. Add Mix (Lerp), from Math then Common. Wire RGB on Metal to A, RGB on Paint to B and Out on Smoothstep to T. Wire its Out to Base Color on PBR, replacing the wire from Paint.
  8. Add a second Mix (Lerp). Set A to 1 and B to 0, and wire Out on Smoothstep to T. Wire its Out to Metalness on PBR.
  9. Add a third Mix (Lerp). Set A to 0.28 and B to 0.6, and wire Out on Smoothstep to T. Wire its Out to Roughness on PBR.
Noise through Smoothstep is the mask: paint where it is 1, bare metal where it is 0. The Float called Wear is both edges of the Smoothstep. Raise it and the paint flakes away, lower it and the paint returns.

Why it works: Smoothstep is 0 where the noise is below Wear and 1 just above it, so the mask has the ragged shape of the noise with a narrow soft edge. Each Mix reads it as T: where the mask is 0 it gives A, the metal's value, and where it is 1 it gives B, the paint's. Because all three use the same mask, colour, Metalness and Roughness change together at exactly the same line, and it reads as two materials.

  • Wear, Paint and Metal are all listed under Graph Inputs, so the material can be aged from its panel.
  • Raise Detail (Octaves) on Noise for a more broken edge, or Scale for smaller flakes.
  • Make B on the Add smaller for a crisper edge.
  • Choose a rust orange for Metal and set the second Mix's A to 0 for rust in place of bare steel.
  • Add a second, much finer Noise through Scale And Offset into the third Mix's A for scratches in the metal.

Recipe 5: burning away

A surface that is eaten away and comes back, over and over, with a glowing line where it is burning. The Shader FX Tutorial's dissolve is moved by hand, with the panel's Cutoff. This one moves by itself and adds the burning edge.

  1. Tap the Color node and choose a dark grey. Leave it wired into Base Color.
  2. Add Elapsed Time, from Input.
  3. Add Multiply, from Math then Common. Wire Seconds on Elapsed Time to A, and set B to 0.22.
  4. Add Ping-Pong, from Math then Common. Wire Out on Multiply to Value. Its output is the threshold: it climbs from 0 to 1 and back.
  5. Add Noise, from Procedural. Set Detail (Octaves) to 3.
  6. Add Step, from Math then Common. Wire Out on Ping-Pong to A and Out on Noise to B. Wire its Out to Opacity on Surface Output.
  7. Add Add, from Math then Common. Wire Out on Ping-Pong to A, and set B to 0.09.
  8. Add Smoothstep, from Math then Common. Wire Out on Ping-Pong to Edge 0, Out on Add to Edge 1, and Out on Noise to Value.
  9. Add One Minus, from Math then Common. Wire Out on Smoothstep to Value.
  10. Add Color, from Parameters. Type Ember in its Label and choose a hot orange.
  11. Add a second Multiply. Wire RGB on Ember to A and Out on One Minus to B. Wire its Out to Emissive on PBR.
  12. Tap PBR. Set Roughness to 0.7 and Emissive Strength to 3.
  13. In the material's panel, set Alpha to Mask and leave Cutoff at 0.5. Turn on Double Sided.
The clock, slowed and folded by Ping-Pong, sweeps a threshold through a Noise. Step cuts the surface away where the noise is under the threshold. Smoothstep and One Minus find the thin band just above it, and that band glows.

Why it works: Step answers 1 where the noise is at least the threshold and 0 below it. With Alpha on Mask, the 0 parts are cut away. As the threshold climbs, more of the noise falls under it and the holes grow. Smoothstep, between the threshold and a little above it, is 0 right at the cut and 1 further in, so One Minus of it is a band that hugs the edge of every hole. Times the Ember colour, into Emissive, it burns.

  • B on the first Multiply is the speed. B on the Add is the width of the burning band.
  • Scale on Noise sets the size of the holes.
  • To burn once and stop, replace Ping-Pong with Saturate, from Math then Common.
  • To drive it by hand, replace Elapsed Time, Multiply and Ping-Pong with a Float labelled Burn, and drag it under Graph Inputs.
  • Without Double Sided you see straight through the holes to whatever is behind the model.

Recipe 6: a glitch on a layer

A broken signal: strips of the picture jump sideways several times a second while the colours pull apart and snap back. It is a layer's Shader FX, so it works on everything on the layer at once.

  1. Put what you want to glitch on a layer of its own, tap the layer, and switch on Shader FX under Post FX Passes in its panel. The graph docks with Layer Source wired into Layer Output.
  2. Tap Layer Source and tap the bin. The effect node will read the picture itself.
  3. Add Elapsed Time, from Input.
  4. Add Multiply, from Math then Common. Wire Seconds on Elapsed Time to A, and set B to 8.
  5. Add Floor, from Math then Common. Wire Out on Multiply to Value. Its output is a whole number that goes up by one, eight times a second.
  6. Add Scale Coords, from Coordinates. Set Scale X to 0 and Scale Y to 1.
  7. Add Random Noise, from Procedural. Set Scale to 14. Wire UV on Scale Coords to UV, and Out on Floor to Seed.
  8. Add Step, from Math then Common. Set A to 0.75 and wire Out on Random Noise to B.
  9. Add a second Multiply. Wire Out on Step to A, and set B to 0.07.
  10. Add Construct Vector2, from Channels. Wire Out on the second Multiply to X.
  11. Add Offset Coords, from Coordinates. Wire Out on Construct Vector2 to Offset.
  12. Add Ping-Pong, from Math then Common. Wire Seconds on Elapsed Time to Value.
  13. Add a third Multiply. Wire Out on Ping-Pong to A, and set B to 30.
  14. Add Chromatic Aberration, from Layer. Wire UV on Offset Coords to UV, and Out on the third Multiply to Strength (px).
  15. Wire Color on Chromatic Aberration to Color on Layer Output, and Alpha to Opacity.
Random Noise, read in rows and given a new Seed eight times a second, picks a quarter of the rows. Those rows are read from a place to one side, so they jump. Chromatic Aberration's split swells and fades with the clock.

Why it works: Random Noise gives each cell of a grid its own number. Scale Coords with a Scale X of 0 squashes the place it reads to a single column, so every pixel of a row lands in the same cell: 14 rows, one number each. A new Seed gives a new set of numbers, and Floor changes the Seed only eight times a second, so the rows hold still between jumps. Step keeps the rows above 0.75, about one in four. Those rows get a sideways offset, and Chromatic Aberration reads the picture from there, with a strength that Ping-Pong raises and lowers.

  • B on the first Multiply is how many times a second the rows change. Scale on Random Noise is the number of rows.
  • A on Step is how many rows jump: 0.9 is a few, 0.5 is half of them.
  • B on the second Multiply is how far they jump, as a part of the layer's width.
  • B on the third Multiply is the colour split at its strongest, in pixels. It is measured on the layer, so raise it for a large layer.
  • To glitch only now and then, multiply the second Multiply's Out by a Step of another Random Noise whose Seed changes more slowly.

When a recipe does not match

What you seeWhat to check
A wire will not landYou are dragging a colour into a single number, or the other way round where it is not allowed. Check the step's port names
The model went plain greyThe graph failed to compile. The inspector says why. Undo takes you back to the last graph that worked
Nothing is see-throughSet Alpha in the material's panel: Blend for recipe 1, Mask for recipe 5
Nothing movesElapsed Time is not wired, or a Speed is 0
Recipe 3 is lit and shadedThe PBR node is still wired into Surface Output. Remove it
Only part of a colour changedA typed number in a Math node sets one lane. Where a step says wire, wire
Recipe 6 shows nothing on MainThe effect is on its layer. Set FX Preview to Shader, or put the layer's target on a plane

What you can do now

  • Read a value as a brightness and bend it into edges, bands, curves, waves and repeats.
  • Turn values into colour with Mix, Color Ramp and the Color folder.
  • Draw shapes from distances and place them with coordinates.
  • Build patterns and noise, and use one as a mask for another.
  • Make any of it move with the clock.
  • Describe a lit surface to PBR, drive its inputs with patterns, and cut or fade it with Opacity.
  • Shade a whole layer: blur, glow, outline, grade and distort a finished picture.
  • Expose the decisions that matter as Graph Inputs, so a material can be adjusted without opening its graph.

Every effect in this chapter is made of those few moves, and so is almost any effect you will see elsewhere. When you meet one you like, ask what value it starts from, how that value is shaped, and where it ends up: a colour, an input of PBR, or Opacity.

Where to go next

Something unclear?

Tell us which recipe and which step did not match what you saw, and which nodes you had wired. A screenshot of the graph helps.

Send Feedback