Monocle

My personal 3D game engine using multiple rendering APIs.

Introduction

Monocle is my learning project when I want to experiment with new rendering algorithms or new APIs I don't know yet.

It is meant to be a modular and flexible framework for 3D applications, using a number of DLLs representing each of the engine's "modules" (Audio, Physics, Rendering, Window...).

It is built using CMake.

The project is open source and available on Github, although the code there isn't always up-to-date (or on secondary branches).

It went through multiple iterations and is in a constant "work in progress" state.

Thus, it is by no means usable to develop a real game at the moment...

But here is a list of the important modules it has, and their main features :

Core

This module is meant to be a central module for all others to include and use features of.

Among other things, it features :

  • an extensive, easy to use policy-based logging chain
  • Debugger and preprocessor utilities like a custom Assert macro, manual DebugBreak instruction, Builder pattern helper macro...
  • an implementation of the impossibly fast delegates
  • a "printf-like" string formatter, but that can work with std::string's out of the box for convenience ( inspired by Kenny Kerr )
  • a HashString implementation, enabling compile-time string hashing for better performance at runtime (when using them as hashmap keys for example)

Game Framework

A module meant to provide more game-centric data structures. Among others :

  • A Factory-based Resource Manager making it easy to collect and reuse data resources as they are read and processed by plug-n-play factories that you connect to the manager.
  • A generic FSM system that lets you program a custom finite state machine for your game.

Graphics

At its core, Monocle was always intended to be kind of a toy renderer sandbox, although a game engine is always much more than just that.

The graphics features I successfully implemented with Monocle :

  • Skyboxes
  • Mesh Instancing
  • Gamma correction and tone mapping operators (including use of the sRGB color space)
  • Shadow mapping (with PCF)
  • Normal mapping
  • Parallax mapping
  • Blending (transparency)
  • SSAO
  • Bloom (glow effect)
  • a basic PBR metalness/roughness-based material system (using a BRDF, and IBL with HDR maps)
  • a basic deferred renderer (as opposed to classic forward rendering)

Unfortunately it does not work on all backends and most of it has been done in OpenGL so far.

Slowly but surely adapting it to all backends ! (One day...)

So far, I programmed in Monocle abstractions of the following rendering backends :

  • OpenGL 4 (with the newer DSA calls)

  • DirectX 11 (in progress)

  • Vulkan (in progress)

But so far, the code never has been really cleaned up and is very messy. It works, but needs constant refactoring.

Hopefully I can stabilize it one day to a common RHI (Render Hardware Interface) that I like.

Shadow Mapping

Bloom (Glow)

PBR material testbed

Unit tests

Apart from the features of the engine, I try as much as I can to include unit tests for all easily testables features of the engine.

To do so, I use Catch2 as a testing framework.

A dedicated program built alongside the engine makes the user able to run the tests and easily add new ones if necessary.

TODO list

What I would like to tackle someday :

  • GUI and Editor app integration (with ImGui)
  • Physics integration (with either Bullet or PhysX)
  • Audio integration (with fmod)
  • Scripting (with the Lua scripting language)
  • The graphics side is obviously very wide, among the main ideas that I would like to try :
  • Planar reflections
  • Raytracing with the new Vulkan extensions
  • Compute shader-based cloth simulation
  • Compute shader-based particle systems
  • FXAA and other, fancier anti-aliasing algorithms
  • A fancier implementation of SSAO, like this implementation of HBAO by Nvidia
  • Signed distance field-based geometries and font rendering
  • Frustum culling and occlusion culling
  • Order-independent transparency
  • Spherical environment mapping
  • Terrain tessellation
  • Ocean water simulation
  • Volumetric fog and lighting

The list is endless... Got work for at least the next decade !