A logo showing a blue circle
Vlad-Stefan Harbuz
A screenshot of the peony game engine showing rocks and waves

Peony — a 3D Game Engine Written From Scratch in C++

I’ve been in love with the technology behind video games my entire life. As a kid, it was incomprehensible to me how anyone could build something like Pokémon Blue, let alone Half-Life 2. Despite that, I’d never built anything resembling a game engine myself.

That’s why in 2020, I decided to build my own 3D game engine from scratch in C++. My objective is to create something that, while being an indie engine, has many features that you would find in production game engines, such as nice lighting and shadows, basic physics and collision, water and atmospheric effects and so on.

Aside from furthering my own education, I have two aims in building Peony. First of all, I’d like to see how compelling of a player experience can be created with a relatively minimal amount of code and small budget. To this end, I am aiming to eventually build a game using this engine. Secondly, there is a dearth of practical game engine development resources on the internet, and I hope to make a small contribution to this community by publishing Peony’s source code.

After a little over a year of working on this engine, I’ve found the “from scratch” approach even more fun and rewarding than I could have hoped. Aside from a couple of dependencies such as GLFW and Freetype (and the soon-to-be-removed assimp), I’ve created all features of this engine myself, with no dependencies.

Here’s a quick summary of some of the features I’ve built so far:

PBR-compatible lighting
Albedo/normal/metallic/roughness/AO support
Cascading shadow maps
Dynamic lights
Procedural water
Forward and deferred rendering passes
Bloom, HDR, fog and other postprocessing effects
Procedural skybox
OBB-based collision detection
Custom GUI system
Development tools such as a game console
Skeletal animation
Custom entity system
Dynamic scene and asset loading from files
Custom scene and material file format
Shader hot-loading

Here are some features that I’m currently working on or planning to add soon, in order of descending priority:

Simple rigidbody physics
Cascading shadow maps
A better render queue system
Spatially-aware audio
Dialogue system using existing GUI
Better development tools such as scene editing

Peony’s source is published on SourceHut, under an education-only license (but contact me if you need to use it).

Skeletal animation and procedural water

I’m actively developing Peony, and I see it as a long-term project — I expect to be working on it for years to come. With time, I’ve realised that this is the kind of work that I find most rewarding, out of all of the things I could be working on.

Reading about how others have built their own game engines has been a huge help for me, so I’ve decided to start a series of articles about how I built various components of Peony. You can find links to these articles below — I hope you enjoy them!

Game Engine: How I Implemented Skeletal Animation
(coming soon?: how I built the water)
(coming soon?: how I built the GUI system)
(coming soon?: how I built the collision detection and physics)

A screenshot of a custom GUI in the peony game engine
Developing the collision detection system using help from the custom GUI

A screenshot of a scene illuminated by a sun with custom skybox and bloom
A sunset with a dynamic skybox and bloom