A homemade engine built on fluid and particle simulation, running entirely on OpenGL Compute Shaders. It models complex flow, friction, projections and collisions ; the whole environment is dynamic, lava and impact change the ground permanently.
Lava is not water, and the difference is the whole problem. Basaltic lava behaves as a non-Newtonian fluid : below a certain shear stress it does not flow at all. The usual first-order description is a Bingham plastic,
τ = τ0 + η · γ̇
a yield strength τ0 that has to be exceeded first, then a plastic viscosity η above it. Fit real flows more closely and you end up at Herschel–Bulkley, with the shear-rate term raised to a power.
That yield strength is why a lava field looks the way it does. It sets a critical thickness on a given slope, hc = τ0 / (ρ g sin α) : thinner than that and the lava simply stops, mid-slope, and stays there. It is what lets levees stand up along the edges of a channel, and what gives a flow front a near-vertical face several metres high.
Viscosity is not a constant either. It climbs steeply as the melt cools and climbs again as crystals grow in it, which the classic Einstein–Roscoe form writes as η = η0(1 − φ/φmax)−2.5 for a crystal fraction φ. A Piton de la Fournaise basalt leaves the vent near 1140 °C at a few hundred Pa·s ; a couple of hundred degrees later it is orders of magnitude stiffer. The solver carries temperature and crust fraction per cell so the same eruption behaves completely differently at 950 °C and at 1'150 °C .
Once a flow has solidified it stops being fluid and becomes terrain : the next flow will run over it, or more often around it, progressively shaping lava rivers !
Visible
Thermal
hover for the infrared view
Lava river formation. Move the cursor over the image to fade to the infrared view, and read the temperature field the solver is actually working on.
The state of the world is held on a regular grid, each cell represent data and flux on a stack of layers : base rock elevation, solidified lava, the main lava layer, with flux, temperature, and crust fraction moving over lava. Every layer lives in GPU memory as data texture and is processed by OpenGL's compute shaders.
Separate layers makes the geology work. Solidified lava is progressively added to the ground the next step reads, and old flow genuinely diverts a new one ; erosion and impacts subtract from it. The simulation and the renderer access the same buffers, and the dynamic mesh follow the terrain frame by frame.
The ground is completely dynamic and interact constantly with the lava layers ! It is simulated as a flow in its own, sculpted by lava.
The consequence is the part we find most satisfying : the structures the simulation produces on its own ; tumuli, long lava rivers, roofed-over channels that become lava tubes, collapsed structures , all the ones you walk over on a real volcano !
Fountains, lava bombs and lapilli are handled by particle systems that are coupled back into the terrain. Every projection that lands adds material where it falls which leads to very natural structures !
Run a fountain long enough on flat ground and you finally get a cone ; out with the right properties for free : a slope close to the angle of repose of the fragments, an asymmetry downwind, and a hornito if the vent narrows.
All cones grew out of a flat lava field during the simulation !
Blocks are simulated as rigid bodies on the GPU, in the same pass neighbourhood as the fluid, so the coupling goes both ways. Rocks and trees sitting on the ground are picked up and carried; a heavy enough obstacle deflects the flow around it and changes where it finally settles.
Each block gets buoyancy from the melt it displaces and drag from the local velocity field, so it rides the surface, catches on the crust, and piles up at the flow front — which is exactly how a real a’a front advances: a bulldozer of loose blocks being pushed and overrun by the melt behind it.
Eruptions start from a crack that can be anywhere from one metre to several hundred metres long, drawn directly on the terrain.
Every parameter of the vent is exposed : flow rate, pressure, lava temperature, ground incline, and the eruptive cycle that drives it - steady effusion, pulsed fountaining, .. change any to see the resulting landform !
One behaviour we like watching : a long fissure that starts erupting along its whole length gradually focuses down onto a single vent, because the cooling of magma against the colder conduit walls causes it to solidify and clog the narrower or slower-flowing parts of the crack, while the faster-flowing zones undergo thermal erosion, widening the pathway and concentrating all the discharge into a single, dominant channel ! Real eruptive fissures do the same thing on the Fournaise !
Nothing is scripted and nothing is baked. Every process, flow, cooling, projection,
deposit, erosion, .. runs live on your GPU !
In the clip below : projections start building a cone, the flow leaves downslope, spread at first and progressively create lava channels !
You can also run it faster than real time and watch a landform assemble itself in a few minutes !
Watch closely small cone forming, and start of a lava river ! Move the cursor over the frame to play it !
Watch more videos of the simulation ! These two from the very first engine proto, showing the lava flow finding its own path in real time !
The physics decides what happens, and the renderer tries to make you believe it, PBR lighting, adaptive tessellation, volumetric atmosphere, particles shadows, emissive lava and raytracing !