View on GitHub


Download this project as a .zip file Download this project as a tar.gz file

Unifided Real­time Particle Simulation Engine

University of Pennsylvania, CIS 565: GPU Programming and Architecture, Final Project


A real­time particle simulation engine implemented with CUDA. The engine includes basic particle sampling, rigid body and fluid (liquid) interaction simulations.

Demo video

Installation and run


  1. Preprocessing
    1. Load objects into scene {A}
    2. Convert them to particles with particle sampling {3}{4}
      • Depth peeling: for each object, two depth maps are generated which maps the shallowest depth and the deepest depth respectively. Particles are filled between these two maps
  2. Simulation (framework based on {1})
    1. Predict particle positions based on current velocity {1}
      • Simple position calculation s = v * t
    2. Adjust particle positions based on collision tests {1}
      • Collision happens for each pair of particles in the local context (voxel grid) where the two particles overlap
      • Adjustments are made for these collisions based on how deep these overlaps are
      • All adjustments are averaged to produce the final adjustment value for collision
    3. Retarget fluid particles {1}{5}{7}{8}{10}
      • Use incompressible density as the extra constraint for the fluid particle
      • Poly6 Smooth Kernel is used to calculate density at each point, Spiky Smooth Kernel is used for the gradients
      • Calculate lambda for each fluid particle
      • Apply incompressibility delta to predict positions
    4. Shape matching {1}{2}
      • Retarget particles for rigid bodies
      • Matching constraint is based on the fact that rigid bodies maintain their original shapes
      • Based on the deformation of particles of a rigid body, it is possible to find a transformation matrix that minimizes the difference between a transformed rigid body and its deformed particle states {1}
        • Calculation is based on polar decomposition {6}{7}
        • The general method for polar decomposition is used, where matrix square root is calculated first
      • Such transformation matrix is used to transform the rigid body such that its particles are retargeted to maintain the shape
    5. Update final prediction and find the corresponding velocity
      • Adjustments due to collision and retargeting are summed and averaged to produce the final adjustments
      • Original prediction value is adjusted based on the final values, and velocities are calculated
    6. Update particle information based on the final values
  3. Render {9}
    • Particle rendering is accomplished with OpenGL built-in features
    • Render each particle as a point sprite, using the fragment shader to compute the distance to the center and get normal from texture coordinates to draw a sphere like point without using any actual geometry model





Original Project Pitch


We are going to implement a real­time particle simulation engine. The engine would proposedly include particle sampling, rigid body and fluid (gas or liquid) interactions. Preferably the engine would also include particle meshing and shading via ray marching.


Real­time particle simulation is useful for a wide range of purposes, especially for fields that needs simulation demo for interactions among various bodies. For example, fluid simulation in games, aerodynamics visualization, and meteorology simulation.

Proposed Pipeline

Preprocessing → Simulation → Vertex Shader (→ Geometry Shader / Meshing → Primitive Assembly → Rasterization) → Fragment Shader

Milestone Plan