Disclaimer: This method for “The bunny and the spheres fell into the water” is not my creative idea. I was inspired by the article Solving General Shallow Wave Equations on Surfaces by Huamin Wang, Gavin Miller and Greg Turk. And all the contents below comes from my understanding of this paper. The sphere is also shown in the original article, while I use the method for stanford bunny.
| Bunny | Sphere | Both |
|---|---|---|
![]() | ![]() | ![]() |
The source cuda code can be found here, which you should noted is that the stb_image.h, stb_image_write.h and the stanford-bunny.obj must be placed at the same file level.
1. Top-View Shallow Water Method Overview
Primary target:
- Reproduce SPHERES-style coupling behavior (waves/splashes from floating objects).
- Keep identical mass but different volumes for spheres.
- Replace sphere geometry with a Stanford Bunny option.
- Render/export only top-view frames.
2. Connection to the Original GSWE Formulation
The paper writes (in continuous form):
and derives a second-order height update with implicit force terms, finally solved in matrix form:
In this implementation:
- Surface is planar regular grid (not curved mesh GSWE).
- Surface tension is disabled (), matching SPHERES table style.
- Coupling with rigid bodies is kept through per-cell constraints (an -like term).
3. State Variables (Planar Grid + Rigid Bodies)
3.1 Fluid grid
On a 2D grid :
- : water height
- : horizontal velocity
3.2 Rigid bodies
Each body stores:
- position
- velocity
- mass
- equivalent radius
- shape type: sphere or bunny
4. Time Integration
Each simulation step uses operator splitting:
- Update rigid bodies and build splash source.
- Build coupling maps from body-water contacts.
- Advect height (semi-Lagrangian).
- Build right-hand side with artificial viscosity term.
- Solve implicit height system by Jacobi iterations.
- Update velocity from height gradient + friction damping.
- Apply boundary damping.
5. Height Advection and RHS
5.1 Semi-Lagrangian advection
For cell center :
5.2 Prospective RHS (paper-style term + external source)
Code form:
where is splash/body forcing written into the height equation.
In current settings: .
6. Implicit Height Solve with Coupling
The solver uses a local nonlinear Jacobi update:
- : coupling weight map (constraint strength)
- : coupling target (object bottom height proxy)
Interpretation:
- is the implicit gravity stiffness.
- is the rigid/fluid coupling term (similar role to ).
7. Velocity Update and Friction
After solving :
Then apply paper-style depth-dependent friction damping:
with constant in code.
8. Rigid-Body Dynamics Used for SPHERES/BUNNY
8.1 Buoyancy proxy
A sphere-cap proxy is used for submerged volume:
For bunny, the cap estimate is scaled by volume ratio:
Buoyancy force:
8.2 Motion update
Vertical:
Horizontal (wave-slope-driven drift):
plus floor and wall collision response with damping/restitution.
9. Coupling Map Construction
For each body, for each covered cell:
- Compute an approximate object bottom elevation .
- Write:
For spheres:
For bunny:
- Transform world into bunny local coordinates.
- Sample precomputed profile from OBJ-derived map.
- Convert back to world height.
10. Splash Source Term
A local Gaussian source is added to height RHS:
Amplitude is driven by:
- downward impact speed
- lateral speed
- body size
This mimics the SPHERES visual effect (waves + splash rings) without introducing particles.


