Assets Other

Controlling Level of Detail (LOD) Distance

single-image

We’ve mentioned LOD before, but what does it really mean and why do we need it?

In the image below, you can see 5 LODs for an asset (yes, programmers like to count starting at 0 🙂

In the 2D view at the top you can see the mesh shapes getting simpler and simpler. The “3D” view below shows the size that item appears in game at the distance indicated.

So the small “dot” that appears at 1km and beyond is, in fact, not a high res 40,000 polygon “sphere” but instead a very simple 8 sided object.

As you can see in the image above, it’s hard to tell that you’re not looking at the original object as the camera moves away, but instead viewing an increasingly simplified LOD version of that object.

Of course the major benefit of adding these LOD versions is that your hardware is then not being forced to draw millions of polygons that are, for all intents and purposes, not visible on screen.

Controlling LOD Distances

As content quality and fidelity improve over time and in-game objects look more and more realistic, it becomes increasingly important to ensure the Level of Detail (LOD) is carefully managed.

Imagine the performance impact of a very high resolution asset that doesn’t reduce in complexity when it apears as a few pixels on screen.

In the current Trainz, the game decides when to reduce LOD. In the next version of Trainz, we’re providing the Content Creators the power to customise and control when each LOD cuts in. This gives more flexibility to allow more aggressive scene reduction

We’ll be introducing a new config.txt tag (“mesh-table-lod-transition-distances”) to control the distance at which the LOD transitions occur.

The use of this feature replaces the “mesh-detail-level-count” and “maximum-lod-distance” tags, which will be obsolete as of v4.6 (the expected trainz-build number for our next Trainz product).

The “mesh-table-lod-transition-distances” tag will be optional as of v4.6 and if used must contain a float array specifying the end distances for each LOD level. If this tag is omitted, then no mesh-table LOD is used.

This is suitable for low-detail scenery assets and for LM-only assets such as train vehicles or Carz.

Example:

mesh-table-lod-transition-distances 10.0, 30.0, 150.0, 1000.0

This example specifies 5 mesh-table LOD levels.
The first (LOD 0) ranges from 0.0m to 10.0m.
The first (LOD 1) ranges from 10.0m to 30.0m.
The first (LOD 2) ranges from 30.0m to 150.0m.
The first (LOD 3) ranges from 150.0m to 1000.0m.
beyond this the asset won’t be rendered.

Practical Example:

Here is an example of an in-game asset that has LOD versus one that doesn’t.
On the left we are showing <kuid2:134105:28049:1> Terrace 1 – LOD
On the right we are showing <kuid:134105:28041> Terrace 1

With LOD implemented, the creator Paulzmay reduces the house from 168 polygons to just 14 at the lowest LOD.

So with 32,000 of these items loaded (using the “Performance Anaysis” option in Preview Asset) we see that the LOD version requires just 22,644 polys and 9 draw calls versus a mammoth 1,666,224 polys and 53 draw calls for the no-LOD version. That’s 80x less polys

In the image below is a beautiful street lamp. The closeup view shows how detailed this item really is. However, in the distant view, with no-LOD, each lamp is still being drawn with all 2,780 polygons per lamp, even when the item is a single pixel wide on screen. So now the scene is rendering over 12 Million polys!

You may also like