d8a80f6272
이름만 다른(표기 변형) [[위키링크]]를 대상 문서의 canonical 제목으로 치환해 끊겼던 1,200개 링크를 연결. 제목/파일명 정규화 일치만 적용하고 별칭 매칭은 과병합 위험으로 제외(애매성 가드). 원본은 _link_reconcile_backup/ 에 백업. 도구: Datacollect/scripts/link_reconcile_apply.mjs Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
153 lines
4.8 KiB
Markdown
153 lines
4.8 KiB
Markdown
---
|
|
id: wiki-2026-0508-lod
|
|
title: LOD
|
|
category: 10_Wiki/Topics
|
|
status: verified
|
|
canonical_id: self
|
|
aliases: [Level of Detail, Mesh LOD, Mipmap, Nanite]
|
|
duplicate_of: none
|
|
source_trust_level: A
|
|
confidence_score: 0.9
|
|
verification_status: applied
|
|
tags: [3d, graphics, rendering, gamedev, optimization, unreal, unity]
|
|
raw_sources: []
|
|
last_reinforced: 2026-05-10
|
|
github_commit: pending
|
|
tech_stack:
|
|
language: cpp
|
|
framework: unreal
|
|
---
|
|
|
|
# LOD (Level of Detail)
|
|
|
|
## 매 한 줄
|
|
> **"매 멀면 단순, 가까우면 정밀"**. 거리/스크린 사이즈 기반으로 mesh, texture, shader 의 디테일을 단계적으로 낮춰 GPU 비용을 절감. 2026 현재 Unreal **Nanite** 가 mesh LOD 를 자동화하면서 표준이 변하는 중.
|
|
|
|
## 매 핵심
|
|
|
|
### 매 종류
|
|
1. **Mesh LOD (geometric)**: 폴리곤 수 다르게 (LOD0=원본, LOD3=단순화).
|
|
2. **Texture LOD (mipmap)**: 1/2, 1/4, 1/8 ... 미리 down-sample.
|
|
3. **Shader LOD**: 거리 따라 PBR → unlit, 그림자 off.
|
|
4. **Imposter / Billboard**: 매우 멀면 평면에 렌더된 이미지.
|
|
5. **Virtualized geometry (Nanite)**: per-pixel cluster 선택, 명시적 LOD 불필요.
|
|
|
|
### 매 전환 기준
|
|
- 화면 면적 (screen-space pixel size).
|
|
- 거리 (camera 와 object).
|
|
- 시야각 / fov.
|
|
- Hysteresis (왔다갔다 깜빡임 방지).
|
|
|
|
### 매 알고리즘
|
|
- Mesh 단순화: **Quadric Edge Collapse** (Garland-Heckbert), Meshoptimizer.
|
|
- Mipmap 생성: trilinear, anisotropic.
|
|
- HLOD: 멀리 있는 여러 object 를 하나의 mesh 로 합침.
|
|
|
|
## 💻 패턴
|
|
|
|
### Unity LODGroup
|
|
```csharp
|
|
var lodGroup = gameObject.AddComponent<LODGroup>();
|
|
LOD[] lods = new LOD[] {
|
|
new LOD(0.6f, new[] { lod0Renderer }), // > 60% screen
|
|
new LOD(0.3f, new[] { lod1Renderer }),
|
|
new LOD(0.1f, new[] { lod2Renderer }),
|
|
new LOD(0.01f, new[] { billboardRenderer }),
|
|
};
|
|
lodGroup.SetLODs(lods);
|
|
lodGroup.RecalculateBounds();
|
|
```
|
|
|
|
### Unreal: StaticMesh LOD 자동 생성
|
|
```cpp
|
|
// Editor 에서: StaticMesh -> LOD Settings -> Auto Compute
|
|
// 또는 Python:
|
|
mesh.set_editor_property("lod_group", "LargeProp")
|
|
mesh.build_from_mesh_descriptions(lod_descs)
|
|
```
|
|
|
|
### meshoptimizer (cross-engine)
|
|
```cpp
|
|
#include "meshoptimizer.h"
|
|
size_t target = (size_t)(index_count * 0.25f); // 25%
|
|
float error;
|
|
size_t new_count = meshopt_simplify(
|
|
new_indices, indices, index_count,
|
|
&vertices[0].x, vertex_count, sizeof(Vertex),
|
|
target, /*target_error*/ 0.05f, /*options*/ 0, &error);
|
|
```
|
|
|
|
### Three.js LOD
|
|
```javascript
|
|
import { LOD, Mesh } from "three";
|
|
const lod = new LOD();
|
|
lod.addLevel(meshHigh, 0);
|
|
lod.addLevel(meshMid, 50);
|
|
lod.addLevel(meshLow, 200);
|
|
lod.addLevel(billboard, 500);
|
|
scene.add(lod);
|
|
// 매 프레임 자동 update from camera distance
|
|
```
|
|
|
|
### Mipmap 생성 (GL)
|
|
```cpp
|
|
glBindTexture(GL_TEXTURE_2D, tex);
|
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixels);
|
|
glGenerateMipmap(GL_TEXTURE_2D);
|
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
|
|
```
|
|
|
|
### Distance-based shader LOD (HLSL pseudo)
|
|
```hlsl
|
|
float dist = length(WorldPos - CameraPos);
|
|
if (dist < 50) col = FullPBR(...);
|
|
else if (dist < 200) col = SimplifiedPBR(...);
|
|
else col = AlbedoOnly(...);
|
|
```
|
|
|
|
### Hysteresis 적용
|
|
```csharp
|
|
float threshold = 50f;
|
|
float hyst = 5f;
|
|
if (state == LOD0 && dist > threshold + hyst) state = LOD1;
|
|
else if (state == LOD1 && dist < threshold - hyst) state = LOD0;
|
|
```
|
|
|
|
## 매 결정 기준
|
|
| 시나리오 | 전략 |
|
|
|---|---|
|
|
| 오픈월드 무수한 풀/돌 | HLOD + imposter |
|
|
| 캐릭터 (animation 있음) | manual LOD0-2, skinning weight 보존 |
|
|
| Unreal 5 hi-poly | Nanite (자동) |
|
|
| 모바일 | 적극적 LOD + mipmap, draw call 우선 |
|
|
| VR (스테레오) | 양 눈 모두 비싸니 LOD 더 공격적 |
|
|
|
|
**기본값**: Unreal 5 → Nanite 켜고 끝. 다른 엔진 → mesh LOD 3-4단계 + mipmap.
|
|
|
|
## 🔗 Graph
|
|
- 변형: [[Nanite]], [[Mipmap]]
|
|
- 응용: [[VR]]
|
|
- Adjacent: [[Frustum Culling]], [[Mesh-Simplification]]
|
|
|
|
## 🤖 LLM 활용
|
|
**언제**: 폴리곤 많은 scene, 모바일/VR, 카메라 distance 변화 큼, 같은 prop 다수 instancing.
|
|
**언제 X**: UI/2D, scene 전체가 가까운 카메라 (LOD 전환 안 일어남).
|
|
|
|
## ❌ 안티패턴
|
|
- **LOD 전환 popping**: 단계 차이 크고 hysteresis 없음 → 깜빡거림.
|
|
- **Skinning 메쉬 강제 단순화**: deformation 깨짐, 캐릭터는 수작업.
|
|
- **Mipmap off**: aliasing + bandwidth 폭증.
|
|
- **너무 많은 LOD level**: 메모리 낭비, 4단계 정도가 sweet spot.
|
|
- **Nanite 인 척하면서 모든 mesh translucent**: Nanite 는 opaque 위주.
|
|
|
|
## 🧪 검증 / 중복
|
|
- Unreal 5 Nanite docs, Unity LODGroup, meshoptimizer (zeux).
|
|
- Garland & Heckbert 1997 (Quadric Error Metrics).
|
|
- 신뢰도 A.
|
|
|
|
## 🕓 Changelog
|
|
| 날짜 | 변경 |
|
|
|---|---|
|
|
| 2026-05-08 | Phase 1 |
|
|
| 2026-05-10 | Manual cleanup — Nanite 반영, Unity/Unreal/Three.js/meshopt 패턴 |
|