Translation: Anatomy of the Total War game engine, Part 1
- Transfer

Good afternoon, dear readers. Your attention is invited to translate a fascinating series of articles on the architecture of the game engine Total War.
Who cares, welcome to cat!
Let me start with a quick look at the finished render of Total War: Attila. In the next few articles, I will tell you about the major changes and optimizations that were made during the development of Total War: Warhammer.
Shadows
Each new frame begins with the drawing of shadows from the main directional light source. Cascading shadow maps are used: 2-4 cascades depending on the graphics settings. The terrain is not drawn into a shadow map, but for a real-time strategy, as you could already imagine, we draw a huge number of small objects compared to first-person or third-person shooters, which draw less, but in more detail. The screenshot below shows the final frame of the Total War: Attila engine.

Landscape
Terrain is one of the most important parts in our game. Being a real-time strategy, the terrain in our game is somewhat different from the terrain in first-person games. We focus on medium-long distances, not short-range ones. The landscape should be divided into repeating patterns - tiles, and have a smooth transition between different types of landscape. Instant movement should also be supported when a player clicks on the minimap, which creates additional difficulties with streaming techniques. Also on the map are many meshes (part of the rock, for example), which must be mixed with the textures of the landscape, which, in turn, are themselves a combination of several layers.
Each battlefield contains many tiles, pieces into which the map is divided. In the games of the Total War series, the global map is huge, so it is impossible to force artists and modelers to create it entirely by hand. In order to deal with this, they use tiles. The tile itself can be represented as a separate card. However, when you start a battle on a company’s map, the battlefield is assembled from surrounding tiles, which can be different - both in size and in shape. The result is that each battlefield is composed of several tiles, where each tile uses its own set of textures. To hide artifacts when stitching tiles, we mix their textures.
For example, imagine a T-shaped intersection of forest, desert, and swamp tiles. Each tile contains 8 texture layers, and at some points it is necessary to mix the textures of all three tiles, which means a potential mix of 24 layers for each pixel. Each layer contains texture –normal and reflective / shiny, which means 24 × 3 = 72 textures per pixel. We have no restrictions on how many tiles / layers can be mixed.
To satisfy all needs, at first we draw only a depth map (including the generated landscape and meshes created by artists). After we run through the screen-space algorithms for each tile, each of which has its own mixing map and projects the layers onto the geometry, which you can imagine as a large projected decal.
GBuffer
GBuffer stores 3 textures in the following form:

One thing that you may notice is clearly highlighted is that we do not store anything in the alpha channel of the first two textures. This is justified by the fact that all properties are mixed at the time of landscape rendering and decals, and we need an alpha channel to set the transparency. The normals themselves are stored in a compressed two-channel format.
You may also notice that we are using diffuse / reflective material, not color / metal. This is a tradition, and we are in the process of change.
Lighting
Most of the lighting comes from the main directional light source. There is a statistically calculated BRDF model that is physically correct and gives a microfacet distribution based on a Gaussian distribution. This model was first introduced in Total War: Rome II. This gives ideal (unstretched) mirror reflections of the sphere and allows you to work with the size of the solar disk.
Total War: Attila has its own implementation of the global occlusion system.
Particles
Particles are created on the CPU, but are simulated and processed on the GPU. Three types of GPU particles are supported: quad, projected decals, and an omnidirectional light source. On top of all this is a CPU pipeline with limited functionality for particles consisting of meshes.
Tonemapping
We use a tonemapping operator based on a curve with automatic levels, which, in turn, are based on the average / minimum / maximum brightness on the screen.
Pipeline Total War: Attila (Simplified)

In the next article, we will look at how performance is measured in Total War and take a look at the main shader optimizations to get the desired performance.
From the translator PS:
About some topics (“Tonemapping” and “mirror reflections of the sphere”) I have only theoretical superficial knowledge, therefore I would greatly appreciate constructive criticism and comments on the translation.