Website powered by

Real-Time Kelp Simulation

Performance Stress

Physics Interaction

Buffer Layout for the simulation

Buffer Layout for the simulation

Shape3D struct layout

Shape3D struct layout

Real-Time Kelp Simulation

This project is a technical art challenge I created for myself because I wanted to learn about compute shaders and performing simulations on the GPU. It was done within the Unity engine.
The simulation is based on rope simulations using the Verlet algorithm. Collisions are also calculated on the GPU by evaluating a scene of SDF shapes representing the obstacles. Currently I support spheres, boxes and capsule shapes. For each simulated node, the scene is sampled once to calculate the distance to the nearest obstacle and 6 times when a collision is detected to determine the normal of the scene along which the colliding nodes need to be moved to solve the collision.
For processing and rendering, the kelp plants are split into chunks which are individually calculated and can be culled from rendering and simulating based on camera perspective. Most of the frame time comes from rendering the kelp leaves, which is why I tried to reduce overdraw as much as possible by increasing the mesh resolution for the leaves but in turn reduce the amount wasted fragment shader work.
Different kinds of kelp types can be generated by tweaking settings like stalk length, leaf length, leaf resting angle, stiffness, damping, color etc. per plant if needed.