What is Horizon Engine?

Horizon is a centralized and modular game engine. It mainly targets desktop games via DirectX 12. The overall flow is built on services that live within the core application’s lifetime scope. Multi-threading is split into frame-based and instant tasks, handled by the JobSystem and the WorkSystem. The JobSystem focuses on frame-based tasks such as the RenderGraph, ECS and game modules. The WorkSystem, on the other hand, handles tasks such as the AssetStreamer’s load and unload, asset importer pipelines, etc. The game world runs on a sparse-set entity component system, resolved through a multi-threaded system graph. Meanwhile, the scene is rendered through a multi-threaded RenderGraph.

ECS Component Showcase

Sparse-set ECS

For those who don’t know, a sparse-set entity component system is an approach where your scene holds multiple component arrays. It runs best when you query a single component, but it’s still fast because we still get the benefits of cache locality.

Note: I can switch to Archetype ECS if this approach becomes a bottleneck for me.

Please check out this amazing person’s blog.
If you want to learn more about archetype ECS, check this out as well.

Reflectable Component
Runtime Reflection Usage

Runtime Reflection System

Like every automated engine, Horizon also has a runtime reflection system. It facilitates internal communication within the engine and the management of its features, while also effectively preventing code designs on the editor side from becoming bloated. Its most significant feature is that it automates many registration processes. Unlike commercial engines, this approach does not involve modifying the files in which the code is written.

Clustered Light Stress Test
Bistro Exterior
Volumetric Fog

System & Render Graphs

Horizon runs both the game world and the frame through dependency graphs, and both of them find their nodes by themselves via runtime reflection. Each system declares the components it reads or writes, and the SystemGraph uses this to run the independent systems in parallel on the JobSystem. The RenderGraph does the same for render passes. It sorts them, creates their resources and places the barriers automatically.

If you want to learn more about graph theory, check this link.

Jolt Collider Debug Draw

Jolt Integration

I chose Jolt because it’s a very successful physics engine, it’s very verbose about what it does, and integrating and using it is extremely easy in a system that is split into modules like mine. I also believe that, together with my ECS, it will deliver top-level performance in physics-heavy scenes.

Profiler with ImPlot
Light Stress Benchmark on Debug

CPU and GPU Profiler

Profiler::Mark measures CPU scopes with the OS’s high-resolution timer, while GPU timings come from DX12 timestamp queries and are submitted through Profiler::SubmitGpu. The reason for using the OS-based timer is entirely about getting a sharp and accurate answer.

Note: There are 8192 point lights in the benchmark scene.

Under the Hood

Most of Horizon’s core is hand-written instead of taken from a library. Below are the modern systems I built myself, and the passes a frame goes through.

Hand-written Core

  • Mesh Asset Streamer
  • Texture Asset Streamer
  • Job (Frame-based) & Work (Instant) Systems with Work Stealing
  • Sparse-set ECS
  • Render Graph
  • Rendering Hardware Interface (Default D3D12)
  • Platform Abstraction Layer
  • Runtime Reflection System

Render Flow

  1. Pre-depth Pass
  2. Hierarchical Z Pass
  3. Cluster Build Pass
  4. Cluster Pass
  5. Cascaded PCF Shadow Pass
  6. GBuffer Pass
  7. Lighting Pass
  8. Procedural Sky Pass
  9. Volumetrics Pass
  10. Tonemap Pass
  11. FXAA Pass
Currently working on: Skinned Mesh, Animations, StateMachines