Manual

Architecture & Internals

How the engine is put together — modules, the life of a frame, diagnostics, and building it yourself.

The big picture

Module Architecture

Horizon Engine is built from cleanly separated modules. Each layer talks to the ones below through narrow interfaces, so a piece can be extended or replaced without touching the rest.

HE_Editor · HE_Game The editor application · the standalone game runtime
HE_Scene · HE_Tools ECS world, systems, serialization · project management, importers, packer
HE_Rendering Render device abstraction + Metal / OpenGL / D3D11 / D3D12 / Vulkan backends
HE_Core App loop, content manager, hpak, script runtimes, HorizonCode, UI widgets, diagnostics
ModuleResponsibility
HE_Core Application loop, logging, math, config, the content manager and hpak, the Lua/Python runtimes, the HorizonCode runtime and compiler, UI widget model, input assets, diagnostics.
HE_Rendering The render device interface, the render-world extraction, shared shaders and the five graphics backends.
HE_Scene Entities, components, all gameplay systems (physics, animation, navigation, particles, audio, widgets at runtime), scene serialisation, the engine API registry.
HE_Tools Project management, asset importers, the export pipeline and CLI tools.
HE_Editor Panels, asset editor tabs, gizmos and tooling on top of the runtime.
HE_Game The standalone runtime an exported game ships with.

Entities are backed by an ECS registry; gameplay logic reaches the engine through the HE::api registry — one machine-readable table of engine functions that simultaneously powers the Lua and Python bindings, HorizonCode's Engine Call node and the HorizonCode→C++ code generator. Adding an engine function is one registry row; every frontend gets it at once.

16 milliseconds

Anatomy of a Frame

  1. Input & events

    SDL events pump; the input snapshot updates; input actions fire into player classes and widgets.

  2. Simulation

    Physics steps at a fixed timestep (accumulator), collision events dispatch to scripts, script onUpdate runs, HorizonCode latent flows resume, widgets tick. The always-on systems — animation, navigation, particles, weather — tick in editor and play mode alike.

  3. Streaming

    Background asset loads complete and register on the main thread under a per-frame budget.

  4. Extract

    The scene is flattened into a backend-agnostic RenderWorld: frustum culling, LOD selection, instancing batches, shadow cascade fitting, environment state.

  5. Render & present

    The active backend draws the frame pipeline — shadow maps, sky and scene in HDR, post-processing, UI — and presents.

Content

Asset Infrastructure

Every asset is a .hasset file: a small chunked container whose chunks carry metadata, source data and cooked payloads (mesh vertex buffers, precompiled shaders, texture cook data, script language, graph JSON …). Assets are identified by UUID — references never break when files move.

  • In the editor, a disk registry indexes loose assets by reading only their headers, so even huge projects resolve references without preloading.
  • In a packaged game, assets live in the hpak archive and stream on demand, following the reference graph.
  • Asynchronous loading runs on worker threads with main-thread registration under a frame budget.

When things go wrong

Diagnostics

  • Profiler — the in-engine profiler measures per-pass GPU time and nested CPU scopes with zero cost while idle; F9 captures a benchmark to JSON in the dumps/ folder, in the editor and in exported games alike. UI: View ▸ Performance Profiler.
  • LoggingHorizonEngine.log next to the executable, truncated per launch.
  • Crash handler — on macOS/Linux, fatal signals write a he_crash_*.crash report (signal + stack trace) to the system temp directory before the OS core dump.
  • Robust config — the editor's config.json is parsed defensively (a corrupt file resets instead of crash-looping) and written atomically.
  • Debug drawing — scripts and graphs can draw lines, spheres and boxes in the viewport via the debug API group.

DIY

Building from Source

The engine builds with CMake (presets for Windows/MSVC+Ninja, macOS and Linux with clang ship in the repository). Dependencies — SDL3, glm, Lua 5.4, Jolt Physics, Recast/Detour, lz4/zstd, nlohmann-json, Dear ImGui — are fetched or found automatically; embedded CPython is optional and enables the Python backend.

terminal
# Configure a release build
cmake -B build -DCMAKE_BUILD_TYPE=Release

# Compile the engine and editor
cmake --build build --config Release

Requirements: a C++20 compiler and CMake 3.20 or newer. Vulkan builds also need the Vulkan SDK on your PATH.

Main targets: HorizonEditor (the editor), HorizonGame (the game runtime), the module libraries, and tools like the shader compiler and the pak packer. Releases carry sky-themed codenames — the current line is Sunrise.