Sub topic 5
The Voronoi Texture Node: Features, Distance Metrics, Randomness
This chapter assumes you can work in the Shader Editor and wire a Principled BSDF. It also assumes you know what the Texture Coordinate and Mapping nodes do, and that you can read a Colour Ramp. Those topics are covered in earlier chapters. Here the focus is the Voronoi Texture node: what each setting computes and which one to pick for a given look.
What the node computes
Voronoi is a cell pattern. Space is divided into a grid, and each grid cell holds one randomly placed feature point. For any shading point, the node finds the nearest feature points and reports a value based on them. Because points exist in every cell and the lookup only inspects neighbouring cells, the pattern is infinite and needs no image.
The node has three groups of settings:
- The feature chooses which measurement is reported (nearest point, second nearest, distance to a border, and so on).
- The distance metric chooses how "near" is measured.
- Randomness and Scale choose how irregular the points are and how many cells fit in a unit of space.
Here is the same flow as a decision aid.
Feature modes
| Feature | What the Distance output means | Typical use |
|---|---|---|
| F1 | Distance to the closest feature point | Stones, tiles, cell shapes |
| F2 | Distance to the second closest point | Web or membrane patterns |
| Smooth F1 | F1 blended between neighbouring points | Soft, organic blobs |
| Distance to Edge | Distance to the nearest cell border | Cracks, grout, veins |
| N-Sphere Radius | Radius of the sphere touching the closest neighbours | Bubbles, pores |
F2 is always greater than or equal to F1. Subtracting F1 from F2 with a Math node gives bright borders that are close to the edges. Distance to Edge is usually cleaner for borders because the lines are narrow and have a more even width.
Outputs
- Distance is a grey value. It is not clamped to 0–1, so you normally pass it through a Colour Ramp to control contrast.
- Color is a random colour per cell. In F1 mode, every shading point inside one cell gets the same colour.
- Position is the location of the feature point that produced the result. It is a vector, so you can feed it to other nodes. For example, it can give each cell its own gradient or its own mapping rotation.
- W appears in the 1D and 4D modes.
- Radius appears only for N-Sphere Radius.
Not every output carries meaning in every feature. N-Sphere Radius, for instance, exposes its own Radius output and not a Distance output. If a socket is missing, check the feature setting before assuming the node is broken.
Dimensions and the extrusion trap
The node can run in 1D, 2D, 3D, or 4D. The default is 3D, which uses the full vector.
- 2D ignores the Z component of the input. With Object coordinates, the pattern is identical at every height and looks extruded along Z. This is fine for a flat floor tile, and wrong for a cube.
- 3D gives consistent results on any surface when you use Object or Generated coordinates.
- 4D adds a W input. Animating W makes the cells shift and reshape over time without moving the object, which suits boiling or evolving surfaces. It costs more to evaluate.
Distance metrics
The metric changes the shape of the cells for F1, F2, and Smooth F1. It does not apply to Distance to Edge or N-Sphere Radius, which always use Euclidean distance. The node also hides the metric in 1D.
| Metric | Cell shape | Notes |
|---|---|---|
| Euclidean | Round, natural polygons | Default and cheapest |
| Manhattan | Diamond-like, angular | Crystalline or tiled look |
| Chebyshev | Square-ish | Blocky, pixel-like cells |
| Minkowski | Adjustable | Uses the Exponent input |
With Minkowski, an Exponent of 1 matches Manhattan and an Exponent of 2 matches Euclidean. Larger values move toward Chebyshev. Values below 1 pinch the cells into star-like shapes. Minkowski is the slowest of the four, so use it only when the other three cannot produce the shape.
Randomness and Scale
Randomness ranges from 0 to 1. At 1, feature points sit anywhere inside their cells and the pattern looks natural. At 0, every point sits at the same spot in its cell, so the cells form a perfectly regular grid. For F1 this gives a repeating lattice, and for Distance to Edge it gives straight grid lines. Values around 0.3 to 0.6 give a loosely ordered look, like brickwork or crop fields.
Scale sets how many cells fit per unit of the input space. Doubling Scale halves the cell width. The visible cell size also depends on the coordinates you feed in, so a Mapping node scale multiplies with it. If cells look too small after you change units, check both.
Smoothness appears only in Smooth F1. At 0 the result matches F1. Higher values blend neighbouring cells together. Detail, Roughness, and Lacunarity layer extra octaves of the pattern, the same way as in the Noise Texture node. Each octave adds evaluation cost, so keep Detail at 0 unless you need the extra breakup. Some features hide these inputs, so a missing socket is expected.
Example: cracks from Distance to Edge
The Distance to Edge output is near zero along cell borders and grows toward cell centres. A very narrow Colour Ramp then separates a thin border from the cell interior. In this script, the ramp goes from black at 0.0 to white at 0.05. The cracks come out black and everything else white. That mask drives Roughness directly, and it also drives a Bump node so the cracks read as recessed lines.
import bpy
mat = bpy.data.materials.new("VoronoiCracks")
mat.use_nodes = True
nodes = mat.node_tree.nodes
links = mat.node_tree.links
bsdf = nodes["Principled BSDF"]
coord = nodes.new("ShaderNodeTexCoord")
voronoi = nodes.new("ShaderNodeTexVoronoi")
voronoi.feature = 'DISTANCE_TO_EDGE'
voronoi.inputs["Scale"].default_value = 4.0
ramp = nodes.new("ShaderNodeValToRGB")
cr = ramp.color_ramp
cr.elements[0].position = 0.0
cr.elements[0].color = (0.0, 0.0, 0.0, 1.0)
cr.elements[1].position = 0.05
cr.elements[1].color = (1.0, 1.0, 1.0, 1.0)
bump = nodes.new("ShaderNodeBump")
bump.inputs["Strength"].default_value = 0.8
links.new(coord.outputs["Object"], voronoi.inputs["Vector"])
links.new(voronoi.outputs["Distance"], ramp.inputs["Fac"])
links.new(ramp.outputs["Color"], bump.inputs["Height"])
links.new(ramp.outputs["Color"], bsdf.inputs["Roughness"])
links.new(bump.outputs["Normal"], bsdf.inputs["Normal"])Moving the second stop to the right widens the cracks. Moving it left makes them thinner. If you want the opposite polarity, with bright cracks, swap the two stop colours rather than rewiring.
Example: warping Voronoi with noise
Straight cell borders look artificial. Feeding a Noise Texture's colour output into the Voronoi Vector input bends them into irregular shapes. The Colour output of Noise is itself a vector-like triple, so it works as a coordinate offset source.
import bpy
mat = bpy.data.materials.new("WarpedVoronoi")
mat.use_nodes = True
nodes = mat.node_tree.nodes
links = mat.node_tree.links
bsdf = nodes["Principled BSDF"]
coord = nodes.new("ShaderNodeTexCoord")
warp = nodes.new("ShaderNodeTexNoise")
warp.inputs["Scale"].default_value = 3.0
voronoi = nodes.new("ShaderNodeTexVoronoi")
voronoi.inputs["Scale"].default_value = 5.0
links.new(coord.outputs["Object"], warp.inputs["Vector"])
links.new(warp.outputs["Color"], voronoi.inputs["Vector"])
links.new(voronoi.outputs["Color"], bsdf.inputs["Base Color"])Here the noise replaces the coordinates entirely. It does not add to them. The cell layout is therefore driven by the noise pattern's own values, which are roughly in the 0–1 range, and Voronoi Scale multiplies them. If you want a milder bend that keeps the original layout, add the noise to the coordinates with a Vector Math node instead. Later chapters on warping cover that approach in detail.
Common errors
- Cells look stretched. The coordinate space is probably UV on a non-uniform unwrap, or Generated on a non-cubic object. Switch to Object coordinates or fix the UV scale.
- A flat band runs through the pattern. You are using 2D on a 3D surface. Switch the node to 3D.
- The metric dropdown has no effect. The feature is Distance to Edge or N-Sphere Radius, which ignore it.
- Everything is white or black after the ramp. The Distance range does not match your stop positions. Preview the raw Distance output first, then place the stops.
- Per-cell colours flicker or look noisy at a distance. Colour output has sharp discontinuities at cell borders. Reduce Scale or add a little blur through a lower-frequency mask.
- Renders are slow. Check for 4D mode, Minkowski, high Detail, or several stacked Voronoi nodes.
Exercise
You need thin, even-width grout lines between irregular stones. Which feature mode and ramp setup do you use, and which metric setting matters?
Show answer
Use Distance to Edge, because its output is near zero along cell borders and rises toward cell centres. Add a Colour Ramp with a black stop near 0.0 and a white stop at a small value such as 0.05, and widen the gap to thicken the lines. The distance metric does not matter, because Distance to Edge always uses Euclidean distance.
Exercise
A floor material uses a Voronoi Texture in 2D mode with Object coordinates. It looks right on a plane, but vertical streaks appear when the same material is applied to a cube. What causes this, and what is the fix?
Show answer
In 2D mode the node ignores the Z component of the input vector, so the pattern is the same at every height and appears extruded along Z. On the cube's vertical faces the changing coordinate is Z, so the pattern stretches into streaks. Switch the node to 3D, or use coordinates that vary on both axes of each face.
Exercise
What happens to F1 cells when Randomness is set to 0, and why might you want that value?
Show answer
Every feature point sits at the same position inside its grid cell, so the cells form a perfectly regular grid. This is useful as a base for tile, brick, or lattice patterns, usually combined with a moderate Randomness or a noise warp to remove the mechanical look.