Sub topic 8
Breaking up regularity by warping coordinates with noise
This chapter assumes you can work in the Shader Editor and know the Principled BSDF inputs. It also assumes you have read the earlier chapters on texture coordinates, the Mapping node, the Noise Texture node and the Voronoi Texture node. You should know that every texture node takes a Vector input, which is the 3D position it samples.
Why a clean pattern looks fake
A Voronoi Texture divides space into cells whose borders are straight lines. That is correct maths, but real cracked mud, stone veins and worn paint have borders that wander. A plain Noise Texture has a different problem: it is uniformly "cloudy", with no direction or structure.
You can fix both by changing where a texture samples, instead of changing the texture. This is coordinate warping (also called domain warping). You feed a second pattern into the Vector input of the first. Each point on the surface then looks up the pattern at a slightly shifted position, and the output bends.
The principle: texture nodes are functions of position
A texture node computes pattern(position). A Texture Coordinate node supplies position. Warping replaces it with pattern(position + offset(position)), where the offset is itself a noise.
Nothing about the pattern node changes. Only its input does, which is why one warp setup works with Voronoi, Noise, Wave, Musgrave-style noise, or any other node with a Vector socket.
Two ways to warp
Option 1: the Distortion input
The Noise Texture node has a built-in Distortion value. It offsets the coordinates with an internal noise before generating the pattern. Raise it from 0 and the clouds become swirled and stringy. It is one node and needs no wiring, so use it when you only want to disturb a noise.
It cannot warp any other node. For Voronoi, Wave or Brick you need the second option.
Option 2: a separate noise driving the Vector input
Connect the Color output of a Noise Texture to the Vector input of the pattern node. This is the simplest form, and it is what the third code example in this chapter's plan does. It has two weaknesses:
- Strength is fixed. The Color output ranges from 0 to 1, so the noise replaces the coordinates entirely instead of nudging them. The pattern is sampled in a small region (0 to 1 on each axis) and often looks smeared or repeats.
- Position is lost. Because the original coordinates are discarded, scale and placement from your Mapping node no longer apply.
The better form adds a scaled offset to the original position, which gives you a warp-strength control.
Building a controlled warp
The offset should be centred on zero, so that the average surface point is not shifted. Noise output centres near 0.5, so subtract 0.5, scale by a strength, then add to the original coordinates.
import bpy
mat = bpy.data.materials.new("ControlledWarp")
mat.use_nodes = True
nodes = mat.node_tree.nodes
links = mat.node_tree.links
bsdf = nodes["Principled BSDF"]
coord = nodes.new("ShaderNodeTexCoord")
mapping = nodes.new("ShaderNodeMapping")
warp = nodes.new("ShaderNodeTexNoise")
warp.inputs["Scale"].default_value = 3.0
warp.inputs["Detail"].default_value = 2.0
center = nodes.new("ShaderNodeVectorMath")
center.operation = 'SUBTRACT'
center.inputs[1].default_value = (0.5, 0.5, 0.5)
strength = nodes.new("ShaderNodeVectorMath")
strength.operation = 'SCALE'
strength.inputs["Scale"].default_value = 0.4
add = nodes.new("ShaderNodeVectorMath")
add.operation = 'ADD'
voronoi = nodes.new("ShaderNodeTexVoronoi")
voronoi.feature = 'DISTANCE_TO_EDGE'
voronoi.inputs["Scale"].default_value = 5.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.08
cr.elements[1].color = (1.0, 1.0, 1.0, 1.0)
links.new(coord.outputs["Object"], mapping.inputs["Vector"])
links.new(mapping.outputs["Vector"], warp.inputs["Vector"])
links.new(warp.outputs["Color"], center.inputs[0])
links.new(center.outputs["Vector"], strength.inputs[0])
links.new(mapping.outputs["Vector"], add.inputs[0])
links.new(strength.outputs["Vector"], add.inputs[1])
links.new(add.outputs["Vector"], voronoi.inputs["Vector"])
links.new(voronoi.outputs["Distance"], ramp.inputs["Fac"])
links.new(ramp.outputs["Color"], bsdf.inputs["Base Color"])Read the chain from the Mapping node. Its output feeds two places: the warp noise, and the Add node directly. The Add node sums the original position with (noise - 0.5) * 0.4, and the Voronoi samples at that shifted position. The Distance to Edge feature plus a narrow ramp gives thin border lines, now bent into irregular curves.
Setting voronoi.feature before linking is fine, because the socket set changes with the feature. The Distance output exists for this mode.
Why Color and not Fac
The warp needs a different offset on each axis. The Noise Fac output is a single number, so if you plug it into a vector socket Blender copies it into X, Y and Z. Every point then shifts by the same amount along the (1, 1, 1) diagonal, which gives a stretched, one-directional smear.
The Color output holds three differently-seeded noise values, one each for X, Y and Z. The offsets are independent, so the warp bends the pattern in all directions. If you plug in Fac by mistake, the symptom is a pattern that looks sheared along a diagonal.
The three controls and what each does
| Control | Where | Effect on the result |
|---|---|---|
| Warp scale | Scale of the warp Noise | Low values give broad, slow bends. High values give fine, jittery edges. |
| Warp strength | Scale of the Vector Math node | How far points move. Near 0 gives the original pattern. Values larger than the pattern's cell size cause cells to tear and overlap. |
| Warp detail | Detail of the warp Noise | Adds smaller wiggles on top of the big bends. |
Pick the warp scale relative to the pattern scale. If the Voronoi scale is 5 and the warp scale is 3, the warp varies about as fast as the cells. This produces cells that bend gracefully. If the warp scale is far larger than the pattern scale, you get wobbly edges at every border, like hand-drawn lines.
Keep warp Detail low, around 0 to 3. A high-detail noise adds tiny offsets that make edges look noisy instead of organic, and costs more to evaluate for little visible gain.
Warping in other spaces
The offset is added to whatever coordinates you start with.
- Object or Generated: the warp is stable in 3D and has no seams. This is the default choice for solid-looking materials.
- UV: the UV output is 2D with Z equal to 0. A 3D noise still works as an offset, but the Z component of the offset is added to a flat zero, which is fine. The warp inherits any UV stretching, so on stretched UV islands the bends are stretched too.
- Camera or Window: the pattern is screen-locked, so the warp swims across the object when it or the camera moves. This is rarely what you want.
Warping several times
You can chain warps. The output of one noise can warp a second noise, whose output then warps the Voronoi. Each extra layer adds complexity but also cost and a harder-to-tune setup. Two layers is usually the practical limit. Beyond that, the result tends to look chaotic instead of natural.
Common problems
- Pattern looks smeared in one direction. You connected Fac instead of Color, or your strength is too large.
- Cells are torn into disconnected specks. Strength exceeds the cell size. Lower the Scale on the strength node, or lower the Voronoi scale so cells are larger.
- The warp has no visible effect. The warp noise is not connected to the Vector input of the pattern node, or strength is 0. An unconnected Vector input falls back to the default coordinates, so no error is shown.
- Mapping node changes affect the pattern but not the warp. The warp noise takes its Vector from a different source than the pattern. Feed both from the same Mapping node, as in the code above, so one Scale value controls overall size.
- Changing the Voronoi scale also changes how strong the warp seems. The offset is measured in the units of the input coordinates, and the Voronoi Scale multiplies them afterwards. Doubling the Voronoi scale halves the cell size but leaves the offset the same, so the relative warp doubles. Retune strength after changing scale.
Exercise
In the controlled warp above, you replace the Noise Color link into the Subtract node with the Noise Fac output, and the cracks now look sheared along one diagonal. Explain why, and say what changes in the node graph restore independent bends.
Show answer
Fac is a single float. When it is connected to a vector socket, the same value is copied to X, Y and Z, so every point is offset by the same amount along the (1, 1, 1) diagonal. The Color output has three separately seeded noise values, one per axis, so the offsets differ in each direction. Reconnect the Noise Color output to the Subtract node's first Vector input.
Exercise
A Voronoi texture with Scale 8 is warped by a noise with Scale 1 and a Vector Math Scale (strength) of 2.0. The cells appear torn and the pattern is unrecognisable. Name two changes that fix this and what each does.
Show answer
Lower the strength (for example to 0.3 to 0.5) so the offsets are smaller than a cell, which keeps cells intact. Alternatively, raise the warp noise scale so the offset changes quickly across space, which produces small local wobbles instead of large displacements. Reducing the warp noise Detail also removes fine tearing.