Lava on solver (whose materials must include options.material, default lava). lighting is shared with other
systems if given; envMap (e.g. scene.environment) lights the surface instead of the sky colour of lighting.
Optionalmaterial?: stringName of the solver material that is lava (compiled into the solver).
Optionalrender?: {The screen-space surface: particle spheres → depth → bilateral smoothing → normals, shaded with the lava field.
Optionalclasts?: numberClinker: each crack cell is a clast tilted at random up to this much (0 a continuous skin, 1 rubble).
Optionalcracks?: numberGlow of the crust's crack network, 0…1: cooling-joint cells of crackSize whose edges, crackWidth wide, glow at the
melt temperature under the crust (dark where the lava below has cooled too), and of crust cracks opening in the flow.
OptionalcrackSize?: numberCrack cell size, metres (pāhoehoe crust plates ~0.3 m, ʻaʻā clinker ~0.1 m).
OptionalcrackWidth?: numberCrack width, metres.
Optionalcrust?: stringBasalt albedo, #rrggbb (sRGB; ~0.05 linear).
Optionalintensity?: numberEmission scale (1: against a noon sun of intensity 3, 1400 K lava has radiance LAVA_GLOW_1400).
Optionaliterations?: numberSmoothing passes (each a horizontal and a vertical blur), 0…4.
Optionalradius?: numberSphere radius of a particle, in particle spacings (Δx / 2). About 1.3 makes neighbours overlap into one surface.
Optionalresolution?: numberResolution of the offscreen passes relative to the drawing buffer (0.25…1).
OptionalropeLength?: numberRope spacing, metres.
Optionalropes?: numberRopy folds of the cooled skin (pāhoehoe), 0…1: ridges across the surface flow, where the skin has gone dark.
Optionalroughness?: numberCrust roughness: glassy pāhoehoe skin ~0.5, clinkery ʻaʻā ~0.9.
Optionalsmoothing?: numberDepth smoothing radius, in sphere radii: large for smooth pāhoehoe skin, small to keep ʻaʻā clinker lumpy.
OptionalenvMap?: Texture<unknown, TextureEventMap> | nullOptionallighting?: ParticleLightingReadonlyfieldPer grid node (texel), written by the thermal step: x lava fill φ, y mean temperature (K), and the glow of the surface particles (skin, or bulk where a crust crack opens) premultiplied: z Σ fill·T_glow (K), w their fill. The drawing divides z/w after trilinear filtering, so the glow is as continuous as the surface.
ReadonlylightingSun and sky light for the surface (fill it with lighting.fromScene(scene)).
ReadonlymaterialIndex of the lava material in the solver.
ReadonlyobjectAdd this to your scene: the full-screen surface pass (drawn after the opaque scene, it reads its depth).
Resolved drawing options.
ReadonlysolverThe solver it runs on.
ReadonlyuniformsShader uniforms.
Clast tilt.
Crack glow.
Crack cell size, metres.
Crack width, metres.
Crust albedo (linear).
Blur direction.
Simulated seconds since the last thermal step.
Environment light scale (the scene's environmentIntensity).
How many.
Most lava fill a new particle may land in.
First ring slot of the particles MPMLava.emit added since the last step.
Emission scale.
Solver origin, world.
Projection [0][0] and [1][1].
Sphere radius, metres.
Camera right, world.
Rope spacing, metres.
Rope amplitude.
Crust roughness.
Smoothing radius, metres.
One texel of the offscreen passes.
Camera up, world.
Frees the GPU passes, targets and meshes (not the solver).
Adds lava (an MPMEmit block, by default this material at its eruption temperature) through a vent that only
fills free space: before the next step, new particles that land where the lava fill φ (from the last thermal step) is
above maxFill are removed. MPM reads density from each particle's own deformation, so a particle born inside lava
would add mass without pressure, and a vent pouring faster than the flow carries lava away would pack it ever denser.
Returns how many were added (before the gate).
The solver's passes for dt and then the thermal step, for one renderer.compute(...).
Draws the offscreen surface passes for camera (each frame, before rendering the scene that holds object).
Merges input into the drawing options (material is fixed at construction).
Optionalmaterial?: stringName of the solver material that is lava (compiled into the solver).
Optionalrender?: {The screen-space surface: particle spheres → depth → bilateral smoothing → normals, shaded with the lava field.
Optionalclasts?: numberClinker: each crack cell is a clast tilted at random up to this much (0 a continuous skin, 1 rubble).
Optionalcracks?: numberGlow of the crust's crack network, 0…1: cooling-joint cells of crackSize whose edges, crackWidth wide, glow at the
melt temperature under the crust (dark where the lava below has cooled too), and of crust cracks opening in the flow.
OptionalcrackSize?: numberCrack cell size, metres (pāhoehoe crust plates ~0.3 m, ʻaʻā clinker ~0.1 m).
OptionalcrackWidth?: numberCrack width, metres.
Optionalcrust?: stringBasalt albedo, #rrggbb (sRGB; ~0.05 linear).
Optionalintensity?: numberEmission scale (1: against a noon sun of intensity 3, 1400 K lava has radiance LAVA_GLOW_1400).
Optionaliterations?: numberSmoothing passes (each a horizontal and a vertical blur), 0…4.
Optionalradius?: numberSphere radius of a particle, in particle spacings (Δx / 2). About 1.3 makes neighbours overlap into one surface.
Optionalresolution?: numberResolution of the offscreen passes relative to the drawing buffer (0.25…1).
OptionalropeLength?: numberRope spacing, metres.
Optionalropes?: numberRopy folds of the cooled skin (pāhoehoe), 0…1: ridges across the surface flow, where the skin has gone dark.
Optionalroughness?: numberCrust roughness: glassy pāhoehoe skin ~0.5, clinkery ʻaʻā ~0.9.
Optionalsmoothing?: numberDepth smoothing radius, in sphere radii: large for smooth pāhoehoe skin, small to keep ʻaʻā clinker lumpy.
Replaces the environment that lights the surface (null: the sky colour of lighting). Rebuilds the surface pass.
Lava on an MPMSolver whose
materialsincludelava: the thermal step once per frame after the solver's substeps (three compute passes: scatter mass, heat and the surface glow into a grid; per node, which also writes the MPMLava.field texture; gather, cool and conduct), and the drawing, a screen-space surface (as for fluids): the particles near the surface are splatted as spheres into a depth buffer, which a bilateral blur smooths into one surface; a full-screen pass over the scene reconstructs its normals and shades it as basalt (sun GGX, sky or environment light) with a blackbody glow from the field's skin temperature (from how long the surface has been open, lavaSkin; Wien-scaled, so skin below ~1000 K is black by day and dull red at night), cracks glowing at the melt's bulk temperature, and ropy folds across the surface flow where the skin is dark. Hide the solver's ownobject, add this one, and call MPMLava.render before rendering.Example