Cloth in Wind and Shallow Water Simulation
C#, Mass-Spring Cloth Sim, Shallow Water, Unity 3D, Realtime Simulation
This project contains two simulations, one is a real-time 3D Cloth Simulation that uses a Mass-Spring model to simulate realistic cloth as it drapes, collides with an object, and is affected by air drag and wind forces. The other simulation is a 2D Shallow Water simulation that is derived from the Navier-Stokes equations. It uses the results of the shallow water equations to drive a procedurally generated mesh that was then textured to look like water. The project was implemented from scratch by me for my Animation and Planning in Games class. A link to the write-up page I submitted for the assignment is linked below.
Project Details
- Category: Physical Simulation, Game Development, Graphics, 3D Simulation, Unity
- Date: Fall 2023
- Technologies: C#, Unity 3D, Cloth Simulation, Navier-Stokes Equations, 3D Rendering
How to Run
- 1.) Click on the Download the Project button
- 2.) Download the latest executable from the Github Releases Page
- 3.) Click the executable to play the game
- 4.) Check out the project's source code on Github
Highlighted Features
Mass-Spring Based Cloth
The Cloth simulation is based on a Mass-Spring formulation that models the cloth as a grid of vertices connected by springs that are tuned to give a slightly elastic cloth-like behavior. My cloth uses spring links in the cardinal directions between vertices. This simulation controls the movement of a procedural mesh that is updated as the simulation updates.
Collision and Air Drag
The cloth also models air drag on the surface of the cloth, changing the velocity of each part of the cloth, and collision with external objects like the ball in the scene depicted. The collision is implemented with a simple sphere intersection test against each vertex in the cloth mesh.
Wind Forces
A convenient consequence of modeling air drag is that it is simple to add an additional force to model wind moving the cloth. Using Unity's particle system I also created particles to visualize the direction and intensity of the wind.
Shallow Water Simulation
I also created a 2D shallow water simulation and integrated it into a 2D scene. This simulation uses a set of equations derived from the Navier-Stokes equations to simulate the heights that define the the surface of a body of shallow water. I used these results to generate a procedural mesh that I then textured to look like water.