Skip to main content

Secrets of Relic Entertainment. Part 1.

· 4 min read

I don't think anyone would argue with the fact that Relic is an excellent company. Homeworld, Warhammer 40K: Dawn of War, and Company of Heroes are games that I enjoy very much. I decided to reverse-engineer Relic's latest titles, and started with W40K: DoW – Dark Crusade.

Ready to learn a terrible secret? :) The game uses a completely FFP renderer! Fixed Function Pipeline. That is, no shaders at all! To be honest, this came as a complete surprise to me.

As usual, the investigation was performed using the maximum graphics settings.

The engine features good sorting by render states and textures. There aren't many DIPs.

Scene rendering begins with the terrain. Simple square patches. With the standard camera position, only 5–6 of them fit on the screen.

Two textures are used:

Ground Specular

Ground Tex

The first one simulates specular highlights on the ground. The textures are blended using linear interpolation, controlled by the alpha channel of the diffuse texture, which looks like this:

Ground Tex Alpha

Result after the first pass:

Ground Pass1

Next comes the second terrain pass. Detail textures are applied using standard alpha blending. Examples of detail textures (the green and red checkerboard pattern visualizes the alpha channel):

Ground Details Pass2

Ground Details2 Pass2

Then shadows from buildings and units, explosion craters, and similar effects are rendered on top. Textures roughly like these are used:

Object Shadow

After all of this, there is one more pass in which the lightmap, the fog of war, and this strange 2-texel texture are applied (I enlarged it and added a border, since white-on-white doesn't look very good :) ):

2tex

This is the alpha channel. The texture itself is white. The texture coordinates for it are generated from the vertex position in camera space (D3DTSS_TCI_CAMERASPACEPOSITION), multiplied by a rather unusual matrix. After many long (and unsuccessful) attempts to understand all this clever math logically, I launched the game and started looking for visual clues. The only thing I noticed was a dark stripe running through the middle of the screen. I'm fairly sure this is the effect produced by that texture, although why it was done remains a mystery. Who knows, maybe without this little trick the image suddenly looks much worse? :)

Terrain lightmap:

Ground LM

Fog of war in LUMINANCE8 format. Computed on the CPU:

FOW

The result looks like this:

Ground Complete

Next comes the sky. A dome-shaped mesh is textured with an image that looks like this:

Sky

The texture is blended with a constant color, apparently for attenuation purposes (I didn't fully figure this part out). The sky texture is authored so that its lower portion matches the fog color used on the level. This creates a seamless transition between the two. Once sky rendering is finished, object rendering begins. The formula is simple: Diffuse texture + fog of war + that same mysterious 2-texel texture. The sun is always enabled as the first directional light source.

Example object texture:

Object Diffuse

Units are rendered in exactly the same way. Skinning is performed on the CPU.

Diffuse texture:

Monster Diffuse

Particle systems. Everything is fairly standard here. After that come the markers beneath units, the outline beneath a selected building (each side of the rectangle is rendered separately, which is very strange), and so on.

Before UI

The UI comes last. There are no DPUPs (thank God), but everything is rendered element by element. UI textures are not stored in atlases (which is also rather strange). Every button is a separate image. Text is rendered in blocks.

And that's it. W40K: DoW is a perfect example of art direction and design carrying a game. There's really nothing more to say. After revelations like these, I became extremely curious about how things were done in Company of Heroes. Knowing that I had already seen shadow maps there (yes, they can be implemented on the FFP, but only on NVIDIA hardware), I understood that I was unlikely to encounter a pure FFP renderer for the second time. The only thing I can say right now is that CoH hides no fewer surprises. :) Part 2 is not far away.

Stay tuned!