Skip to main content

Material graphs

Build your own material from nodes when the standard materials are not enough. You can also use a graph to make a full-screen effect.

The standard material types cover most projects. When they do not, connect nodes into a graph, and the editor turns it into a real material.

Use a graph for things a fixed material cannot do: a scrolling texture, a dissolve, a hologram, water, a colour that changes with the viewing angle, a flag that ripples.

Every node and its ports are in the shader node reference: 95 nodes.

Graph materials are as good as the built-in ones

A graph material gets the same lighting as the built-in types, such as standard, physical and toon, and works on mobile too.

Create a material graph​

  1. Open the Material editor from the left rail.
  2. Click + Create material to start from an empty graph. Or click Clone an existing material to start from a copy of a material you already have.
  3. Add nodes and connect them, from inputs to the output node.
  4. Use the material on your objects like any other material.

You can also create a graph in Project assets: right-click, then choose Create asset → Material graph.

How a graph is built​

A graph runs from inputs, through maths, to the output. The nodes are grouped like this:

GroupWhat you will find
InputsUVs, the surface normal, time, position, textures, which copy is being drawn
Constantsfixed numbers and colours you type in
Matharithmetic and curves on single numbers
Vectorsbuilding, splitting, mixing and turning vectors and colours
Lightinglighting terms you shape yourself
Post-processingnodes that read the rendered frame; see screen effects
Outputwhat the surface looks like in the end

The surface outputs​

The graph ends at the output node. Its inputs describe the surface:

OutputMeans
baseColorthe colour of the surface
metallic0 for non-metal, 1 for bare metal; rarely anything between
roughness0 is mirror-smooth, 1 is completely matte
normalyour own normal, to add surface detail
emissivelight the surface gives off by itself
alphatransparency
clearcoat · clearcoatRoughnessa clear lacquer layer on top
ior · transmission · thicknesslight bending through the surface, for glass and liquids

Any output you leave unconnected keeps its default. An output you do not use costs nothing.

Make each copy look different​

Two input nodes are made for instanced objects, where one object is drawn many times:

  • instanceId tells you which copy is being drawn;
  • instanceColor gives you that copy's tint.
A thousand copies that do not look the same

Feed instanceId into a hash, and every copy gets its own tint, size or animation timing. Grass where every blade sways a little differently costs the same as grass where all blades sway together.

On an ordinary object, both nodes give safe default values. So the graph still works on objects that are not instanced.

Screen effects​

A graph that reads the rendered frame becomes a full-screen effect over the whole scene. It is not something you put on an object. Use it for colour grading, vignettes, blurs or scanlines.

You do not need to set this up. As soon as the graph uses a node that reads the frame, such as screenColor, it becomes an effect.

To add the effect:

  1. Open Space settings.
  2. Click + Add feature and choose Post-processing, if the section is not there yet.
  3. Click + Add effect and pick your graph.

Several effects run in the order you give them.

Textures and colour​

A texture node reads an image from your project. Colour images are converted for you, so the maths works on true colour values.

Mark data textures as data

Some textures hold numbers, not colour: a roughness map, a mask, a height map. Mark these as data, or they get colour-corrected and your values come out slightly wrong. This is the most common reason a roughness map looks nothing like it should.

Change a graph material while the scene runs​

A script cannot change a graph's settings. Scripts cannot reach the graph component. The two common needs are still covered:

You wantDo this
something that animates by itselfuse the time input inside the graph for pulsing, scrolling or shimmering
something that reacts to the gameuse an ordinary material instead; a script can change its emissiveIntensity, color, opacity or roughness

For example, a beacon that pulses forever is a graph that reads time. A beacon that gets brighter when the player scores is a script that changes emissiveIntensity on a standard material.

Tips​

  • Start from an existing material. Clone an existing material turns a standard material into a graph. You get a correct, complete starting point. On an empty canvas, you would rebuild lighting you did not need to.
  • Watch what you add. A graph runs for every pixel, on every frame. A texture lookup is cheap; a loop is not. If the frame rate drops after an edit, check the last node you added.
  • Keep one graph for one look. Every object that uses the graph updates when you change it. So there is one place to fix the look.

Next: Particles — fire, smoke, sparks and dust.