# Tutorial 11 — LODs for Large Rooms

Large rooms with detailed geometry — wide arenas, multi-floor dungeons, boss halls — can drop the frame rate in VR. **Level of Detail (LOD)** groups let Unity swap in simpler meshes when objects are far from the camera.

---

## What is an LOD group?

An `LODGroup` component holds several meshes at decreasing detail levels:

| LOD level | Distance | Usage |
|---|---|---|
| LOD0 | 0–15 m | Full detail (seen up close) |
| LOD1 | 15–40 m | Reduced poly count (~50 %) |
| LOD2 | 40–80 m | Very low poly (~20 %) |
| Culled | >80 m | Not rendered at all |

Unity automatically switches between levels based on the object's screen-space size, not raw distance — so a large pillar stays detailed longer than a small torch.

---

## When to use LODs

LODs pay off when:
- Your room is 20 m or wider
- You have repeating props (pillars, torches, barrels) placed many times
- Meshes have > 500 triangles each

For small rooms with Unity primitives (Cubes, Planes), LODs are not needed.

---

## Step 1 — Create LOD meshes in Blender

You need **two or three versions of each mesh** at decreasing detail:

1. Start with your full-detail mesh (e.g. a stone pillar, 1 200 triangles)
2. Select the mesh → **Modifier → Decimate** → set **Ratio** to `0.5` → **Apply** → this is LOD1
3. Duplicate again → Decimate to `0.15` → Apply → this is LOD2
4. Export all three as separate FBX files: `pillar_lod0.fbx`, `pillar_lod1.fbx`, `pillar_lod2.fbx`

> **Rule of thumb:** LOD1 should not be visually different from LOD0 when standing 15 m away in VR. Test by standing back in Blender with the camera zoomed out.

For simple geometry (Cube-based walls, flat Planes), skip LODs entirely — Unity primitives have almost no overhead.

---

## Step 2 — Import into Unity

1. Import all three FBX files into `Assets/`
2. For each: set **Scale Factor** = `1`, **Mesh Compression** = `Off`, click **Apply**

---

## Step 3 — Create the LOD group object

1. Right-click in the Hierarchy → **Create Empty** → rename `Pillar_A`
2. Select it → **Add Component** → `LOD Group`

In the Inspector, you see LOD0, LOD1, LOD2 slots:

3. Click **LOD 0** → click **+ (Add)** → drag the GameObject with `pillar_lod0` mesh renderer into the slot
4. Repeat for LOD 1 (`pillar_lod1`) and LOD 2 (`pillar_lod2`)
5. Add a `MeshCollider` to the LOD0 child (collision is invisible — no need for high-poly colliders)

Adjust the transition thresholds by dragging the sliders in the LOD Group component. A starting point:
- LOD0: 0–40 % of screen height
- LOD1: 40–15 %
- LOD2: 15–5 %
- Culled: < 5 %

---

## Step 4 — Apply LOD groups to repeating objects

Any prop you place more than 4 times is a LOD candidate:
- Stone pillars
- Torch brackets
- Barrels / crates
- Archway segments

Create the LOD Group object once, then **duplicate** it across the room. All instances share the same mesh assets (Unity does not re-upload them per instance).

---

## Step 5 — Wall and floor planes

Wide flat surfaces (Planes, large Cubes) have low poly counts and don't benefit from LODs. Instead, reduce their impact by:

- Splitting one giant 50 m Plane into 4–6 tiles — Unity frustum-culls tiles outside the field of view
- Keeping texture resolution at 512 × 512 for repeating surfaces (tiling handles the detail)

---

## Step 6 — Test performance

1. Export the bundle and load it in-game
2. Move around the room — watch for LOD transitions (they should be invisible in VR)
3. If transitions pop visibly, increase the overlap between LOD thresholds or reduce the poly delta between LOD0 and LOD1

> **VR headsets run at 72–90 Hz with high stereo rendering cost.** A room that runs at 45 FPS on a monitor may feel uncomfortable in VR. Prioritise keeping the draw call count low over maximising visual detail.

---

## LOD budget reference

| Object type | LOD0 triangles | LOD1 triangles | LOD2 triangles |
|---|---|---|---|
| Small prop (barrel, crate) | 300 | 80 | — |
| Medium prop (pillar, statue) | 1 200 | 400 | 100 |
| Large structure (archway, altar) | 3 000 | 800 | 200 |
| Wall segment (5 m section) | — | — | — (no LOD needed) |

---

## Culling — objects that never need LODs

Some objects are always close to the player and never need multiple LOD levels:
- Floor surface
- The player's immediate surroundings (within 5 m of SpawnHere)
- Collision-only objects (invisible triggers, invisible walls)

---

## Summary

| Step | Action |
|---|---|
| 1 | Make LOD meshes in Blender with the Decimate modifier |
| 2 | Import all detail levels into Unity |
| 3 | Create a LOD Group object and assign each level |
| 4 | Use LOD groups on repeating props |
| 5 | Split large flat surfaces into tiles instead of LODs |
| 6 | Test in-game for pop-in and frame rate |
