← Unity assets

SandSim Released

Deformable desert sand for the Universal Render Pipeline, simulated on the GPU.

Get Sand Simulation on the Asset Store ↗

Desert dunes with tracks, scattered boulders and patches of bedrock showing through the sand

Sand you can walk on, dig into and pile up. Feet, wheels and dropped objects press marks into the surface, and the sand they displace piles up around the rim. Slopes that end up too steep collapse at the sand's angle of repose. The wind softens tracks and moves the dunes over time.

The surface is a height field held on the GPU, not particles. The cost is the same whether the ground is pristine or covered in an hour of footprints: one mesh, one draw call.

What it simulates

Displacement

One pass records how much sand each cell lost to whatever pressed into it. The next pass piles that sand back around the rim. Without it, marks look stamped on instead of pressed in.

Angle of repose

Dry sand holds a slope of about 34 degrees and no more. Each cell sheds to lower neighbours and receives from higher ones. Both sides come from the same expression, so the exchange is symmetric and the total volume stays put. Dig a hole and the walls slide back in. Pile sand up and it settles into a cone on its own — the brush only adds height.

Wind

Sand lifted off a cell lands on the next one downwind. The flux is worked out once per pair of cells and applied twice, out of one and into the other, so the total is conserved over long sessions. Set the strength to zero and marks stay where they are.

Bedrock

Sand sits on rock and is never carved below it, so digging bottoms out. Where the rock rises above the dunes it shows through as an outcrop, shaded as stone.

Sand scraped away to reveal a broad patch of bedrock, with boulders resting in the hollows
Dig far enough and you hit rock.
Top down view of sand sculpted into ridges with boulders resting against them
The top-down sculpting demo.

Using it

float   y = field.SampleHeight(worldPos);   // stand on it
Vector3 n = field.SampleNormal(worldPos);   // read the slope
field.ApplyBrush(worldPos, radius, metresPerSecond, mode);

That is most of the API. Put a SandDeformer on anything that should leave a mark. It is a sphere with a radius, so your mesh can be any shape. Call ApplyBrush from a shovel, an explosion crater or a vehicle plough.

There is no collider. The surface lives on the GPU as a texture, so raycasts pass through it. Read SampleHeight instead. That is also how the demo character stays on the surface while digging the ground out from under itself.

Tuning

Four presets: dry dunes, packed sand, fine dust and gravel. Past those you set the angle of repose, flow rate, relaxation passes, wind, dune shape and bedrock, all live in the inspector.

Specifications

PipelineURP. No Built-in or HDRP variant. No URP asset changes needed: it uses no Depth Texture, no Opaque Texture and no custom Renderer Feature.
Unity6000.0 or newer
GPUCompute shader support required — Shader Model 5.0, or GLES 3.1 with compute. WebGL is not supported.
InputDemos work with either input backend. The Input System package is not required.
Performance512 × 512 cells over 120 m at 1440p: about 0.5 ms per frame of simulation, 5 MB of height field, one draw call, 170–290 fps on a desktop GPU.
ContentsFull C# source, compute shader, surface shader, setup window, custom inspector, two demo scenes and a manual. No DLLs and no textures — the sand, rock and boulders are procedural.
LimitsHeight field, so no overhangs or caves. No collider. 32 deformers per frame. Wind ripples are shading, not geometry.

Support

[email protected]