The Lod Objects are simple components which define what happens when the distance changes.
They wait until the Lod Manager gives them a distance, then they calculate the new lod level.
With that lod level, they decide what to do.

A Lod Object can do whatever it wants to do with the given distance information and the lod level.
It can change the mesh in the mesh filter, activate and deactivate child objects, adjust a variable in a component, or whatever you want it to do.

All Lod Objects derive from the LodObjectBase.cs class.
This class already handles many basic features such as registering, deregistering, position change handling, optimal distance calculation and editor visualizations.

Workflow

The default work process of a Lod Object is the following:

  1. Register to the Lod Manager
  2. Wait for next distance calculation
  3. Calculate new lod level
  4. Does something with the new lod level (and go back to step 3)
  5. When no longer needed, deregister from Lod Manager

Distance overload

LodObject_RelativeDistance

A Lod Object receives two distances; the real distance and a relative distance.

The real distance is just the distance in world units.
The relative distance is the real distance multiplied with all distance multipliers.
Both distances are measured to the nearest camera.

Be aware that if you use two cameras with different local distance multipliers, it can happen that the relative distance is taken from one, while the real distance is taken from the other.

Example:
Imagine the red dots are cameras and the rings indicate a relative distance of 1 meter.
For the relative distance camera A is thus the nearest one.
But camera B has the shorter real distance.

Moving objects

QuickLod optimizes objects which don’t move.
Unmoving objects should be marked as static in order to prevent unnecessary calculations.
Moving objects must be marked as static as position changes need to be considered.

When an object is only rotated or scaled but not moved, it can be marked as static too.

Override lod level

If you want to set the lod level manually, you can do so by activating the option “Exclude from manager”. This will unlock the lod level slider and you can define the desired lod level. A lod level smaller than 0 is equal to invisible or deactivated.

If you want to override the lod level by code, you must enable the option too, as else the Lod Manager will reset the lod level.

Available Lod Objects

There are currently 4 different Lod Object types implemented.

Lod Object Replacement

This Lod Object is similar to the LodGroups from Unity. It enables and disables referenced game objects depending on the lod level.

LodObjectReplacement_HierarchyExampleThe most common way to use this Lod Object is to create an empty and drop all lod level objects as children on it. Then add a LodObjectReplacement component to the parent object.

In this example taken from the hierarchy window, the StreetLamp_01 is the parent object, while the three Lod_x objects represent the different lod level objects.

Those objects need to be referenced in the LodObjectReplacement.
Only the object of the current lod level is active, all other levels will be deactivated.LodObjectReplacement_Lods

You should choose this Lod Object when:

  • You need to use multiple game objects for the different lod levels
  • You want to replace components over different lod levels
  • You want to replace whole object hierarchies

Lod Object Mesh

This Lod Object needs a mesh filter component on the corresponding game object.
It replaces the mesh in the mesh filter depending on the lod level.

Try to use this Lod Object whenever possible as it only needs a single game object and thus uses less memory than the LodObjectReplacement.

You just need to reference the meshes it should use.
If you want to use the Autosetup feature, you might want to take a look into the document How Autosetup Works (PDF)LodObjectMesh_Lods

You should choose this Lod Object when:

  • You want to replace the mesh in the mesh filter
  • Whenever possible

Lod Object Skinned Mesh

It’s equal to the LodObjectMesh, but used for animated meshes (skinned meshes).
It uses the SkinnedMeshRenderer instead of the MeshFilter.

Lod Object Child Switch

This Lod Object activates and deactivates all child objects based on the distance.

This can be used to activate and deactivate many objects at once instead of giving them all a separate Lod Object.
This is normally needed for patches of details like grass, trash or other small objects.

It can also be used to deactivate many objects at a given distance to remove them from physics calculation or other resource heavy tasks.

This component is a simple version of the GroupSwitch, but is limited to distance based triggering and can only manage child objects.
If you want more control over which objects should be managed and when, then you might want to take a look at the GroupSwitch component.

You should choose this Lod Object when:

  • You want to activate/deactivate all child objects at once

Choose the correct Lod Object

If you want to choose the correct Lod Object for a given game object, you can ask the following questions and stop at the first one you can answer with yes:

Do I want to replace components or multiple hierarchies?
Use the LodObjectReplacement

Do I have multiple skinned meshes?
Use the LodObjectSkinnedMesh

Do I have multiple unskinned meshes?
Use the LodObjectMesh

Do I simply want to activate/deactivate all children based on the distance?
Use the LodObjectChildSwitch

Do I want to do something fancy that doesn’t work with any given Lod Object?
Create a new Lod Object or contact me: chillersanim@gmail.com