Work::Dev


Personal Projects

#include <dev_work>
namespace Projects::Personal{ 
// Info: These are personal projects, largely centered on simulation and ML.

ML-XR-Fluids — Real Time Machine Learning Accelerated Fluid Engine (2023 – 2024)

Languages: C++, CUDA, Python, GLSL

Key Libraries: PyTorch, LibTorch, OpenGL

This project started as a fork of my MSc Dissertation Project, with the aim of supporting larger-scale fluid simulations while exploring additional modules for neural–accelerated simulation and rendering. The core library is a C++/CUDA simulation framework that supports a mix of standard and differentiable operations, running entirely on the GPU for both simulation, inference, and rendering.

In early 2024, and while interviewing at Apple, I started moving this to utilise a sparse grid-based data structure and also started developing an XR Runtime for running my simulations directly via an HMD interface via OpenXR.

This project also allows me to generate fluid simulations, fully in the GPU, inside a ML training loop, to experiment with new synthetic data, and ML approaches. It can also generate much higher-resolution simulations and allow prototyping new modules into the framework.

I’m not sure why I like taking photographs of my screen as well as screencaps!?

Verlet Cloth Mesh – An Unreal Engine-Based Cloth Solver Plugin (2020 – 2021)

Languages : C++, HLSL

Libraries: UE4 C++ API.

Because everyone needs a volume-preserving Stanford Bunny in their life 🙂

This started out as a weekend project to write a small cloth solver plugin for Unreal Engine, utilising Position Based Dynamics (PBD). It was my first attempt to write an Unreal Engine plugin. The aim is to simulate both in-game and offline cloth for set dressing in the editor, as well as for runtime user interaction.

Unlike conventional PBD, it also utilises the velocity-less Verlet integration method, based on work from Thomas Jakobsen of IO Interactive. The plugin supports the simulation of planar, parametric cloth patches (drapes, curtains, etc.) and 3D triangle meshes, with core constraints derived from the topology/edge-connectivity graph. While utilising the velocity-less Verlet scheme has advantages: being second–order in time and avoiding the need to store velocities per particle, it also has downsides occurring from a lack of explicit velocities. So traditional, first-order, Semi-Implicit Euler is also provided.

The plugin utilises the Procedural Mesh Component within Unreal Engine’s source to allow efficient updates and rendering of mesh data. I focused some time optimising it and implementing various features, including:

  • World Collisions – Both internal or via underlying Physx/Chaos in the engine.
  • Self-Collisions – With spatial acceleration using Uniform or Spatial Hash Grid
  • Auto-Sleep – Save compute when cloth ${\Delta x \over \Delta t}$ is low, cloth goes to sleep.
  • Volume Pressure – Yeah, this is implemented as a force in a PBD solver; odd choice, I know!
  • Runtime or Editor – Real-Time Cloth vs Level Editing Generation supports both, including mesh export.
  • GPU Compute – I also began working on a GPU version in 2021 before starting University, it’s not lost on me that I still need to finish this, and rewrite it to utilise RDG in Unreal Engine 5 🙂

The project is fully open-source under MIT License and has multiple forks. You can check it out on GitHub:

Note – GPU Constraint Solver is not currently pushed to this remote. But I did record the initial implementation.

Stable Fluids GLCPU-based fluid simulation framework with OpenGL Volume Rendering –(2018-2020)

Languages: C++, GLSL Key Libraries: OpenGL, GLFW, OpenMP

This project is based on the work of Jos Stam and his seminal ‘Stable Fluids’ paper. This project is where my interest in linear solvers for approximating the ‘Poisson Pressure’ equation began! I use this framework as a reference for any fluid-related project I work on, as I find it handy to have a CPU-based framework I can use for ground truthing when implementing higher-performance code in other paradigms (SIMT), which are harder to debug.
Some key features :

  • 2D and 3D Modes – with 3D Volume Rendering (OpenGL Ray Marching)
  • Multiple Advection Approaches – Semi-Lagrangian, Macormack, BFECC
  • Pressure/Poisson Equation Solvers – Jacobi, Gauss-Seidel, SOR
  • SSE & AVX SIMD Acceleration – Trilinear Interpolation and Vector Calculus operations on x64.

Academic Projects

#include <dev_work>
// Info: These are projects I worked on during my MSc at University of Leeds, including my dissertation project!
namespace Projects::Academic{ 

MSc Dissertation Project A Deep Learning Accelerated Interactive Fluid Simulation
Framework
– (2022)

Languages: C++, CUDA, Python, MATLAB, GLSL

Key Libraries: PyTorch, LibTorch, OpenGL

Visualisation of small $64^3$ pressure model vs. Ground Truth

My MSc dissertation at the University of Leeds in late 2022, involved a self-proposed, multi-stage project aiming to explore the acceleration of real-time fluid simulation using deep learning. This work focused specifically on neural acceleration of the pressure solve stage of the Chroin-based ‘Projection Method’, which involves calculating the unknown pressure field, given the current intermediate velocity field utisling an ‘Operator Splitting’ approach to solve the discretised equations (Inviscid Euler Equation).

Typically, the pressure field is defined as a Poisson equation, which is derived as a product of Helmholtz-Hodge Decomposition, resulting in a large and sparse linear system. Normally, this requires running an expensive numerical linear solver to approximate it. However, challenges for real-time simulation exist due to the reliance on convergence and minimal residual error to solve for an accurate pressure field and thus maintain incompressibility when used to project the intermediate velocity onto its divergent free subspace.

Enhanced Volumetric Rendering with Pseduo-Combustion
Example of High Resolution Training Data

My project takes inspiration from and cites [Tompson et al. 2017] with the aim to replace conventional numerical linear solvers, with a fully convolutional neural network, allowing for a with a fixed cost inference step that can utilise modern GPU architectures with Tensor Cores, freeing up the Graphics and Compute pipelines. This could allow for high quality, high-performance interactive fluid simulations within games and XR experiences, where performance and thermal constraints of hardware were previously bounded.

The project was a large engineering undertaking for a single person (during recovery from a broken jaw!) and involved several sub-projects:

