Skip to content
Blender

Blender guide · · 8 min read

Blender Geometry Nodes scatter: rocks and grass by slope

Scatter rocks and grass on terrain with a Geometry Nodes group in Blender 5.2: density by slope, 4,181 instances, and what Realize Instances costs on export.

A low poly hill seen from the front, covered in green grass tufts on the flat parts, with a steep brown ridge behind them where grey rocks sit. The words Scatter with nodes are at the top left over a warm evening sky.

How do you scatter rocks and grass in Geometry Nodes?

Distribute points on the faces of the terrain, instance a mesh on each point, and decide where points may appear from the slope of each face. That is the whole idea: Distribute Points on Faces, then Instance on Points, with a number from the surface steering the density. The group in this guide has 31 nodes, which sounds like a lot, but nine of them do the real work.

The picture shows the main stages. The grass chain keeps only the flat faces. The rock chain does the opposite and puts rocks where the ground is steep. Both end in Join Geometry, which adds the terrain itself. An optional Realize Instances turns the result into ordinary triangles, behind a checkbox on the modifier.

Everything here was built and run through Blender 5.2's Python API: real nodes, real links, a real modifier on a 15,488 triangle terrain. At the default settings the group made 4,085 grass tufts and 96 rocks, which is 4,181 instances.

Nine cards connected by arrows. Top row: Slope test, Distribute (random, 20 per square metre), Instance (3 tuft meshes). Middle row: Steepness, Distribute (Poisson, 0.7 m apart), Instance (3 rock meshes). Bottom row, right to left: Join Geometry, Realize, Switch with a Realize checkbox.
The main stages of the Scatter group. A link is drawn only if it exists in the real node tree.

How do you make density depend on slope?

Read the face normal, take its Z component, and compare it with the cosine of the steepest angle you allow. A face pointing straight up has a normal Z of 1. A 30 degree slope has a normal Z of cos(30°), which is 0.866. A vertical wall has 0. So "flat enough" is just Normal Z greater than or equal to cos(Max Slope), and Max Slope is a number you expose on the modifier.

In nodes: Normal into Separate XYZ, take Z, and a Compare node (Float, Greater Than or Equal) against a Math node set to Cosine, fed by Radians of the slope in degrees. Plug the Compare result into the Selection socket of Distribute Points on Faces. Faces that fail the test get no points at all.

The left picture is that normal Z drawn as a colour on the terrain: green is flat, red is steep. The right picture is what the grass and rock chains do with it. Note the noise in the map: even the flat meadow has patches of yellow, which are real small slopes in the mesh, and your threshold decides what counts.

Two renders of the same terrain side by side. Left: the terrain coloured by face normal, green on flat ground and red along a steep diagonal ridge. Right: the same terrain with grass on the flat parts and grey rocks along the ridge.
Left: normal Z as colour. Right: the scatter that uses it.

What do Random and Poisson Disk change?

Distribute Points on Faces has two methods. Random drops points by density and lets them land close together, which suits grass, where overlap hides the pattern. Poisson Disk keeps a minimum distance between points, which suits rocks, because two rocks inside each other look wrong.

They also expose different inputs, and this tripped me up. Random has Density. Poisson Disk has Distance Min, Density Max and Density Factor. Both have Selection. So I used Selection with the slope test for the grass, and Density Factor, a 1 to 0 ramp from steep to flat, for the rocks. If a script asks for a socket that the current method hides, it fails with a key error.

Density is per square metre. 20 per square metre over this 16 by 16 m terrain is about 5,000 tufts if all of it is flat; on the real terrain, with the ridge removed, it came to 4,085. Poisson Disk with a 0.7 m distance and a density of 1.2 gave 96 rocks. Raise the density and the Poisson Disk distance becomes the limit, so for denser rocks lower the distance first.

How do you pick props, rotate and scale them?

Instance on Points takes an Instance socket. Feed it from Collection Info with Separate Children and Reset Children on, so each object in the collection is its own instance and sits at the origin. Turn on Pick Instance and give it an Instance Index from a Random Value (Integer) node. A range of 0 to 100 worked for three props here, because the index is wrapped to the number of instances.

For rotation, use a Random Value on Z turned into a rotation with Euler to Rotation for the grass, so it stays upright and spins. For rocks, take the Rotation output of Distribute Points on Faces, which is already aligned to the surface, and add a random spin with Rotate Rotation. Scale takes a vector, so a Random Value goes into a Combine XYZ on all three axes to keep the size uniform: 0.7 to 1.5 for tufts, 0.25 to 0.7 for rocks.

Keep the source meshes simple. The three tufts are 7, 8 and 9 triangles, and the three rocks 80 triangles each, 264 triangles in all. Because they are instances, Blender stores each mesh once and the 4,181 copies are only transforms. Hide the source objects from the render, and keep them where Blender evaluates them: I hid the objects for rendering and parked them 60 m below the scene, because objects in an excluded collection came out empty when I realized the result from a script.

ng = bpy.data.node_groups.new('Scatter', 'GeometryNodeTree')
N, L = ng.nodes, ng.links

# group inputs show up on the modifier: Max Slope, Grass Density, ...
ng.interface.new_socket('Geometry', in_out='INPUT', socket_type='NodeSocketGeometry')
slope = ng.interface.new_socket('Max Slope', in_out='INPUT', socket_type='NodeSocketFloat')

