How does OpenMW render terrain?

General discussion regarding the OpenMW project.
For technical support, please use the Support subforum.
Post Reply
Glitchr9506
Posts: 3
Joined: 08 Jan 2021, 07:09

How does OpenMW render terrain?

Post by Glitchr9506 »

I was wanting to know how OpenMW rendered its terrain. Is it rendered as a bunch of triangles or a whole mesh or something else and how are multiple textures applied to that terrain?
User avatar
AnyOldName3
Posts: 2668
Joined: 26 Nov 2015, 03:25

Re: How does OpenMW render terrain?

Post by AnyOldName3 »

The height data for a cell is stored in ESM files, and that gets converted to a mesh. If you've got distant terrain on, when you're further from a cell, instead of using the full-quality version, a combined mesh will be used for 2x2, 4x4, 16x16 cells etc. which only has as many vertices as you'd normally have for a terrain chunk.

In the terrain data in the ESM, it's got a list of textures per-cell and a blendmap for each which controls how much each texture affects each bit of the cell. Each cell is drawn in multiple passes, first in black, and then with one texture and the corresponding blendmap bound and alpha blending set to additive. The blendmap and terrain texture are multiplied together on the GPU, so the chunk is black where the texture has no effect and the texture's colour where it has full effect, and something in between otherwise, and so as all blendmap values sum to one, when all terrain textures affecting a chunk have been drawn like this, you have the right colour.
Post Reply