LOD Groups

From Mod Wiki
(Redirected from LOD Group)
LOD Groups as used in Salvage.

LOD (Level of Detail) Groups allow for map geometry, lights and entities to be hidden or shown at a distance. It's primary use is to hide distant geometry and/or replace it with simpler versions of the same geometry in order to improve rendering performance.

LOD Groups can be seen working in-game by keeping a very close eye on some buildings or structures as you move away from them - while subtle, you can sometimes see buildings and objects fade out when you are too far away to notice they were there in the first place. In the heat of battle, the transition should be completely invisible to most players, but provides enormous performance benefits. The same technique can also be used to replace complex geometry with simpler versions so at a distance it looks identical, but is far faster to draw.

Usage

A LOD Group consists of 1 or more 'Levels' to which an object can belong. Each LOD Group Level has minimum and maximum view distance settings (MinVisDist and MaxVisDist respectively), such that objects placed in that level will only be rendered when it is between MinVisDist and MaxVisDist units away.

The most basic LOD Group contains just one level with a MinVisDist setting of 0 and a MaxVisDist setting of 4096. This would make any object in the group disappear once it is more than 4096 units from the camera. Depending on the map and object, this number could be lowered or raised to make the LOD group fade out sooner or later.

If an object is not assigned to any LOD Group, it is rendered all the time irrespective of distance.

  • Note: Powers of 2 (1024, 2048, 4096, 8192, 16384 etc.) are traditionally used for draw distances, although they can actually be any appropriate positive integer.

Basic Setup

LOD Groups Inspector

To make an object, a model or brushwork disappear at 4096 units, first create a LOD Group: use L for the Groups Inspector, press the red/green/blue button on the Groups Inspector window for the LODs view, and then press the green 'plus' button. This will create a new LOD Group called New Group with three levels underneath it (New Group (Level 01), New Group (Level 02) and New Group (Level 03)).

New LOD Groups have 3 levels by default. Change this to 1 by selecting 'New Group' and change its Num Stages property to 1.

To add objects to the group, select them, then RMB on the LOD Group and choose Add Selection to New Group. This will make the selected objects part of the LOD Group New Group (rename as appropriate!)

Finally, to make the objects in the group fade out at 4096 units, click on the LOD Group New Group (Level 01) and set MaxVisDist to 4096.

LOD Group Level

Each level has a number of properties that affect the rendering of the objects within it.

  • Ambient Cubemap - Ambient cubemap to apply for this stage.
  • dontCastFromAtmosLight - Enable to disable shadows from atmosphere light. Use this to stop the sun casting shadows from geometry in this LOD group level.
  • drawSpec - GPU spec at which to draw group.
  • Generate AAS - Bot navigation info will be generated from this groups' geometry
  • Inline Collision Model - Merge the collision model into the main world
  • Instance - Models in this group will be instanced
  • MaxVisDist - The maximum distance from the player that this group will be drawn
  • MinVisDist - The minimum distance from the player that this group will be drawn
  • noShadows - Enable to turn off shadows in this group.
  • occlusionTest - Models in this group will be occlusion tested.
  • Push By Origin - Use the group's origin, rather than the bounds, for determining visibility.
  • shadowSpec - GPU spec at which to shadow from group
  • shadowVisDistMult - shadow max dist = shadowVisDistMult * MaxVisDist
  • VIS Dummies - List of VIS dummy entities to push the level's geometry into
  • visDistFalloffInfo - The fraction of the distance that the group is blended out. (e.g. if MinVisDist is 0, MaxVisDist is 1024, and visDistFalloffInfo is 0.25, the level will be faded out within 256 units)

Where a LOD Group has multiple levels - for example to swap a structure out for a simpler version at a distance - it is common to use the noShadows setting to stop shadows being cast at the higher LOD levels.

Examples

A Hut

Hut as seen from various distances

This hut is used in the map 'Island', and uses LOD Groups to reduce its complexity when at a distance. It has four LOD Groups: decals, fencing, models, and structure.

Decals contains all the dirt decals on the building, and models contains the boxes and crates on the outside. Both consist of just one LOD level and fade out at 4096 units.

Fencing contains the patch meshes used for the fence, and again consists of one LOD level but fades out at 8192 units.

Finally, the structure group contains the structure of the hut itself, but has two levels: one for the trims, stilts, and stairs that fades out at 8192 units, and a second level which consists of the actual walls, floor and roof of the hut which fades out at 16384 units.

We can see these groups in action on the screenshot: top-left shows all groups being rendered, top-right shows the decals and models groups faded out (the player is more than 4096 units away), bottom-left shows the fencing and one level of structure are gone (more than 8192 units away), and finally at more than 16384 units away the hut isn't rendered at all.

Batches

Batching is the process of rendering many parts of the scene at the same time with the same texture in order to improve performance. The fewer batches that are required to render the scene, the quicker it can be rendered. Therefore, by reducing the number of different textures/shaders a map uses (hence fewer batches), the quicker is should be able to perform.

The way LOD Groups are set up is particularly important for batching. A particular scene may require 15 batches to render, but if one of those batches is for a tiny, small model hundreds of metres away that the player can barely see, then the advantage of batching is lost. This could be avoided by placing the model in a LOD group that disappears at a short distance (i.e. a smaller MaxVisDist value), thereby reducing the number of batches to be rendered and preserving performance.

Developer commands

r_showModelTypes on Sewer
  • r_visDistOfs - this can be used to artificially test out LOD render distances. For example, by setting r_visDistOfs 5000, the engine only renders what would be seen if you were 5000 units further away.
  • r_lockedView 0/1 - in this mode you can move the camera around the level and it'll only render what was being drawn when r_lockedView was turned on.
  • r_showModelTypes 0/1 - renders triangles as green if they are part of a LOD group, and blue if they are not.


Notes

  • Brushes do not cut up the faces of brushes in other LOD Groups, however, they do cut up brushes within their own LOD Group. This means you can have two overlapping LOD Groups, and the brushes in one LOD Group won't cut up the brushes in the other LOD Group. (However brushes still cut brushes in the same LOD Group that they belong to.)

See Also