Engine design document
This is a rough sketch of the final engine. Treat this as some type of "this is how a 1.0 will look". The current iteration of the engine does not match this, but features will be indicated with symbols: βπ β.
Entries marked with β are mostly or fully complete (are used widely throughout the engine and plugins), β means not started yet, and π means this area is a work in progress. These markers will be updated periodically.
Overall architectureβ
There are generally 3 layers:
- Application β - This is game/application logic, leveraging the engine's subsystems.
- Application framework π - Takes care of launching all the engine's subsystems needed for a particular application type. There should be a couple templates to minimise bloat:
- CLI tool - Uses a few basic subsystems (logging, plugin system, virtual filesystem, asset system).
- Application - Utilises all engine subsystems (e.g. rendering and audio on top of prior ones) to run games or desktop GUI tools.
- Game - Like Application, but it launches a moddable game, so it initialises a little differently.
- Launcher β - A concrete executable that launches the application framework with one of the aforementioned templates.
Modules are organised into a few categories:
- Core modules
- Addon modules
- System modules
- Plugins
Core librariesβ
Most of these libraries are designed to be engine-agnostic, meaning you can use these outside of Elegy.
- Elegy.Common - Utility library β
- Elegy.Framework - Engine core, handles engine configuration etc. π
- CLI tool template β
- Application template β
- Game template β
- Elegy.ECS - Eventful entity component system library π
- Elegy.Scripting - C# scripting library β
- Elegy.RenderBackend - Veldrid/Vulkan utilities β
Addon librariesβ
These are optional libraries you can use within an Elegy application. Unlike plugins that are loaded dynamically at runtime, addons are used by developers at design time.
- Elegy.Avalonia π
- Integration with Avalonia for building desktop GUI apps β
- In-game Avalonia UI π
- Elegy.VirtualReality β
- VR support powered by OpenXR
- Full body tracking support via SteamVR
System modulesβ
These libraries implement engine subsystems, but are mostly independent (β) of each other.
- Elegy.AssetSystem β
- Quake 3-style materials β
- Data-driven shaders β
- Model asset loading (plugin-based) β
- Texture asset loading (plugin-based) β
- Level loading (plugin-based) β
- Elegy.AudioSystem (plugin-based) β
- Sound sources, listener
- Sound FX
- Geometric acoustics
- Elegy.CommandSystem π
- Note: currently called Elegy.ConsoleSystem
- Console frontends β
- External developer console π
- Console commands β
- CVars β
- Elegy.FileSystem
- Mounting game/mod paths β
- Mounting addon paths π
- Elegy.Input
- Keyboard, mouse input β
- Gamepad & joysticks π
- Elegy.LogSystem
- Note: currently part of Elegy.ConsoleSystem
- Logging, warnings, errors β
- Tagged logging β
- File logger β
- Elegy.NetworkSystem β
- Utility layer on top of ENet or similar
- Elegy.PlatformSystem
- Windowing (injected) β
- Fundamental engine configuration, e.g. headless mode β
- Elegy.PluginSystem
- Flexible plugin system β
- Plugin dependencies π
- Plugin reloading π
- Plugin versioning π
- Elegy.RenderSystem π
- Slang-based shader system π
- Renderable objects:
- Mesh entities β
- Batches β
- Volumes β
- Lights β
- Views & rendering into windows β
- Debug rendering π
- Render styles (plugin-based) π
- Style99 - Lightmapped 90s style shading π
- StyleModern - Physically-based shading, POM, reflections etc. β
Legend:
- Plugin-based: implemented in a plugin, engine just provides API
- Injected: implemented externally (e.g. in a launcher), engine just sees API
Game SDKβ
- AI β
- Goal-oriented action planning
- Use Recast/DotRecast
- Animation β
- Animation playback and management
- Animation blending
- Animation channels
- Inverse kinematics
- Client π
- Client controllers (handle input and interaction with the game world) β
- Keybind system β
- View bobbing and viewport management β
- Entity system β
- Reactive ECS β
- Source-style IO β
- Scripting β
- Game sessions β
- Menu state, loading state, playing state, paused state etc. β
- Linking a client into the game β
- Gamemodes β
- Campaign, deathmatch, team deathmatch, co-op etc.
- Netcode π
- Mainly intended for LAN co-op
- Quake-style client-server with prediction and rollback β
- Singleplayer bridge β
- Particles β
- Physics π
- Rigid bodies π
- Constraints β
- Save-load system β
- UI β
- ImGui for quick'n'easy stuff
- Custom game UI system for everything else
Toolsβ
Every engine needs good tooling. Elegy would come with these:
- Elegy.Librarian - Plugin-based game data editor. Used to edit e.g. vehicle configs, NPC profiles, difficulty settings and so on. Editing tools provided by plugins. β
- Elegy.MagicWand - Manages projects and Elegy Engine installations. β
- Elegy.MapCompiler - EMC for short, it compiles levels. π
- Utilises the plugin system to bake game-specific or render-style-specific data. β
- Usable with TrenchBroom. β
- Elegy.ModelEditor - Based on Elegy.Librarian, a tool for importing models, fixing them up and editing game-specific metadata. Or just viewing them. β
- Elegy.ShaderTool - Compiles Slang shaders and generates extra data for the render system. π
A custom map editor may be a possibility, but that would be way after v1.0.
Workflow and featuresβ
Overall:β
- Quake-style workflow.
- Thereβs an engine executable in the root folder, accompanied by game folders and an engine folder.
- The engine folder contains base engine assets, e.g. a βmissing modelβ model, a βmissing textureβ texture and whatnot.
- Each game/mod folder contains a configuration file that describes it as well as its plugins and dependencies.
Mapping:β
- Youβd use an external level editor like TrenchBroom, J.A.C.K. or NetRadiant-custom.
- Youβd also use a map compiler, either as part of your level editorβs compile config, or through a console command.
Modelling:β
- Youβd use a model editor like Blender.
- Export GLTF for basic props, import via custom tool for extra attributes for complex models.
Texturing, sound design and other trivial asset types:β
- Quite simply place your PNGs/WAVs/FLACs into a textures/sounds folder, itβs just there.
UI:β
- Declarative C# UI files sitting in a directory.
Scripting:β
- Naked C# scripts, S&box-style.
- Level scripts
- UI scripts
- NPC scripts?
- Weapon scripts?
- Vehicle scripts?