S&box Wiki

LODs

LODs

Introduction

LODs are variant meshes that often have lesser geometry than its derived original. When an original model with high-quality meshes is viewed from far away, it can be swapped for an LOD-group of itself with lower quality meshes to improve performance, whilst the distant camera view of the player would see no respectable difference.

Similarly, it is also common for textures to be vested with mipmaps that interchange based on the camera's distance from its material surface.

Preparing LODs

LODs are easiest to make when derived directly from the various parts (or single part) of your original model. The mileage for creating LODs will vary based on your modelling software. A common practise is to make a copy of the original geometry and thereafter decimate it, which instructs the software to reduce the amount of vertices that the geometry consists of, while simultaneously compromising for as much of its original shape as possible. There may be other methods of simplifying a mesh convincingly at a distance and different software may offer differing tools towards doing so.

Once this has been done for the first iteration of an LOD, you can repeat the procedure above with stronger and stronger decimation over time, making sure that the geometry count decreases over each time. Every iteration is made part of a new LOD group that can be set further and further away from the original model. It may look unimpressive after a few iterations, but from far away it will be nearly impossible to tell.

e6UZHzwi2z.gif

You can also set up LODs to exclude smaller separable parts of the model that would never be visible from a long distance away, if decimating the geometry further is no longer viable.

Moving into ModelDoc

Import the meshes of your model, including their LODs, into the ModelDoc node tree. It is generally a good idea to also associate all of your meshes and LODs with a default, or several bodygroups of your choice. This can also be automated by selecting the meshes in the node tree and right clicking:

image.png

Once the meshes, and their LOD associates, are bodygrouped accordingly, it is time to add LODGroups in ModelDoc:

image.png
The first LODGroup that is added is always referred to as LOD 0 by default, and it always has a visibility threshold of 0, meaning that this group is where you should designate the original model, and no LODs. Meshes that are never included in any LODGroup will also never be visible!

LODGroup simply refers to a single LOD group, so add or duplicate as many as you need. LODGroupAll is a unique group that contains meshes that should always be displayed, no matter the distance. This is useful for parts of the model that do not have LODs made for them, and thus should always be visible all the same at any distance.

LODGroups are sorted in the tree, according to their switch threshold. This threshold can be edited in each LODGroup node. It is a measurement of distance that can also be snapshotted from the ModelDoc viewport, via a button at the top of the node's property list:

The slider of the switch threshold, at the top of the node editor, is clamped to values between 0 and 50. Any higher value input into the adjacent box will get clamped down. The workaround to this is to use the property input at the bottom, instead of the slider at the top. Their functionality is seemingly identical, but you may not be able to use snapshots of the viewport at longer distances.
image.png

The groups will be named accordingly, but to quickly add the corresponding meshes into each one, you can refer to the previous context menu and use the same automation technique. All second-rate LODs correspond to group LOD 2 and so on:

Example

Part name → LODGroup
part.dmx LOD 0
part_lod.dmx LOD 1
part_lod2.dmx LOD 2
... ...
image.png

Once the meshes and their LODs are distributed and the LODGroups are given switch thresholds, the model can be compiled and you can immediately test the LOD functionality. Either via the Compiled Preview Outliner or via the LOD box on the upper bar.

image.png

You can also toggle Rendering Info in the viewport to get instantaneous feedback on the currently active LOD group.

image.png

Special Pages


Wikis

?

Render Time: 16ms

DB GetPage 4
Generate Html 0
SaveChanges (1) 8
Render Body 0
Render Sidebar 1