This HLSL geometry shader simulates any given model to dissolve into a pile of sand over time.
​
Starting from the bottom of the model, small pieces of sand will start to fall down to a specified ground height, eventually forming a pile. The shape of this pile is customizable but relies heavily on the geometry itself.
​
The pile is a squashed down version of all the small sand particles that are located above a specified height in the geometry.
​
The main parameters that make up the pile are:
- Pile height: This just determines how high the pile is
- Pile offset: determines the height where the pile starts forming
​
This model of pile generation is pretty simple and lightweight. It works well on most models, but falls short on really organic models because the shape only takes the top of the model into account. This can result in floating piles.
Sand Geometry Shader

Code snippet for faking the pile

