Skip to content

rytis-p/offbeat

Repository files navigation

offbeat

Offbeat - Particle Effects System

A project mainly inspired by the Destiny particle system, reviewed and explained in detail in the SIGGRAPH 2017 Advances in Real-Time Rendering in Games course. That was not the only source of information though. List of all the resources/references can be found at the end of this README.

Game engine

The system was developed in the ngpe engine -- a custom game engine that my friend and I worked on. Thus, the proper commit history can be seen in the particle_system branch of the project. This repository, however, contains only the code of the particle system, meaning the code in this repository cannot be ran on its own -- it needs to be integrated into a game engine.

A basic API was created with the idea of making the particle system's integration into custom game engines easier. Currently it is in a usable state, but there definitely are places where it could be improved.

Features

  • Three-staged update: Emission, Motion, Appearance.
    • Emission - memory allocation (double buffer swap), particle spawn.
    • Motion - position and velocity update.
    • Appearance - color and size update.
  • Expressions that are used to represent and calculate various parameters for each stage.
    • Similar to AST expressions; currently has no recursion.
  • Can use either CPU or GPU for calculations.
    • GPU calculations were done using OpenGL compute shaders. Curently it means that GPU calculation is available only if OpenGL 4.3 or higher is supported.
  • Screen-space collision detection.
    • Uses depth and normal textures, thus is GPU-only.
  • Creates vertex + index buffers (similar to dear imgui) for particle rendering.
    • However, basically only relevant if CPU is used for the calculations.
  • Tried out the AZDO style OpenGL API -- GPU rendering implementation uses bindless textures.
    • Requires ARB_bindless_texture extension support.

Preview

Recordings (15-20 FPS GIFs) of various particle effects ran in the ngpe engine using the Offbeat particle system.

Live editing example:

Particle effect live editing example

Fire:

Fire

Smoke:

Smoke

Waterfall colliding with a 3D mesh:

Waterfall colliding with a 3D mesh

Rotating hourglass:

Hourglass

Sphere formation; particle color depends on the distance from camera:

Sphere changing color depending on distance from camera (purple - orange)")

Supernova-like explosion:

Supernova-like explosion

Flowy flames/ember:

Flowy flames

Million particles; color depends on the distance from camera:

Million particles (color changes depending on the distance from camera)

Other notes

There are still plenty of things that could be implemented, fixed and experimented with:

  • Sort particles by distance from camera (so that depth could be perceved properly).
  • Add an option to change the quad facing direction. Currently quads can only face the camera.
  • Change data layout to be SIMD friendly (to improve the performance on CPU).
  • Test the use of 3D meshes as particle emitters.
  • Add a possibility to draw 3D meshes at the particle positions, not only 2D quads.
  • Improved API.
  • Improved expression interpretation, added recursion.
  • Add expression baking into code/shaders for improved runtime performance.
  • More parameters (maybe with an API for easy addition of custom ones).
  • Try out cubemap depth/normal textures for (potentially) more accurate collision detection.
  • Research and experiment with particle lighting and shadows.
  • Vector fields.
  • Lots of cleanup!

Resources and references

About

Offbeat - Particle Effects System

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published