Follow us
YouTube: https://www.youtube.com/@piccoloengine
Website: https://games104.boomingtech.com/
WeChat Official Accounts: games104
GitHub: https://github.com/BoomingTech/Piccolo
Lecture 02: Layered Architecture of Game Engine | GAMES104 - Modern Game Engine: Theory and Practice
This course will introduce the system architecture, technical points, and engine system-related knowledge involved in modern game engines. Through this course, you can build a comprehensive and complete understanding of game engines. If your hands-on ability is strong enough, you will be able to follow the course and build a complete mini-game engine from 0 to 1. This course is suitable for students in related professional fields, researchers, and anyone interested in game engine design and development.
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Lecture 02: Layered Architecture of Game Engine | GAMES104 - Modern Game Engine: Theory and Practice
1. WANG XI GAMES 104 2022
Modern Game Engine - Theory and Practice
Modern Game Engine - Theory and Practice
Lecture 02
Layered Architecture of
Game Engine
5. Modern Game Engine - Theory and Practice
Make It Visible, Movable and Playable
Rendering
Animation
Physics
Camera, HUD and Input
Script, FSM and AI
Tool Layer
Function Layer
6. Modern Game Engine - Theory and Practice
Data and Files
Tool Layer
Function Layer
Resource Layer
Scene and Level
Script and Graph
Game Logic Data
7. Modern Game Engine - Theory and Practice
Animation Physics Render Script Camera
Swiss Knife of Game Engine
Tool Layer
Function Layer
Resource Layer
Core Layer
8. Modern Game Engine - Theory and Practice
Publishing Platforms
Input Devices
Launch on Different Platforms
Consoles
Tool Layer
Function Layer
Resource Layer
Core Layer
Platform Layer
Operation Systems
Platform File Systems
Graphics API
Platform SDK
…
9. Modern Game Engine - Theory and Practice
Middleware and 3rd Party Libraries
Tool Layer
Function Layer
Resource Layer
Core Layer
Platform Layer
3
rd
Party
Libraries
10. Modern Game Engine - Theory and Practice
Explore Game
Engine Layers
Think I’m ready to roll!
11. Modern Game Engine - Theory and Practice
Practice is the Best Way to Learn
Simple Animated Character Challenge
• Create, animate and render a character
• Playable on selected hardware platforms
I want to build an
animation system
12. Modern Game Engine - Theory and Practice
Resource - How to Access My Data
Offline Resource Importing
• Unify file access by defining a meta asset file format (ie.ast)
• Assets are faster to access by importing preprocess
• Build a composite asset file to refer to all resources
• GUID is an extra protection of reference
Tool Layer
Function Layer
Resource Layer
Core Layer
Platform Layer
3
rd
Party
Libraries
GUID
texture.ast character.ast mesh.ast animation.ast
13. Modern Game Engine - Theory and Practice
Resource – Runtime Asset Manager
Runtime Resource Management
• A virtual file system to load/unload assets by path reference
• Manage asset lifespan and reference by handle system
Handle vs. Post Address
Tool Layer
Function Layer
Resource Layer
Core Layer
Platform Layer
3
rd
Party
Libraries
14. Modern Game Engine - Theory and Practice
Resource – Manage Asset Life Cycle
Memory management for Resources - life cycle
• Different resources have different life cycles
• Limited memory requires release of loaded resources when possible
• Garbage collection and deferred loading is critical features
Tool Layer
Function Layer
Resource Layer
Core Layer
Platform Layer
3
rd
Party
Libraries
Character Scene Cutscene
15. Modern Game Engine - Theory and Practice
Function - How to Make the World Alive
Physics
Camera
Motor
Character
Controller
Animation
Input
Render
Network.
I/O
Memory
GC
Etc.
Logic
Unbelievably Simple!!!
Tool Layer
Function Layer
Resource Layer
Core Layer
Platform Layer
3
rd
Party
Libraries
• Transmission shaft game_main.
cppvoid tick(int delta_time)
• Endless loop
while (true) { … }
16. Modern Game Engine - Theory and Practice
Function - Dive into Ticks Tool Layer
Function Layer
Resource Layer
Core Layer
Platform Layer
3
rd
Party
Libraries
17. Modern Game Engine - Theory and Practice
• In each tick (over-simplified version)
• Fetch animation frame of character
• Drive the skeleton and skin of character
• Renderer process all rendering jobs in an iteration of render tick for each frame
Function -Tick the Animation and Renderer
Tool Layer
Function Layer
Resource Layer
Core Layer
Platform Layer
3
rd
Party
Libraries
18. Modern Game Engine - Theory and Practice
Function - Heavy-duty Hotchpotch
• Function Layer provides major function modules for the game engine
• Object system (HUGE)
• Game Loop updates the systems periodically
• Game Loop is the key of reading codes of game engines
• Blur the boundary between engine and game
• Camera, character and behavior
• Design extendable engine API for programmer
Tool Layer
Function Layer
Resource Layer
Core Layer
Platform Layer
3
rd
Party
Libraries
19. Modern Game Engine - Theory and Practice
Advanced
JOB System
Entry
Fixed Thread
Mainstream
Thread Fork/Join
RenderThread
LogicThread
SimulationThre
ad
Visibility GBuffer Shadow Lighting Transparent PostProcess UI
Lua AI Motor …
LOD Animation Physics Particle …
WorkThread
WorkThread
WorkThread
WorkThread
WorkThread
WorkThread
RenderThread
LogicThread
SimulationThre
ad
Visibili
ty
Shadow Lighting
Transpare
nt
PostProce
ss
U
I
AI
Mot
or
…
LOD
Animati
on
…
WorkThread
WorkThread
WorkThread
Visibili
ty
GBuffer
Mot
or
Mot
or
Animati
on
Animati
on
Animati
on
Animati
on
U
I
U
I
U
I
Mot
or
Mot
or
Visibili
ty
Visibil
ity Lua Shadow Lighting
PostProce
ss
…
LOD
Animati
on
Physics
Visibil
ity
Motor
UI
Mot
or
Animati
on
Animati
on
Animati
on
AI
UI
Mot
or
Mot
or
Visibil
ity
GBuffer
Shado
w
Particl
e
Particle …
LOD GBuffer
Animati
on
Particl
e
Particl
e
UI …
Particle
AI Physics UI …
…
Transpare
nt
Physics Particle
Lua
Function - Multi-Threading
Multi-Core CPU
Tool Layer
Function Layer
Resource Layer
Core Layer
Platform Layer
3
rd
Party
Libraries
• Multi-core processors become the mainstream
• Many systems in game engine are built for parallelism
20. Modern Game Engine - Theory and Practice
Core - Math Library
Tool Layer
Function Layer
Resource Layer
Core Layer
Platform Layer
3
rd
Party
Libraries
Linear algebra
• Rotation, translation,
scaling
• Matrix splines,
quaternion
21. Modern Game Engine - Theory and Practice
Core - Math Efficiency
SIMD
Quake III Engine
Quick and dirty hacks
• Carmack’s 1/sqrt(x)
• Magic number!
Tool Layer
Function Layer
Resource Layer
Core Layer
Platform Layer
3
rd
Party
Libraries
22. Modern Game Engine - Theory and Practice
Core - Data Structure and Containers
• Vectors, maps, trees, etc.
• Customized outperforms STL
• Avoid FRAGMENT memory!
• Skeleton tree
• Animation frame sequence
Tool Layer
Function Layer
Resource Layer
Core Layer
Platform Layer
3
rd
Party
Libraries
23. Modern Game Engine - Theory and Practice
Core - Memory Management
• Major bottlenecks of game engine performance
• Memory Pool / Allocator
• Reduce cache miss
• Memory alignment
• Polymorphic Memory Resource (PMR)
• Cache locality/diffusion
• Memory Arena
• Put data together
• Access data in order
• Allocate and de-allocate as a block
Tool Layer
Function Layer
Resource Layer
Core Layer
Platform Layer
3
rd
Party
Libraries
24. Modern Game Engine - Theory and Practice
Core - Foundation of Game Engine
• Core layers provide utilities needed in various function modules
• Super high performance design and implementation
• High standard of coding
Tool Layer
Function Layer
Resource Layer
Core Layer
Platform Layer
3
rd
Party
Libraries
25. Modern Game Engine - Theory and Practice
Compatibility of different platforms, provides platform-independent
services and information for upper layers
• File system
• Path: Slash/backslash, Environment variables
• Directory Traversal
Platform - Target on Different Platform
Time to show off
Tool Layer
Function Layer
Resource Layer
Core Layer
Platform Layer
3
rd
Party
Libraries
S:Main FolderFolder1Folder2FinalFolder
/Volumes/Share/Main Folder/Folder1/Folder2/FinalFolder
26. Modern Game Engine - Theory and Practice
Platform - Graphics API
Render Hardware Interface (RHI)
• Transparent different GPU architectures and SDK
• Automatic optimization of target platforms
Tool Layer
Function Layer
Resource Layer
Core Layer
Platform Layer
3
rd
Party
Libraries
27. Modern Game Engine - Theory and Practice
Platform - Hardware Architecture
• Core variants: PPU and SPUs
• UMA: unified memory access
Tool Layer
Function Layer
Resource Layer
Core Layer
Platform Layer
3
rd
Party
Libraries
28. Modern Game Engine - Theory and Practice
Tool - Allow Anyone to Create Game
Unleash the Creativity
• Build upon game engine
• Create, edit and exchange game play assets
UI Editor
Logical Editor
Shader Editor
Animation Editor
Flexible of coding languages
Level Editor
Tool Layer
Function Layer
Resource Layer
Core Layer
Platform Layer
3
rd
Party
Libraries
29. Modern Game Engine - Theory and Practice
Tool - Digital Content Creation
Game Engine
Game
Tool Layer
Function Layer
Resource Layer
Core Layer
Platform Layer
3
rd
Party
Libraries
DCC
Editors
Asset
Conditioning
Pipeline
30. Modern Game Engine - Theory and Practice
Why Layered Architecture?
Decoupling and Reducing Complexity
• Lower layers are independent from upper layers
• Upper layers don’t know how lower layers are implemented
Response for Evolving Demands
• Upper layers evolve fast, but lower layers are stable
Tool Layer
Function Layer
Resource Layer
Core Layer
Platform Layer
3
rd
Party
Libraries
32. Modern Game Engine - Theory and Practice
Neat PILOT Engine
Build by C /C++
• Runtime: ~13,000 lines
• Editor: ~2,000 lines
Follow Engine Layers
• Source code still improving
Support Platform
• Windows
• Linux
• MacOS (working on M1)
33. Modern Game Engine - Theory and Practice
PILOT Editor and Runtime
Basic Editing
• Add/Delete objects
• Move/Scale/Rotate objects
Simple Functions
• Character control
• Camera
34. Modern Game Engine - Theory and Practice
Release Plan
1st Release (3/25/2022)
• Editor
• Character/Camera
• Renderer
• Resource system
• Play in editor (PIE)
To be Released with Course
• Animation system
• Collision System
• Gameplay and script systems
• Simple parameter editing
• More graphics features
• …
How to download
• https://github.com/BoomingTech/Pilot simple ECS framework
35. Modern Game Engine - Theory and Practice
Takeaways
• Engine is designed with a layered architecture
• Lower levels are more stable and upper levels are more customizable
• Virtual world is composed by a set of clocks - ticks
36. Lecture 02 Contributor
PILOT Engine Contributor
- 一将
- Hoya
- 喵小君
- 呆呆兽
- Olorin
- 靓仔
- 爵爷
- Jason
- 砚书
- BOOK
- MANDY
- 俗哥
- 金大壮
- Leon
- 梨叔
- Shine
- 邓导
- Judy
- QIUU
- C佬
- 阿乐
- 阿熊
- CC
- 大喷
- 靓仔
- 达啦崩吧
- Shy
- Adam
- 人工非智能
- KUN
- o果蝇o
- 弥漫
- 陈皮
Modern Game Engine - Theory and Practice
37. Enjoy;)
Coding
Please scan here to let
us know what you think
Course Survey
Course Wechat
Please follow us for
further information
Modern Game Engine - Theory and Practice
38. Modern Game Engine - Theory and Practice
Please note that all videos and images and other media
are cited from the Internet for demonstration only.