Mesh-table LOD

From TrainzOnline
Jump to: navigation, search

Mesh-table LOD is a Level of Detail (LOD) technique intended for use on simple scenery assets. It is the primary alternative of the LM.txt file LOD technique, which offers more flexibility but is more expensive and is incompatible with mesh stitching and other substantial optimisations.

Please note that it is possible to use both forms of LOD in a single asset, in order to gain flexibility in the high LODs and performance in the low LODs. The Advanced LOD Techniques page covers this in more detail.

Technique

Mesh-table LOD works at the asset level. The mesh-table-lod-transition-distances tag is used in the asset's config.txt file to define the transition distances between each LOD level. The most detailed LOD level is #0. This starts from the camera and continues until the first transition distance is reached (specified in meters). At the transition distance, the asset changes to LOD level #1. This continues until there are no more transition distances specified in the mesh-table-lod-transition-distances tag, beyond which the asset instance remains at the same (lowest) LOD level until it exceeds the user-specified maximum draw distance, at which point it vanishes entirely.

A LOD transition causes various meshes from the asset's mesh-table to become visible or invisible. Specifically, if a mesh was already invisible for any other reason than LOD, that mesh remains invisible. If the mesh is considered visible for all reasons other than LOD, then the lod-level tag for that mesh is consulted to determine whether the mesh should be visible at the current LOD level. If the lod-level tag is not specified, the mesh is unaffected by LOD.

Interaction with Draw Distance

The LOD transition distances do not override the user-specified draw distance. If LOD transitions are specified which are beyond the draw distance, these will never be used. The asset instance will behave as expected prior to the draw distance, and then suddenly disappear at the draw distance, regardless of what LOD instructions are given in the config file. There is no performance cost to the extra LOD transitions; it is simply as if they were not present in the config file.

Custom Draw Distance

It is possible to cause an asset to be culled from the scene earlier than the user-specified draw distance. This is used as a performance enhancement in scenarios where a mesh can safely be removed from the scene without affecting visuals. For example, a very small object could be explicitly culled from the scene once it is far enough away from the camera that the user can no longer make it out. This technique works by simply defining a LOD transition with no corresponding meshes. The asset instance is still within the draw distance, and is still considered visible by the game, but since there are no meshes available at the LOD level in question, nothing will be visible on the screen and no rendering performance will be consumed.

This technique should be used with some caution:

  • You must specify a lod-level tag for all meshes, since leaving one out will cause that mesh to be visible on your "empty" LOD.
  • You should only ever leave the final LOD empty. Higher LODs should always have at least one mesh visible.
  • You should only use the technique where there is a substantial gain. For example, if you can cut off at 200m without causing visual problems, you have a good use case. Cutting off at 8km is probably pointless and you should just let the game handle the draw distance in this scenario.
  • If you have a mesh which is small enough to go away, but the actual moment of transition is too obvious, consider having a second-lowest LOD which helps to smooth the process (eg. by making the mesh partially transparent, or reducing the size or impact of the mesh somehow).
  • This technique can be worthwhile, but is not as cheap as when the mesh is truly culled at the draw distance. You will still pay other costs associated with having the mesh in the scene, such as LOD update calculations, script updating, collision detection, etc.
Personal tools