Project Proposal - Alexander-Hjelm/metaballs-glfw GitHub Wiki

Metaballs-GLFW

Objective

Using low-level graphics programming, we aim to program and render a dynamic fluid using the metaballs technique, where the fluid particles will collide with each other and the environment. The final result will look like the Nvidia FleX fluid demo. A reference video can be found here: https://www.youtube.com/watch?v=2gp7-ejkwBQ. While the FleX engine can simulate 500'000 particles in real time, we will restrict ourselves to making a realtime simulation with the order of 1000 particles.

Grading goal

For this project we are looking to obtain an A in the course. We would like to continue on the graphics programming tracks with our master's projects, and we would much appreciate it if the examinator would asses our project closer to the criteria of a master's project.

Tools

We will use GLFW, GLSL and the Bullet physics library for creating the simulation. GLFW is a utility library for working with OpenGL, and we will use it as an interface between the high-level program logic and the low-level rendering. Mainly we will use GLFW to manage the OpenGL context and make GPU drawcalls. GLSL is the OpenGL shading language that gives developers control over the rendering pipeline. We will use GLSL to write our shader programs. Bullet is a free and open source physics library, and we will use it for rigid body dynamics and collision detection between primmitive 3D shapes.

Initial feasibility study

So far, we have begun development to examine how feasible our project idea is. In order to render simple primitives, we have created a program that renders triangles with glfw's built-in library for pixel rasterization. It also sets up the View-Model-Projection matrix and renders a primitive cube in perspective 3D, using a triangle buffer.

Using this base program, we have built a voxel shader that renders a cube field from a defined isosurface (we began using a spherical surface model for simplicity). After we derived the mathematical definition of the potential field of multiple metaballs, we made a test implementation of the marching cubes algorithm to construct the fluid mesh. Using these components, we have successfully rendered multiple metaballs with interacting potential fields.

Here is a screenshot of what the current program looks like with only two metaballs whose fields are partially overlapping:

alt text

Remaining steps

To achieve the same results as in the FleX demo, we would like to complete the following steps:

  1. We must optimize the marching cubes implementation to support the order of 1000 metaballs in one real-time scene. The existing marching cubes implementation is very much hard-coded and not necessarily optimized that many particles.
  2. We should begin with animating the individual particles (using random motion to begin with).
  3. We will implement a basic Phong illumination model on the fluid mesh.
  4. We will integrate Bullet, an existing physics library, for collision detection and responding, where the particles are treated as sphere colliders.
  5. We will implement a simple gravity model that affects all particles universally.
  6. We will model the environment using cubes, which means that sphere-cube collision must be implemented.
  7. We will include a controllable primitive shape in the scene that can be used by the user to manipulate the fluid.

Additionally, if there is time we would like to implement a basic model for particle adhesiveness, meaning the particles may stick to the scene surfaces and/or other particles (surface adhesion). We would also like to model the viscosity of the fluid and expose this as a settable parameter.

References

Hello Triangle

Primitive Rendering

Marching Cubes

Metaballs rendering

Phong illumination model

Bullet physics library