📜 ⬆️ ⬇️

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



Good afternoon, dear readers. Your attention is invited to the translation of an exciting series of articles on the architecture of the game engine Total War.

Who cares, welcome under the cat!

Let me start by reviewing the total 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 drawing shadows from the main directional light source. Use cascading shadow maps: 2 - 4 cascade depending on the graphics settings. The landscape is not drawn into the shadow map, but for the real-time strategy, as you could imagine, we draw a huge number of small objects compared to first or third-person shooters that draw less, but in more detail. The screenshot below shows the final frame of the Total War: Attila engine.



Landscape


The landscape is one of the most important parts in our game. Being a real-time strategy, the landscape in our game is somewhat different from the landscape in first-person games. We focus on medium-long distances, rather than close ones. The landscape should be broken into repeating patterns - tiles, and have a smooth transition between different types of landscape. Instant movement should also be supported when the 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) that must be mixed with landscape textures, which, in turn, are themselves a combination of several layers.

Each battlefield contains many tiles, pieces into which the map is divided. In 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 cope with this, they use tiles. The tile itself can be represented as a separate card. However, when you start a battle on a company map, the battlefield is assembled from surrounding tiles which can be different - both in size and in form. As a result, each battlefield is made up 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 wood, 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 mixing of 24 layers per pixel. Each layer contains textures - 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 the 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 blending map and projects layers onto the geometry, which you can represent as a large projected decal.

GBuffer


GBuffer stores 3 textures as follows:



One thing that you may have noticed clearly stands out, 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 drawing the landscape and decals, and we need an alpha channel to set the transparency. The normals themselves are stored in compressed two-channel format.

You may also have noticed that we use a scattering / reflective material, rather than color / metal. This is a kind of 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, which is physically correct and gives a distribution of micropatterns based on Gaussian distribution. For the first time this model was introduced in Total War: Rome II. This gives an ideal (undrawn) specular reflection of the sphere and allows you to work with the size of the solar disk.

Total War: Attila has its own implementation of a global shading system (ambient occlusion).

Particles


Particles are created on the CPU, but simulated and processed on the GPU. Three types of GPU particles are supported: quad (quad), projected decals and a non-directional 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 basic shader optimizations that allow you to get the desired performance.

From PS translator:
I have only theoretical superficial knowledge about some topics (“Tonemapping” and “mirror reflections of the sphere”), so I would be very grateful for constructive criticism and comments on the translation.

Source: https://habr.com/ru/post/314744/


All Articles