CodeBlanks Logo Icon CodeBlanks

LOD groups

Learn distance-based mesh detail with LOD Group.

What is Level of Detail (LOD)?

When an object is close to the camera, thousands of polygons and detailed geometry are necessary; however, at 60 meters away, seeing these details is impossible. LOD (Level of Detail) is the system that swaps in lower-polygon versions of a model based on distance to the camera.

// Unity LOD Group structure:
// LOD 0: 5000 polygons (Close distance)
// LOD 1: 1500 polygons (Medium distance)
// LOD 2: 300 polygons  (Far distance)
// Culled: 0 polygons   (Too far, not drawn)

The LOD technique substantially reduces vertex processing on the GPU.

LOD transitions and Culled state

The LODGroup component attached to an object in Unity manages transition thresholds according to screen coverage. When the model shrinks below a minimal percentage of the screen, rendering stops completely; this state is called Culled.

LODGroup group = GetComponent<LODGroup>();
// lodCount returns the number of defined LOD levels
int levels = group.lodCount;

This prevents thousands of distant trees or rocks on the horizon from straining the graphics card.

Practice Select LOD level by distance

Check the given distance: if less than 20 assign "LOD 0", if less than 50 assign "LOD 1", otherwise "LOD 2", and print with Console.WriteLine.

Starter code

Player.cs
using System;

class LodSystem
{
    static void Main()
    {
        float distance = 45.0f;
        // Mesafeye gore LOD seviyesini belirle ve yazdir
        
    }
}

Sample solution

Player.cs
using System;

class LodSystem
{
    static void Main()
    {
        float distance = 45.0f;
        string lodLevel;
        if (distance < 20.0f)
            lodLevel = "LOD 0";
        else if (distance < 50.0f)
            lodLevel = "LOD 1";
        else
            lodLevel = "LOD 2";

        Console.WriteLine($"Mesafe: {distance}m - Aktif: {lodLevel}");
    }
}

Expected output

Mesafe: 45m - Aktif: LOD 1

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 What does the LOD Group component do for a model moving away from the camera?

  • Disables all lighting in the scene
  • Automatically narrows the camera field of view
  • Completely removes the object from the physics engine
  • Switches to a lower-polygon, reduced-detail version of the model Correct answer

Explanation: LOD Group performs progressive transitions between simplified mesh models based on the screen percentage of the object.

2 Get LODGroup component

Question
LODGroup lodGroup = GetComponent<____>();
Answer
LODGroup lodGroup = GetComponent<LODGroup>();

Explanation: The component that manages LOD levels and transition percentages for a model is LODGroup.

3 LOD stages

Term Meaning
LOD 0 Highest polygon and detailed mesh
LOD 1 Simplified mesh for medium distances
LOD 2 Lowest polygon mesh for far distances
Culled Stop rendering when too small

All lessons in Expert