Lava Particle Field
- group .........
- 3D and WebGL scenes
- source ........
- https://ui.aryank.space/components/lava-particle-field
- markdown ......
- /lab/lava-particle-field.md
- human .........
- /lab/lava-particle-field
── WHAT_IT_IS ────────────────────────────────────────────────────────────────────────────────
A GPU particle solver where the particles live in the texture itself. Buffer A stores one particle per texel as position in RG and velocity in BA, and advances it by sampling its eight neighbours and adopting whichever one is closer under a wrapped distance, which is how particles are handed between texels without any CPU-side list. Buffer B accumulates density and pressure from that field, and its gradient is fed back into A on the next frame, so the two ping-pong: motion writes density, density pushes motion. The image pass reads out vorticity, the curl of the velocity field, and maps it straight to the lava colour, so what you see is rotation rather than heat. Four double-buffered FloatType targets at twice display resolution; press and drag to inject a gaussian of velocity.
── BEHAVIOUR ────────────────────────────────────────────────────────────────────────────────
* The particle list is the texture
One particle per texel, position in RG and velocity in BA. Advection happens by each texel checking its eight neighbours and adopting the closest under a wrapped distance, so particles migrate across texels with no CPU-side array and no draw call per particle.
* Motion and density feed each other
A writes positions, B integrates them into a density and pressure field, and A reads B's gradient next frame. Neither is the source of truth; the look comes from the loop between them.
* The colour is vorticity, not heat
The image pass computes the curl of the velocity field and maps its magnitude to the orange. Bright regions are where the fluid is rotating fastest, which is why the filaments look like they are being wrung out.