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.
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
- Open the Material editor from the left rail.
- 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.
- Add nodes and connect them, from inputs to the output node.
- 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:
| Group | What you will find |
|---|---|
| Inputs | UVs, the surface normal, time, position, textures, which copy is being drawn |
| Constants | fixed numbers and colours you type in |
| Math | arithmetic and curves on single numbers |
| Vectors | building, splitting, mixing and turning vectors and colours |
| Lighting | lighting terms you shape yourself |
| Post-processing | nodes that read the rendered frame; see screen effects |
| Output | what the surface looks like in the end |
The surface outputs
The graph ends at the output node. Its inputs describe the surface:
| Output | Means |
|---|---|
baseColor | the colour of the surface |
metallic | 0 for non-metal, 1 for bare metal; rarely anything between |
roughness | 0 is mirror-smooth, 1 is completely matte |
normal | your own normal, to add surface detail |
emissive | light the surface gives off by itself |
alpha | transparency |
clearcoat · clearcoatRoughness | a clear lacquer layer on top |
ior · transmission · thickness | light 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:
instanceIdtells you which copy is being drawn;instanceColorgives you that copy's tint.
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:
- Open Space settings.
- Click + Add feature and choose Post-processing, if the section is not there yet.
- 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.
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 want | Do this |
|---|---|
| something that animates by itself | use the time input inside the graph for pulsing, scrolling or shimmering |
| something that reacts to the game | use 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.