Skip to content

Skyepulse/FluidSimulatorGame

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GlassOverFlow

Game Picture

Overview

GlassOverFlow is a real-time 2D fluid simulation game developed by a team of three enthusiasts for the IGR205 course. The game is built from scratch using the OpenGL API. The technical report can be found here.

Description

The source code is divided into three parts: the engine, the physics solver, and the game itself.

The Engine

The Engine structure is inspired by an early version of the Hazel Game Engine. It features OpenGL class abstraction, a 2D renderer, and some primitives like squares, circles, and rendering properties. It also features a handling of user events, a camera system, and position transforms.

The Physics Solver

The solver implements the DFSPH method and features various kernels:

  • Density:

$$ \begin{align} W_{\text{poly6}}(r, h) &= \frac{315}{64\pi h^9} (h^2 - |r|^2)^3 \\ \nabla W_{\text{poly6}}(r, h) &= -\frac{945}{32\pi h^9}r(h^2 - |r|^2)^2 \\ \nabla^2 W_{\text{poly6}}(r, h) &= -\frac{945}{32\pi h^9}(h^2 - |r|^2)(3h^2 - 7|r|^2) \end{align} $$

  • Pressure: (be careful in 0)

$$ \begin{align} W_{\text{spiky}}(r, h) &= \frac{15}{\pi h^6}(h-|r|)^3 \\ \nabla W_{\text{spiky}}(r, h) &= -\frac{45}{\pi h^6}\frac{r}{|r|}(h-|r|)^2 \\ \nabla^2 W_{\text{spiky}}(r, h) &= -\frac{90}{\pi h^6}\frac{1}{|r|}(h-|r|)(h-2|r|) \end{align} $$

  • Viscosity:

$$ \begin{align} W_\text{vis}(r, h) &= \frac{15}{2\pi h^3}\left(-\frac{|r|^3}{2h^3}+\frac{|r|^2}{h^2}+\frac{h}{2|r|}-1\right) \\ \nabla W_\text{vis}(r, h) &= \frac{15}{2\pi h^3}r\left(-\frac{3|r|}{2h^3}+\frac{2}{h^2}-\frac{h}{2|r|^3}\right) \\ \nabla^2 W_\text{vis}(r, h) &= \frac{45}{\pi h^6}(h-|r|) \end{align} $$

It is capable to handle rigid structures that will interact with the fluid:

Rigid body

It is also capable of handling different fluids with different parameters:

Multiple fluids

The Game

The game features several levels to showcase the different features. The rendering of the different levels is done using several compute passes to get the 'pixel art' style. It uses some spatial hashing and computes the color of the pixels by using the SPH method idea.

Direct particle drawing Simple pixel art render pass Density computation for rendering Final rendering

From left to right and top to bottom: Rough particle rendering; Simple pixel art render pass; Per pixel density computation; Final rendering

Getting Started

To build the project, follow these steps:

mkdir build
cmake -B build
make -C build

To update submodules, run:

git submodule init
git submodule update

Acknowledgments

We would like to thank Prof. Kiwon Um for being our supervisor for this project.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published