System Architectures Game Engine Architecture: Basics and History Jonathan Thaler Department of Computer Science 1 / 59
Introduction Remember the Driving Forces of Architectural Design ... 4. Driving Force Particular efficiency requirements may lead to suitable software architectures: For example: Performance. Ease of modelling effort (process-oriented modelling versus event-oriented, visual modelling, ...) 2 / 59
Introduction Unreal Engine 5 https://www.youtube.com/watch?v=Oa2drgVThbs 3 / 59
Game Engine Architecture Definition Game Engine Architectures are an architectural style which allow to implement soft real-time interactive agent-based computer simulations . The main architectural driving force of Game Engine Architectures is conveying experience of how to build software with very strict performance require- ments . 4 / 59
Game Engine Architecture The focus of a Game Engine Architecture is on performance as games in general perform a massive amount of numerical computations to achieve high visual fidelity. The essence of game engines is built around a main loop , which executes as fast as possible, with the aim of not dropping below 30 iterations per second. In general, this is not a hard constraint, cannot be guaranteed and depends on the hardware and computational complexity of the game, therefore we refer to games as soft real-time . In the main loop various subsystems are executed, implementing various features required by every game. 5 / 59
Game Engine Architecture Game Engine Subsystems: Rendering Audio and sound Physics AI Animations Input Data Streaming Networking Scripting Game Object Management 6 / 59
Game Engine Architecture Rendering Subsystem Responsible for displaying the graphics on the screen in either 2D or 3D. It is generally the most computationally heavy subsystem , therefore getting dedicated support from rendering hardware such as GPUs . There exists various graphics APIs such as Direct3D, OpenGL and Vulkan which provide a standardised interface for accessing rendering hardware, allowing to implement platform-independent rendering subsystems. 7 / 59
Game Engine Architecture Audio and Sound Subsystem Plays in-game background music and sounds , triggered by certain events and influenced by the physics of the environment e.g. a cave or the doppler effect by moving sound sources. There exists also deditcated hardware for this, which can be also programmed through open and standardised interfaces such as OpenAL and FMOD. 8 / 59
Game Engine Architecture Physics Subsystem Performs collision detection and computes realistic movement of rigid bodies, cloths, ropes and other elastic materials. This subsystem can be also quite computationally heavy and has traditionally been computed on the CPU. In the mid 2000s dedicated physics hardware emerged, which then eventually got integrated into the more general GPGPUs, therefore in modern game engines GPUs also perform physics calculations along- side the CPU. When physical accuracy is paramount, such as in racing games, the physics sim- ulation is executed in a separate thread with for example 100Hz or above, to achieve a higher update rate and not be limited by rendering performance. 9 / 59
Game Engine Architecture AI Subsystem Responsible for implementing various low- and high-level AI functionality such as path finding and environment scanning (low-level) or tactical behaviour (high-level). The computations of this subsystem are generally executed on the CPU. 10 / 59
Game Engine Architecture Animations Subsystem Required by every game , whether it is 2D or 3D. 2D animations are achieved by sprites, which are simply a number of images displayed over time. 3D animations are much more computationally heavy and complex as they are generally implemented using sekeletal animation, requiring the interaction of many transformation matrices and interpolation of many values over time. 3D animation is therefore executed to a great extent on the GPU . 11 / 59
Game Engine Architecture Input Subsystem Capture input from the user from various devices such as mouse, keyboard, joystick or more advanced system such as Wii controllers. To achieve high performance buffered input is used where instead of waiting blocking for the input, the OS or the input library buffers input between frames which can then be queried in the next frame without delay. 12 / 59
Game Engine Architecture Data Streaming Subsystem Deals with the streaming of data from the harddisk / optical disc into the game. As modern games have content that goes far beyond what fits into the main memory of standard hardware, it is necessary to stream data in the background and load/unload parts of a level seamleassly. 13 / 59
Game Engine Architecture Networking Subsystem Is an important subsystem to implement multiplayer functionality. There exist a number of different approaches how to program multiplayer games, and which to choose depends very much on the genre of the game. 14 / 59
Game Engine Architecture Scripting Subsystem Allows to implement game functionality such as triggering events upon some player action using a high level scripting language such as Lua, Python or even JavaScript. This allows for quick prototyping and faster development as there is no need to customise existing classes and recompile the whole engine. 15 / 59
Game Engine Architecture Game Object Management Subsystem Responsible for providing certain classes of game objects , such as vehicle, NPC, door. Manages their relationships and interactions . This is basically the domain layer of traditional monolithic layered architectures, however in game engine middlewares they have to be quite general to support a broad range of games (for the specific genre). 16 / 59
Game Engine Architecture Game engines are built in layers Figure: Runtime game engine architecture 17 / 59
Game Engine Architecture 18 / 59
Game Engine Architecture 19 / 59
Game Engine Architecture 20 / 59
Game Engine Architecture Implementing Game Engines Practically all modern game engines are written in C++ . C++ is a modern object-oriented programming language with a rich featur set, allowing low-level memory management , following a policy of zero run-time overhead for features. This makes it possible to write extremely performant code while still having the benefits of object-oriented programming. Having high performance is of fundamental importance in games for obvious reasons. Object-oriented programming is clearly the programming paradigm best suited to game engines in particular and computer simulations in general. 21 / 59
Game Engine Architecture Implementing Game Engines Game engine developers pick a standard which suits them and then stick to it for at least one generation of their engine. Also, game engine studios deliber- ately restrict themselves to a specific subset of C++ and avoid usage of more problematic features : Exceptions cause overhead. Certain variants of automatic memory management as games need to be in full control over memory. Extensive use of template metaprogramming as code tends to become non-portable and very difficult to understand. The use of the STL and containers due to memory management (STL has a lot of memory overhead). 22 / 59
Game Engine Architecture Implementing Game Engines Ideally a game engine is platform independent, by following a component-based architecture, allowing for abstracting the subsystems into interfaces, providing different implementations for them and by programming a specific subsystem against standard APIs. How can we arrive at a maintainable software architecture with high cohesion and low coupline and achieve required performance? How much performance are we willing to sacrifice for a higher software quality such as high cohesion, low coupling, leading to better maintainability and higher productivity? 23 / 59
Game Engine Architecture Implementing Game Engines A game engine should be customisable and extensible and applicable to a wide range of games but it is unlikely a that an engine will be applicable to all kind of genres. a For example the Unreal Engine is generally used in 1st and 3rd person 3D games such as Fortnite, Unreal,... and it is rather unlikely that we will see its use in real-time strategy such as Star Craft or in MOBA such as Dota 2 (interstingly Dota 2 uses the Source Engine ;)). 24 / 59
Game Engine Architecture Game Engine Architecture In this course we will ignore specific implementation details of various subsystems and primarily focus on the ”glue” which holds them together which is the game engine architecture . More specifically we are discussing how the main loop is implemented, how subsystems interact , how game object management works. 25 / 59
Introduction A short and opinionated 1 History of Game Engines. How did we end up with Unreal Engine 5 ? 1 Let me know if you think I missed an important (your favourite) game. 26 / 59
Introduction CPU-only, until 1996 27 / 59
History of Game Engines 1993: Doom I Figure: Doom is considered to be one of the most significant games in video game history and is frequently cited to be one of the greatest games of all time. 28 / 59
History of Game Engines 1994: Doom II Figure: Doom pioneered impressive 3D graphics, multiplayer gaming and modding. 29 / 59
Recommend
More recommend