# slope test: is the face normal's Z at least cos(max slope)?
normal = N.new('GeometryNodeInputNormal')
z = N.new('ShaderNodeSeparateXYZ');            L.new(normal.outputs['Normal'], z.inputs['Vector'])
cos = N.new('ShaderNodeMath');                 cos.operation = 'COSINE'      # fed by Radians(Max Slope)
flat = N.new('FunctionNodeCompare');           flat.data_type, flat.operation = 'FLOAT', 'GREATER_EQUAL'
L.new(z.outputs['Z'], flat.inputs['A']);       L.new(cos.outputs[0], flat.inputs['B'])

# grass: random points on the flat faces, then tufts on the points
dist = N.new('GeometryNodeDistributePointsOnFaces');  dist.distribute_method = 'RANDOM'
L.new(flat.outputs['Result'], dist.inputs['Selection'])
inst = N.new('GeometryNodeInstanceOnPoints')
L.new(dist.outputs['Points'], inst.inputs['Points'])
inst.inputs['Pick Instance'].default_value = True      # choose one of the 3 tufts per point

# on the modifier, in Blender 5.2:
mod = terrain.modifiers.new('Scatter', 'NODES');  mod.node_group = ng
mod.properties.inputs.Socket_4.value = 30.0            # not mod['Socket_4'] any more

How does the slope limit change the result?

The animation moves Max Slope from 6 to 60 degrees and back, and the counts on the panel are read from the modifier at every frame. At 6 degrees only 266 tufts survive and the ridge and every bump are covered with 211 rocks. At 60 degrees there are 5,851 tufts and only 2 rocks.

That is the decision rule worth keeping: the slope limit is your art direction control. A low limit gives a rocky, sparse look; a high one gives a lush meadow. Make it a modifier input, not a number buried in a node, so you can change it without opening the graph.

Add a Seed input to the same modifier and wire it to the Seed socket of both Distribute nodes and the Random Value nodes. Changing it gives a new arrangement with the same rules, which is how you place the same scatter on several terrain pieces without them looking like copies.

A low poly terrain with a diagonal ridge. As the Max Slope value on a panel rises from 6 to 60 degrees and falls again, the number of grass tufts rises from 266 to 5,851 and the rocks fall from 211 to 2, and the grass spreads up the ridge while the rocks disappear.
Max Slope from 6 to 60 degrees and back. Counts are read from the evaluated modifier on each frame.

What does Realize Instances cost when you export?

Realize Instances turns 4,181 instances into 40,356 real triangles. The terrain alone is 15,488 triangles. With the scatter realized it is 55,844, and the exported .glb went from 818 KB to 3,800 KB. The unrealized result is 264 triangles of source meshes plus a list of transforms.

So realize at the end, only when you must. Keep instances while you work, because the viewport and the file stay light. The glTF exporter has an option called Geometry Nodes Instances (Experimental) and a GPU Instances option that is limited to children of an Empty. I measured only the realized export, so test what your exporter version does with instances before you rely on them. Realizing is the safe route, and it costs the triangles above.

For a game, the better answer is often not to export the scatter at all. Export the terrain and the six prop meshes, and place the copies in the engine with a MultiMeshInstance3D in Godot, which draws many copies of one mesh in a single call. I did not test that in Godot for this article. Use Realize Instances when the layout has to be exactly what you see in Blender, as in a baked set piece you will not change.

The export settings guide lists what else to set before export, and the modifiers guide shows why the order of modifiers matters if you put the scatter after other modifiers on the terrain. If you need cheaper props, the low poly workflow shows how to count triangles as you model.

Two sets of bars. Triangles: 15,752 when kept as instances, 55,844 when realized. Exported .glb size: 818 KB for the terrain only, 3,800 KB with the scatter realized. The panel title reads 4,181 instances, 4,085 tufts and 96 rocks.
What the same scatter costs as instances and as real geometry.

What changed in Blender 5.2 when you script this?

Two things cost me time. First, the inputs of a Geometry Nodes modifier are no longer set with md['Socket_2'] = value. In 5.2 the modifier has a properties attribute, and the value goes in modifier.properties.inputs.Socket_2.value, with the socket identifier from the group's interface. The old form raised an error that id properties are not supported for this type.

Second, a script can read stale results. After you change an input, call update_tag() on the object and update the view layer before you count triangles or instances, or the evaluated mesh still shows the old values. In the interface this happens on its own.

The sockets themselves are created with node_group.interface.new_socket(), and collection inputs use the NodeSocketCollection type. The code above is the real skeleton, cut down to the slope test and the grass chain.

Questions people ask

Why is my Distribute Points on Faces missing the Density Factor?
Density Factor exists only with the Poisson Disk method. The Random method has Density. Use Selection for a hard cut-off on either method.
Should I realize instances before exporting to Godot?
Only if the layout must be fixed exactly as in Blender. Realizing multiplied the triangles of this scene by about 3.6. Otherwise export the source meshes and place the copies in the engine, for example with a MultiMeshInstance3D.
How do I keep the scatter from moving every time I edit the terrain?
Points are placed by face, so changing the mesh changes the result. Fix the Seed input, avoid editing the terrain's topology after you place props, or realize and keep a copy once the layout is final.

Sources and further reading