LOD system

From Valve Developer Community
Jump to: navigation, search

When rendering any First-Person Perspective view, objects appear to get smaller as they get futher away from the viewer.

In source, the Viewer is usually the Player's Viewport, but LOD also applies to a point_camera entity's in-world display.

Because the Viewer's screen resolution limits the number of pixels available to render a scene, an object's finely detailed "close-up" geometry and textures are simply wasted at greater distances. Source therefore uses an LOD optimisation system which renders "cheaper" models and textures at greater distances, where the difference in detail (number of polygons and pixels) is invisible to the Viewer. This allows us to have very large, open areas in maps without sacrificing "close-up" detail or bringing the Rendering Engine to its knees.

  • Models use the $lod configuration in their QC file to specify which Mesh and Skin should be rendered beyond a specified Distance.
  • Brushes may use func_lod to specify a Distance at which the Brush is not rendered at all.
  • Textures use mipmaps which are automatically generated by the VTF compiler, stored in the texture's VTF file, and used automatically by the Rendering Engine.

Design Guidelines

The simple rule of thumb is:

  • When the distance between Viewer and Object is doubled, the apparent height and width of the Object are halved..
(For more detailed calculations, see the FOV article.)

Mipmaps are created and applied on this principle. Each successive mipmap is half the height and width (ie number of pixels) of the previous one, and its distance threshhold is double. In practice the texture_scale is also a factor in determining the actual distance (eg in game units) at which the mipmap will switch.

To do: where does $detail come into it ?

A Model's $lod configuration specifies the Distance for each LOD threshhold, so you are not limited to "double-distances", but these do provide a good benchmark for creating LOD meshes and skins.

The $lod Distance is specified by a metric rather than game units.

The practical way to achieve a good set of LOD threshholds for your LOD Models is to use the HLMV Model tab to find numbers where the LOD transitions with a low amount of visual popping.