Sub topic 1
What a procedural material is and how the node graph evaluates
A procedural material computes its appearance from math at render time instead of reading pixels from an image file. This chapter explains what that means in practice and how Blender evaluates a node graph to produce a colour at each point on a surface. Every later chapter (Noise, Voronoi, Colour Ramp, masks, bump) builds on this model.
Prerequisites
This chapter assumes you can already do the following:
- Move around the 3D viewport and the Shader Editor, and add nodes with Shift+A.
- Read a material as a graph of connected nodes, with a Material Output node at the end.
- Recognise the Principled BSDF node and its main inputs: Base Color, Roughness, Metallic, and Normal.
- Tell UV coordinates (a 2D unwrap of the mesh) apart from 3D coordinates (a position in space).
You do not need to know Python to follow the main text. The one script near the end uses only basic loops and function calls.
Procedural versus image textures
An image texture stores a fixed grid of pixels. Blender looks up the pixel that matches a UV position. A procedural texture stores no pixels. It stores a formula. Given a position in space, the formula returns a value, and Blender calls it again for every point it needs.
This gives procedural materials some properties worth knowing:
- No fixed resolution. You can zoom in as far as you like. The formula returns a new value for every position, so there is no pixel grid to blur or tile.
- Small file size. The material is a handful of numbers and connections, not megabytes of image data.
- Adjustable after the fact. Changing a Scale value or a ramp stop changes the whole pattern. You never re-bake or repaint anything.
- Dependence on coordinates. The formula needs a position as input. If the position is wrong, the pattern is stretched, too large, or too small. Most "my texture looks wrong" problems come from here, and the next chapters cover this in detail.
- Cost at render time. Every evaluation costs computation. A deep graph on a large surface at high sample counts is slower than a single image lookup.
Procedural does not mean random. A Noise Texture node is deterministic: the same position always returns the same value. This is why a procedural material looks identical from frame to frame and across render passes.
What the node graph actually computes
A shader graph describes a function. The function takes a shading point as input and returns a surface description, that is, a shader. A shading point is a location on a surface where the renderer needs to know the material's response. It carries a 3D position, a UV coordinate, a surface normal, and other data.
The renderer does not run your nodes left to right like a script. Evaluation is driven from the output end:
- The renderer reaches a surface point and asks the active Material Output node for its Surface shader.
- The output node looks at what is connected to its Surface socket, usually a Principled BSDF.
- The Principled BSDF needs a value for each of its inputs. For each input that has a link, it asks the connected node. For each input with no link, it uses the number or colour typed on the node.
- Each of those nodes repeats the same process for its own inputs, going further left until it reaches nodes with no inputs to resolve, such as a Texture Coordinate node.
- Values then flow back right: coordinates feed the Mapping node, the mapped vector feeds the Noise Texture, the noise value feeds the Colour Ramp, and the ramp's colour reaches Base Color.
Three consequences follow from this pull-based model.
Only connected nodes matter. A node that does not lead to the active output is never asked for anything, so it has no effect on the render. You can leave experiments lying around in the graph without changing the result. The only cost is clutter.
Left and right are for the reader. The position of a node in the editor does not change what it computes. Only the links do. Arranging data flow left to right is a convention that makes the graph readable.
Each shading point is independent. The graph does not know about neighbouring points. A node cannot "look at" the pixel next to it. The Bump node appears to break this rule, but it does not: it asks the same subgraph for a few nearby values and compares them. Chapter 11 covers how.
The active output
A material can contain several Material Output nodes, for example one targeted at Cycles, one at EEVEE, and one for all renderers. The renderer uses the active one. If you edit a graph and see no change, check that the output you are editing is the active output, and that your new nodes are connected to it.
Data types and sockets
Each socket carries one of a few data types. Knowing them explains most of the odd colours and values you will see.
| Socket type | Contents | Typical use |
|---|---|---|
| Float (grey) | One number | Fac, Roughness, Metallic, Scale |
| Vector (purple) | Three numbers (X, Y, Z) | Coordinates, normals, Mapping input and output |
| Color (yellow) | Red, green, blue, and alpha | Base Color, ramp output, Noise colour output |
| Shader (green) | A description of how a surface scatters light | BSDF output to Material Output |
Blender converts between types automatically when you link sockets of different types. You should know the rules:
- Float to colour or vector: the number is copied into all channels. A float of 0.5 becomes grey (0.5, 0.5, 0.5).
- Colour to float: the channels are combined into a single grey value, weighted by perceived brightness. Green counts more than blue.
- Vector to float: the three components are averaged.
- Colour to vector and back: the three channels are copied across unchanged.
- Shader sockets: these only connect to other shader sockets. You cannot feed a colour into a Shader input without a node that makes a shader, such as an Emission or a BSDF.
The automatic conversion is convenient and also a common source of surprises. If you connect a Noise Texture's colour output into a Roughness input, Blender silently reduces it to a float. That is legal, but the result differs from using the Fac output. Pick the output that matches what the input expects.
Colour data versus numeric data
Procedural nodes produce numbers, not image files, so there is no colour space to choose. Colour space only matters when you add an image texture. Still, keep the distinction in mind. Values that control Roughness, Metallic, or Bump height are measurements, not colours, and should not be treated as if they were colours. In a procedural graph this mostly means using float outputs for those inputs and keeping colour outputs for Base Color.
A first procedural graph
The graph below is the smallest useful one: a Noise Texture goes through a Colour Ramp into Base Color. In the Blender interface the node is named "Color Ramp"; this tutorial uses the British spelling "Colour Ramp" in prose, but the node's internal name in scripts is Color Ramp.
The script builds the graph and then walks it the way the renderer does, starting at the output and following links toward the inputs. It also adds a Voronoi node that is not connected to anything, to show that unconnected nodes are never reached.
import bpy
mat = bpy.data.materials.new("EvalDemo")
mat.use_nodes = True
nodes = mat.node_tree.nodes
links = mat.node_tree.links
bsdf = nodes["Principled BSDF"]
noise = nodes.new("ShaderNodeTexNoise")
ramp = nodes.new("ShaderNodeValToRGB")
links.new(noise.outputs["Fac"], ramp.inputs["Fac"])
links.new(ramp.outputs["Color"], bsdf.inputs["Base Color"])
# Not connected to anything that leads to the output.
unused = nodes.new("ShaderNodeTexVoronoi")
visited = []
def walk(node, depth=0):
visited.append(node)
print(" " * depth + node.name)
for socket in node.inputs:
for link in socket.links:
walk(link.from_node, depth + 1)
output = next(
n for n in nodes
if n.type == 'OUTPUT_MATERIAL' and n.is_active_output
)
walk(output)
print("Reached by evaluation:", len(visited), "nodes")
print("Voronoi reached?", unused in visited)Run it from the Scripting workspace. The printed tree is indented like this:
Material Output
Principled BSDF
Color Ramp
Noise Texture
Reached by evaluation: 4 nodes
Voronoi reached? FalseThe Noise Texture has an unlinked Vector input. In that case Blender supplies a default coordinate, which for most texture nodes is the Generated coordinate of the surface. Chapter 2 explains the options and why you will almost always want to set the coordinate space yourself.
The script mirrors the real evaluation order but is only a model. Cycles and EEVEE compile the graph into their own formats. The result is the same: a node that cannot be reached from the output is dropped.
Evaluation differs slightly between renderers
Cycles and EEVEE both evaluate the same graph, but not in the same way, and this matters for a few node features.
- Cycles runs the shader on the GPU or CPU for every ray hit. Texture nodes see exact positions. It supports every procedural node, true displacement, and the full set of coordinate spaces.
- EEVEE evaluates the shader in the rasterizer. Most procedural nodes work, and results usually match Cycles. Features that depend on actual geometry changes, such as true displacement, behave differently or need extra settings.
If a material looks right in Cycles and wrong in EEVEE (or the other way round), suspect a feature the renderer treats differently, not a bug in your graph. Check the render engine first when you diagnose a mismatch.
Common errors at this stage
- Editing a node that isn't connected. The viewport does not change. Follow the links from the output back to the node.
- Wrong output active. You edit one Material Output while the renderer uses another.
- Relying on automatic conversion. A colour output wired into a float input gives a different grey than the node's float output.
- Reading the graph as a script. Nodes are not steps. A value can be used by several nodes, and each use re-evaluates that part of the graph.
- Expecting detail beyond the formula. A procedural pattern has no detail outside the range of its Detail setting. Zooming in does not add new features past that limit.
Exercise
You build a graph with a Noise Texture, a Colour Ramp, and a Voronoi Texture. The Voronoi node is wired into the Colour Ramp's Fac input in place of the Noise Texture, but the Colour Ramp's own output is not connected to the Principled BSDF. The Principled BSDF Base Color has a typed-in colour. Which of these three nodes affect the rendered surface, and why?
Show answer
None of them. The renderer starts at the active Material Output and only evaluates nodes that lead to it. The Colour Ramp's output goes nowhere, so the ramp is never asked for a value. It never asks the Voronoi or Noise nodes either. The Base Color comes from the typed-in colour. To make the pattern visible, link the ramp's Color output to the Base Color input.
Exercise
A Noise Texture's Fac output is linked to the Roughness input of a Principled BSDF. A colleague changes the link to use the Noise Texture's Color output instead. Roughness is a float input and the Color output is a colour. What does Blender do, and why might the render change?
Show answer
Blender converts the colour to a float automatically, weighting the red, green, and blue channels by perceived brightness. The Color output of a Noise Texture has different values per channel, so the weighted grey differs from the Fac output. The roughness pattern therefore shifts. To avoid this surprise, use the output whose type matches the input.