  • Fluid Simulation Framework – I wrote a custom simulation framework in C++ / CUDA from scratch, based on solving a reduced set of the Navier-Stokes equations (Inviscid Euler) in real-time. This was used both to generate training data and perform the rest of the simulation operations at runtime as a small and modular library. This was optimised to ensure good usage of GPU resources, avoiding costly host-device transfers.
  • Training Data Generation – A client application that calls the base fluid simulation framework library, to generate many permutations of the parameter space, generating thousands of simulations to form the training dataset. This data was used for training the neural network.
  • Neural Network Training – The fully convolutional network architecture was built and trained within PyTorch using Python. Both quantitative and qualitative testing were used to validate and examine the resulting models, adjust hyperparameters and make architectural and training logic changes.
  • Tech Demo Application – The trained model was utilised in a small program to test in an applied setting, where a gaseous smoke simulation could be interacted with by a user controller input. My fluid framework was utilised for simulation and the trained pressure FCN model was used for inference by exposing it to this C++ application through LibTorch (PyTorch’s C++ frontend). This was compared with common numerical linear solvers such as Red-Black Gauss-Seidel. Finally, a basic volumetric renderer was written using OpenGL utilising ray marching to visualise the resulting fluid data.

Of course, because all data is synthetic, data generation is limited purely by your computational resources and tolerance for excess GPU heat! The entire project was trained and run on a single RTX 3090 (GA102).

Small demo video I made of the Data Generation app I wrote (I didn’t have time to wrap in a Python API!)

June 2023: I’m pleased to announce that this dissertation resulted in a distinction grade. I’m also thrilled that I managed to get a print copy of my dissertation.

The report can be found online here

COMP5530M Game Engine — Rendering/Material System – 2022.

Languages: C/C++, GLSL

Key Libraries: OpenGL, GLFW, DearImGUI

As part of a group module at the University of Leeds during my MSc, I worked on a group project in which we wrote a small ‘game engine’ from scratch. I built the rendering and material system and also led the team for the first half of the project. This involved adopting an Agile-like approach to the project’s software engineering process.

I also implemented the base application and systems logic. The rendering subsystem implemented an abstracted interface to the underlying graphics API, which was OpenGL 4.5. Due to time limitations, the material system is non-PBR (hello 2005!), but still allows for creating variations in materials that look physically plausible.

Class Presentation Video
  • Abstraction of Graphics API Backend – Implements high-level abstractions for common primitives and constructs defined by modern graphics APIs (Textures, Framebuffers, Meshes, Lights). The engine specifically targets OpenGL 4.5, but other API back-ends could be added by implementing these abstractions.
  • Auto Mesh Indexing System – Allows meshes with multiple vertex attributes to be automatically indexed when loaded into the engine, only keeping unique vertices. This was implemented using a hashing-based approach and allowed large memory savings when dealing with meshes with lots of shared attributes, such as the terrain subsystem.
  • Material System – Users can load texture maps, define parameters to create various perturbations of material properties, this is accessible by a GUI panel interfacing the engine editor application with editable parameters.
  • Hot-Reloading of Shaders – Re-compile shaders using static code paths to prevent dynamic branching on the GPU when material parameters change.

The project is hosted on GitLab by a teammate.


COMP5823M Animation & Simulation Projects – 2022

Languages: C/C++, GLSL

Key Libraries: OpenGL, GLFW, Dearimgui

For coursework during COMP5823M at the University of Leeds in 2021, I produced three projects related to ‘Animation & Simulation’. Given my prior experience, these are far from my most complex work, but they turned out to be quite nice standalone applications, so I put them online.

Tiny mocap data / FK viewer
Tiny cloth solver.
Tiny 2D SPH Solver.
Each project has a detailed readme file, including details of base paper/s, algorithms used and implementation.

Talks / Presentations

#include <dev_work>
// [..]
namespace Projects::Talks{ 
// Info: These include presentations I gave at University regarding my research project, Coding videos, etc.  

Presentation @ University of Leeds“A Deep Learning Accelerated Fluid
Simulation Framework for Interactive Applications”
– May 2022

(Opens a PDF from Google Drive in a new tab)

Before beginning my MSc dissertation at the University of Leeds, I gave a presentation on the scope and nature of the work. The talk highlights the challenges of accelerating real-time fluids for games, with a brief refresher on the core equations, the approximations that can be made, and how I convinced the department to let me proceed with this project, given that in the UK, our MSc projects are normally quite tightly bound.


Unreal Engine – GPU Compute Coding Series“Implementing GPU Compute-Based – Self Collision Detection in Unreal Engine 4” – June 2021

(Redirects to YouTube in a new tab)

During my break between my last contract and starting University in 2021, I was noodling on my UE Cloth Solver project, and began migrating the code to run on the GPU using Compute.

Back in the void between Unreal Engine 4 and production Unreal Engine 5, finding documentation on properly utilising Global Shaders, for Compute, within a C++ plugin was a little tricky. During my ‘flow’, I decided to document part of the process in a, well… very casual series of videos I recently found and uploaded into a small playlist!

I don’t think I’m going to be live-stream coding anytime soon, let’s put it that way 😀