Game Development

AAA engine architecture

Unreal Engine 5 contains 20 million lines of code. Unity around 6 million. Behind every frame of Horizon Forbidden West are years of engineering work on the rendering pipeline, threading systems, memory allocators, and tools. Understanding engine architecture means understanding why some optimizations work, why others do not, and how to solve problems at scale.

  • **Epic Games** opened Unreal Engine 5 source to every developer. Studying real production C++ for a AAA engine is free on GitHub
  • **id Software id Tech 7** (DOOM Eternal) uses a job-based architecture: each frame breaks into thousands of small tasks across 8+ CPU cores, holding a locked 60 fps frame time
  • **Insomniac Games Spider-Man 2** uses Nanite-like virtual geometry for NYC: 10M+ unique building meshes rendered through a clustered geometry pipeline
  • **CD Projekt Red REDengine** for Cyberpunk 2077 supports ray tracing with dynamic GI: the shadow and lighting system was rewritten from scratch for RT hardware

Rendering pipeline in AAA

**A modern AAA rendering pipeline** is more than 'draw the meshes'. Unreal Engine 5 uses Deferred Shading: the first pass collects a G-Buffer (albedo, normals, roughness, metallic into separate render targets) and the second pass computes lighting for all sources at once. That allows thousands of lights without a performance cliff.

Nanite (Unreal Engine 5) is virtual geometry. Source meshes hold billions of polygons; Nanite dynamically streams only the triangle clusters needed, adapting to on-screen size. Result: artists can use raw ZBrush sculpts without retopo. The Matrix Awakens demo: 37B polygons running in real time on a PS5.

Deferred Shading renders 1000+ light sources efficiently. What is the main cost?

Multithreading in a game engine

**A game engine cannot be single-threaded on an 8-core CPU.** Typical multithreaded architecture: Main Thread (logic, physics API), Render Thread (preparing render commands), and GPU Thread (executing on the GPU). Unreal Engine adds a Task Graph: a pool of worker threads for parallel execution of animation, AI, physics simulation, and audio mixing.

Data races are the main hazard of multithreaded engines. Unity Job System addresses them through NativeContainer with [ReadOnly]/[WriteOnly] attributes. The compiler verifies absence of race conditions. Unreal uses GameThread check macros: check(IsInGameThread()) in functions that cannot be called from worker threads. A violation crashes a debug build.

An AI system reads all enemy positions at one moment for pathfinding. If this happens on a worker thread while the main thread moves enemies, you have a data race. How to fix?

ECS at AAA scale

**Entity Component System (ECS)** is becoming the standard in AAA games with many homogeneous objects. Unity DOTS (Data-Oriented Technology Stack) and Unreal Mass Entity are production implementations. The key advantage is cache efficiency: components of the same type live in contiguous arrays, and the CPU processes them via SIMD with no cache misses.

Architectural compromise: ECS shines for many homogeneous objects (bullets, particles, RTS minions). Classic OOP with MonoBehaviour suits unique objects with complex behavior (main hero, bosses). Fortnite uses Mass Entity for thousands of NPCs on the map while keeping Blueprint for unique characters.

ECS in Unity DOTS stores all components of a type in contiguous arrays (Archetype Chunks). Why is that faster than classic GameObject + MonoBehaviour?

Engine development tools

**Tools are a productivity multiplier for the team.** A good level editor lets a designer do in an hour what a programmer needs a week for. Unreal Engine Blueprint Visual Scripting is not 'simplified programming'. It is a language for designers that allows building gameplay without C++. On large projects, the tools team accounts for 10 to 20% of developers.

Hot Reload lets you change C++ code (or Blueprint) without restarting the game. Unreal Engine Live Coding: modify a .cpp, press Ctrl+Alt+F11, code compiles in 15 to 30 seconds and applies to the running instance. Minutes saved per iteration. At 100 iterations per day, that is 2 hours saved.

Unreal Engine Blueprint is slower than C++. Do not use it in production

Blueprint logic compiles to bytecode that runs fast. Hot-path code (rendering, physics) stays in C++. Gameplay logic in Blueprint is fully acceptable and used in AAA games

Fortnite is written largely in Blueprint for gameplay systems. C++ handles engine-level systems. The Blueprint vs C++ speed gap for gameplay is small (microseconds) relative to the productivity gain in iteration

A level designer wants to add a new trap type without a programmer. In Unreal Engine this is implemented via:

Key ideas

  • **Deferred Shading:** G-Buffer collects material data, the lighting pass evaluates everything at once. Thousands of lights without O(lights x pixels) overhead. Cost: bandwidth
  • **Threading:** Main Thread + Render Thread + Worker Pool; double buffering for safe data sharing; Unreal Task Graph / Unity Job System for parallel work
  • **ECS:** contiguous arrays per component type yield cache efficiency plus SIMD, 10x+ performance for large counts of homogeneous objects
  • **Tools:** Blueprint Visual Scripting for designers without C++; Hot Reload saves hours; tools teams are 10 to 20% of staff at AAA

Related topics

Engine architecture builds on every earlier topic:

  • Performance: GPU and CPU — An AAA engine's rendering pipeline implements batching, culling, and LOD as foundational systems, not optional optimizations
  • Memory Management in games — AAA engines maintain custom memory allocators (Unreal FMemory, id Tech zone allocator). No serious engine uses system malloc in hot paths
  • Game Development in interviews — Engine architecture questions are central to senior game engineer interviews at Epic Games, Naughty Dog, and Insomniac

Вопросы для размышления

  • Deferred Shading does not support MSAA because of the G-Buffer. TAA (Temporal Anti-Aliasing) or TSR is used instead. What artifacts does TAA introduce (ghosting, motion blur) and how do games compensate via sharpening and reprojection?
  • ECS suits homogeneous objects well, but a game world contains unique entities (a boss with unique mechanics). How does Unreal Mass Entity reconcile ECS with the traditional OOP Actor system in one project?
  • Hot Reload in Unreal Live Coding recompiles only modified translation units. Editing a header file forces a recompile of everything that includes it. How do precompiled headers (PCH) and Unreal's module system minimize compile time in a large codebase?

Связанные уроки

  • par-01
AAA engine architecture

0

1

Sign In