frtru / GemParticles

Particle engine built on OpenGL used to produce various visual effects.
MIT License
34 stars 4 forks source link
cmake glew glfw3 glm gpgpu opengl particles rendering-engine shaders simd-instructions stb

GemParticles - Particles sandbox

This is a basic core-profile compliant OpenGL particle sandbox I used to create various visual effects and learning 3D concepts.

Updates and important mentions:

Description

The code itself is pretty simple and follows a templated data-oriented design. The ParticlesSystem class is type-bound to the particle structure. It also contains a renderer, dynamics and emitters and a particle pool. For each experiment that I want to make I create a new cmake library project that is built in the GemParticlesApp executable project and by passing the project name as an argument to the executable you can select which experiment you want to load.

Highlights

Here are some highlights that I managed to create with this system. Please note that, at the time of taking those screenshots, I had an i5-3570k CPU and Geforce GTX 660 GPU.

Lit particles or particles with 200 dynamic CPU lights 500000 CPU particles attracted toward a location with hot and cold colors and some rain... (1 million CPU particles)

Launching or installing the project

The project uses CMake files for portability and the Conan package manager to manage the dependencies so in order to launch the whole thing you have to

  1. Ensure you have both CMake (at least 3.10) and Conan installed. See https://cmake.org/install/ and https://docs.conan.io/en/latest/installation.html respectively for more details.
  2. mkdir build && cd build
  3. conan install .. (NOTE: it's possible you have to run conan profile new default --detect beforehand and set prefered compiler and architecture to 64 bits which is the architecture I've been using)
  4. Generate the projects using CMake (cmake .. -G "MY PREFERED BUILD TOOL")
  5. Build using the generated files
  6. Launch by passing the project name to the executable (e.g. ./GemparticlesApp.exe lit_particles)

External libraries

I'm using various external libraries in this project which are listed in the file conanfile.txt

Utilities

I pretty much built this from scratch looking up efficient design patterns and tutorials. So you'll find a handful of utilities that I built to help me create stuff more easily. Most of them are named as modules.

And last but not least, some wrapper utilities I built around ImGui examples. This includes

Extending the project

If you want to create your own project using this "engine" or the project structure you can

  1. Add the project to the list of sub-directories in projects cmakelists.txt file
  2. Register the project in the project dictionary (if you use the REGISTER_STD_PROJECT you'll have to define the init, run and terminate functions in your project)
  3. Add your own cmakelists.txt and sub-directory in the projects/ folder
  4. Refer to the other projects' blueprints or *_project.cc files
  5. Run the GemParticlesApp (main) executable with the name of your project passed as an argument.