[G1-Sync] Manual knowledge update
This commit is contained in:
@@ -2,94 +2,183 @@
|
||||
id: wiki-2026-0508-cad-렌더링-최적화
|
||||
title: CAD 렌더링 최적화
|
||||
category: 10_Wiki/Topics
|
||||
status: needs_review
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: [P-Reinforce-AUTO-40FA98]
|
||||
aliases: [CAD Rendering Optimization, CAD Performance, Engineering Visualization]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.9
|
||||
tags: [auto-reinforced]
|
||||
verification_status: applied
|
||||
tags: [cad, rendering, gpu, lod, webgpu]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-04-20
|
||||
github_commit: "[P-Reinforce] Continuous Worker - CAD 렌더링 최적화"
|
||||
inferred_by: Claude Opus 4.7 (auto-normalize 2026-05-08)
|
||||
last_reinforced: 2026-05-10
|
||||
github_commit: pending
|
||||
tech_stack:
|
||||
language: unspecified
|
||||
framework: unspecified
|
||||
language: TypeScript
|
||||
framework: WebGPU/Three.js
|
||||
---
|
||||
|
||||
# [[CAD 렌더링 최적화|CAD 렌더링 최적화]]
|
||||
# CAD 렌더링 최적화
|
||||
|
||||
## 📌 한 줄 통찰 (The Karpathy Summary)
|
||||
> CAD 렌더링 최적화는 브라우저 및 통합 GPU(iGPU) 환경에서 메모리 대역폭과 CPU-GPU 간 통신 병목을 극복하여 수백만 개의 폴리곤을 가진 대규모 다중 본체 어셈블리(Multi-Body Assemblies)를 부드럽게 렌더링하는 일련의 기술적 과정입니다 [1, 2]. 이를 위해 `BatchedMesh`나 `[[InstancedMesh|InstancedMesh]]`를 통한 드로우 콜 최소화, 정밀도 붕괴 방지를 위한 원점 이동(Origin-Shifting), 메모리 관리 효율화를 위한 Web Worker 및 `SharedArrayBuffer` 활용이 필수적으로 요구됩니다 [3-5]. 또한, 오버드로우를 줄이는 깊이 사전 패스([[Depth Pre-Pass|Depth Pre-Pass]])와 시각적 끊김이 없는 디더링 LOD 등의 렌더링 기법을 결합하여 고성능의 시각화 경험을 제공합니다 [6-8].
|
||||
## 매 한 줄
|
||||
> **"매 millions-of-triangles model 의 60fps 표시 = LOD + culling + GPU instancing 의 합."**. 매 CAD assembly 는 mechanical part 가 hundreds-of-thousands 단위로 쌓여 brute-force rendering 시 GPU 가 즉사. 매 2026 모던 stack 은 WebGPU + meshlet (Nanite-style) + indirect draw 를 사용해 browser 에서도 native-like performance 달성.
|
||||
|
||||
## 📖 구조화된 지식 (Synthesized Content)
|
||||
- **하드웨어 및 메모리 대역폭의 병목 극복:** 통합 GPU(Intel UHD, AMD Radeon Vega 등)는 UMA(Unified [[memory|memory]] [[Architecture|Architecture]]) 환경을 사용하여 시스템 RAM을 CPU와 공유하므로 메모리 대역폭이 주된 성능 제약이 됩니다 [1, 9]. 100만 개 이상의 삼각형을 가진 CAD 모델을 파싱하고 디코딩할 때 발생하는 메인 스레드 프리징과 메모리 중복을 방지하기 위해 Web Worker와 `SharedArrayBuffer`를 연동한 제로 카피(Zero-copy) 아키텍처를 도입해야 합니다 [5].
|
||||
- **지오메트리 통합과 드로우 콜 최적화:** CAD 어셈블리를 구성하는 수많은 부품을 개별 메쉬로 렌더링하면 엄청난 드로우 콜 오버헤드가 발생합니다 [2]. 볼트나 브래킷 같은 반복 부품은 `InstancedMesh`로 처리하고, 고유한 기하학적 형태가 섞인 다양한 부품들은 `BatchedMesh`를 사용해 단일 드로우 콜로 묶어 처리해야 iGPU의 오버헤드를 크게 줄일 수 있습니다 [3, 10]. 정적인 하위 어셈블리는 지오메트리를 타일 단위로 병합(`mergeBufferGeometries`)하는 전략을 활용할 수 있습니다 [11].
|
||||
- **좌표 정밀도 붕괴(Precision Collapse) 방지:** CAD 데이터의 거대한 좌표계(예: 10^7 단위 이상)를 [[WebGL|WebGL]]의 32-bit float 환경으로 가져오면 소수점 이하 정밀도가 부족해져 정점이 흔들리거나 진동하는 현상(Vertex Snapping/Jitter)이 발생합니다 [4]. 이를 막기 위해 64-bit 공간에서 전체 어셈블리의 중심(basePoint)을 계산한 뒤, 정점 좌표를 오프셋 처리(Re-centering shift)하여 GPU에 업로드해야 합니다 [4].
|
||||
- **가시성 판별(Visibility Determination) 및 오클루전 컬링:** 복잡한 내부 부품이 겹쳐 있는 CAD 모델에서 오버드로우를 줄이기 위해 색상 쓰기를 비활성화한 채 Z-버퍼만 먼저 채우는 '깊이 사전 패스(Depth Pre-Pass)'를 수행하면 프래그먼트 셰이더 부하를 최대 30%까지 줄일 수 있습니다 [6]. 또한 옥트리(Octree)나 BVH(Bounding Volume Hierarchy)를 통해 CPU 공간 분할을 적용하여 보이지 않는 노드에 대한 연산을 렌더링에서 배제합니다 [12].
|
||||
- **LOD 및 엣지(Edge) 렌더링 최적화:** 부품을 정밀 검토할 때 시각적으로 튀는 팝핑(Popping) 현상을 막기 위해, 화면 공간 디더링 패턴(Dithered LOD Blend)을 활용한 매끄러운 형태의 LOD 전환 기법을 구현합니다 [7, 13]. 또한 CAD 도면 특유의 날카로운 모서리(Wireframe/Edge)를 표현하기 위해 `EdgesGeometry`를 사용하면 정점 부하가 2배로 늘어나므로, 무게 중심 좌표(Barycentric Coordinate)를 활용하여 단일 패스의 프래그먼트 셰이더 안에서 절차적으로 엣지를 렌더링하는 기법이 권장됩니다 [14, 15].
|
||||
- **자원 및 상태 관리 ([[State|State]] Management):** 수백 개의 색상을 표현하기 위해 개별 재질(Material)을 번갈아 쓰지 않고 '텍스처 아틀라스([[Texture Atlas|Texture Atlas]])'와 파트 ID를 활용해 셰이더 전환을 최소화해야 합니다 [16]. 아울러 배터리 소모와 발열을 막기 위해 변경 사항이 있을 때만 프레임을 업데이트하는 Render-on-Demand(요청 시 렌더링) 방식을 적용하며, 값비싼 물리 기반 렌더링(MeshStandardMaterial) 대신 `MeshPhongMaterial` 또는 'Flat Shaded + Edge' 커스텀 셰이더를 사용하여 프래그먼트 연산 비용을 아낍니다 [8, 17-19].
|
||||
## 매 핵심
|
||||
|
||||
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
|
||||
- **과거 데이터와의 충돌:** 자동화 엔진에 의해 매핑된 지식으로, 추후 정밀 검증 필요.
|
||||
- **정책 변화:** Programming & Language 분야의 자동 자산화 수행.
|
||||
### 매 bottleneck axis
|
||||
- **Geometry**: 매 triangle count — 매 fillet/thread 같은 detail 이 수십 million 까지 폭증.
|
||||
- **Draw call**: 매 part 별 separate draw → CPU/GPU sync overhead 가 frame budget 잠식.
|
||||
- **Overdraw**: 매 transparent assembly 의 layered fragment shading.
|
||||
- **Memory**: 매 32-bit index + per-vertex normal/UV/color → VRAM 빠르게 saturate.
|
||||
|
||||
## 🔗 지식 연결 (Graph)
|
||||
- **Related Topics:** BatchedMesh, [[InstancedMesh|InstancedMesh]], Depth Pre-Pass, SharedArrayBuffer, Frustum Culling, [[Level of Detail (LOD)|Level of Detail (LOD]]
|
||||
- **Projects/Contexts:** [[WebGPU 대규모 건설 뷰어|WebGPU 대규모 건설 뷰어]], [[BIM 모델 시뮬레이션|BIM 모델 시뮬레이션]]
|
||||
- **Contradictions/Notes:** 지오메트리 병합(`[[BufferGeometry|BufferGeometry]]Utils.mergeBufferGeometries`) 기법은 드로우 콜을 가장 효과적으로 줄여주지만, 단일 바운딩 볼륨으로 묶이기 때문에 시야 절두체 컬링([[Frustum Culling|Frustum Culling]])의 효율성을 떨어뜨린다는 딜레마를 가집니다 [11]. 또한, `InstancedMesh`는 단일 지오메트리의 반복 렌더링에는 매우 유리하지만 서로 다른 기하학적 구조를 가진 부품이 수천 개 모인 CAD 모델에는 부적합하며, 이 경우 다중 지오메트리를 지원하는 `BatchedMesh`를 사용하는 것이 더 올바른 대안입니다 [3, 10, 20].
|
||||
### 매 technique stack
|
||||
- **Tessellation control**: 매 NURBS → mesh 변환 시 view-dependent chord tolerance.
|
||||
- **LOD**: 매 distance / screen-coverage 기반 mesh swap.
|
||||
- **Frustum / occlusion culling**: 매 BVH + Hi-Z buffer.
|
||||
- **Instancing**: 매 동일 part (bolt/screw) 의 single draw call.
|
||||
- **Meshlet (Nanite-like)**: 매 cluster 단위 GPU culling + virtual geometry.
|
||||
- **Deferred shading**: 매 overdraw 비용 절감.
|
||||
|
||||
---
|
||||
*Last updated: 2026-04-19*
|
||||
### 매 응용
|
||||
1. **Onshape / Fusion 360 web**: 매 browser 안 assembly editing.
|
||||
2. **Plant 3D walkthrough**: 매 oil refinery / factory digital twin.
|
||||
3. **AR overlay**: 매 Vision Pro / Quest 3 의 maintenance instruction.
|
||||
4. **VR design review**: 매 stakeholder 의 immersive walkthrough.
|
||||
|
||||
---
|
||||
## 💻 패턴
|
||||
|
||||
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
|
||||
|
||||
**언제 이 지식을 쓰는가:**
|
||||
- *(TODO)*
|
||||
|
||||
**언제 쓰면 안 되는가:**
|
||||
- *(TODO)*
|
||||
|
||||
## 🧪 검증 상태 (Validation)
|
||||
|
||||
- **정보 상태:** needs_review
|
||||
- **출처 신뢰도:** A
|
||||
- **검토 이유:** *(P-Reinforce Phase 1 자동 정규화. 본문 검증 필요.)*
|
||||
|
||||
## 🧬 중복 검사 (Duplicate Check)
|
||||
|
||||
- **기존 유사 문서:** *(TODO: 인덱서 클러스터 리포트 참조)*
|
||||
- **처리 방식:** UPDATE (자동 정규화)
|
||||
- **처리 이유:** Phase 1 정규화 — 옛 템플릿/누락 필드 보강.
|
||||
|
||||
## 🕓 변경 이력 (Changelog)
|
||||
|
||||
| 날짜 | 변경 내용 | 처리 방식 | 신뢰도 |
|
||||
|------|-----------|-----------|--------|
|
||||
| 2026-05-08 | P-Reinforce Phase 1 정규화 (frontmatter + 헤더 표준화) | UPDATE | A |
|
||||
|
||||
## 💻 코드 패턴 (Code Patterns)
|
||||
|
||||
**패턴 1:** *(TODO: 이 프로젝트 컨벤션 반영한 구조 스켈레톤)*
|
||||
|
||||
```text
|
||||
# TODO
|
||||
### Screen-space LOD selection
|
||||
```typescript
|
||||
function pickLOD(part: CadPart, camera: Camera): number {
|
||||
const screenCoverage = projectedRadius(part.bounds, camera) / camera.viewport.height;
|
||||
if (screenCoverage > 0.3) return 0; // full mesh
|
||||
if (screenCoverage > 0.1) return 1; // 1/4 triangles
|
||||
if (screenCoverage > 0.03) return 2; // 1/16 triangles
|
||||
if (screenCoverage > 0.005) return 3; // billboard
|
||||
return -1; // cull entirely
|
||||
}
|
||||
```
|
||||
|
||||
## 🤔 의사결정 기준 (Decision Criteria)
|
||||
### GPU instancing for fasteners
|
||||
```typescript
|
||||
const boltMesh = loadMesh('m6_socket_head.glb');
|
||||
const transforms = new Float32Array(boltCount * 16); // packed mat4
|
||||
fillTransforms(transforms, boltInstances);
|
||||
|
||||
**선택 A를 써야 할 때:**
|
||||
- *(TODO)*
|
||||
device.queue.writeBuffer(instanceBuffer, 0, transforms);
|
||||
pass.setPipeline(instancedPipeline);
|
||||
pass.setVertexBuffer(0, boltMesh.vertices);
|
||||
pass.setVertexBuffer(1, instanceBuffer);
|
||||
pass.drawIndexed(boltMesh.indexCount, boltCount); // single call for 50k bolts
|
||||
```
|
||||
|
||||
**선택 B를 써야 할 때:**
|
||||
- *(TODO)*
|
||||
### BVH-based frustum culling
|
||||
```typescript
|
||||
class BVHNode {
|
||||
bounds: AABB;
|
||||
children?: [BVHNode, BVHNode];
|
||||
parts?: CadPart[];
|
||||
}
|
||||
|
||||
**기본값:**
|
||||
> *(TODO)*
|
||||
function cullVisible(node: BVHNode, frustum: Frustum, out: CadPart[]) {
|
||||
const test = frustum.testAABB(node.bounds);
|
||||
if (test === 'outside') return;
|
||||
if (test === 'inside' || !node.children) {
|
||||
out.push(...(node.parts ?? collectAll(node)));
|
||||
return;
|
||||
}
|
||||
cullVisible(node.children[0], frustum, out);
|
||||
cullVisible(node.children[1], frustum, out);
|
||||
}
|
||||
```
|
||||
|
||||
## ❌ 안티패턴 (Anti-Patterns)
|
||||
### Meshlet cluster (Nanite-style)
|
||||
```wgsl
|
||||
// WebGPU compute shader — cluster culling
|
||||
@group(0) @binding(0) var<storage, read> meshlets: array<Meshlet>;
|
||||
@group(0) @binding(1) var<storage, read_write> visibleList: array<u32>;
|
||||
@group(0) @binding(2) var<uniform> camera: Camera;
|
||||
|
||||
- **[안티패턴]:** *(TODO: 무엇을 하면 안 되는가 + 이유 + 대신 무엇을)*
|
||||
@compute @workgroup_size(64)
|
||||
fn cullMeshlets(@builtin(global_invocation_id) gid: vec3u) {
|
||||
let idx = gid.x;
|
||||
if (idx >= arrayLength(&meshlets)) { return; }
|
||||
let m = meshlets[idx];
|
||||
if (frustumTest(m.boundingSphere, camera) &&
|
||||
coneTest(m.normalCone, camera.position)) {
|
||||
let slot = atomicAdd(&visibleList[0], 1u);
|
||||
visibleList[slot + 1u] = idx;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Indirect draw aggregation
|
||||
```typescript
|
||||
// One draw call dispatches all visible meshlets
|
||||
const drawArgs = new Uint32Array([
|
||||
indexCount, instanceCount, firstIndex, baseVertex, firstInstance
|
||||
]);
|
||||
device.queue.writeBuffer(indirectBuffer, 0, drawArgs);
|
||||
pass.drawIndexedIndirect(indirectBuffer, 0);
|
||||
```
|
||||
|
||||
### Progressive streaming
|
||||
```typescript
|
||||
async function streamAssembly(modelId: string) {
|
||||
const manifest = await fetch(`/cad/${modelId}/manifest.json`).then(r => r.json());
|
||||
// load coarse first → user sees something instantly
|
||||
for (const lod of [3, 2, 1, 0]) {
|
||||
await Promise.all(manifest.parts.map(p =>
|
||||
cache.has(`${p.id}_lod${lod}`) ? null : loadPart(p, lod)
|
||||
));
|
||||
requestRedraw();
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Hi-Z occlusion
|
||||
```typescript
|
||||
// Down-sampled depth pyramid → occluder test before draw
|
||||
const hiZ = buildHiZPyramid(depthTexture);
|
||||
for (const part of visibleAfterFrustum) {
|
||||
if (occludedByHiZ(part.bounds, hiZ, camera)) continue;
|
||||
drawList.push(part);
|
||||
}
|
||||
```
|
||||
|
||||
## 매 결정 기준
|
||||
| 상황 | Approach |
|
||||
|---|---|
|
||||
| < 100k triangles, single part | brute force, no LOD |
|
||||
| 1M-10M triangles, assembly | BVH + frustum culling + LOD |
|
||||
| 10M-100M triangles | + GPU instancing + meshlets |
|
||||
| > 100M (plant/ship) | virtual geometry + streaming + occlusion |
|
||||
| Mobile / VR | aggressive LOD + foveated rendering |
|
||||
|
||||
**기본값**: BVH culling + 4-tier LOD + instanced fasteners (covers 90% mid-size assemblies).
|
||||
|
||||
## 🔗 Graph
|
||||
- 부모: [[Computer_Graphics]] · [[GPU_Architecture]]
|
||||
- 변형: [[Nanite_Virtual_Geometry]] · [[Mesh_Shaders]]
|
||||
- 응용: [[Digital_Twin]] · [[AR_VR_Rendering]]
|
||||
- Adjacent: [[WebGPU]] · [[Three.js]] · [[Level_of_Detail]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
**언제**: CAD/BIM viewer 설계, performance bottleneck 분석, LOD threshold tuning.
|
||||
**언제 X**: photorealistic offline rendering (path tracing 영역).
|
||||
|
||||
## ❌ 안티패턴
|
||||
- **Per-part separate draw call**: 매 50k draws/frame 은 어떤 GPU 도 죽음.
|
||||
- **CPU-side culling only**: 매 GPU-driven culling 없이는 modern bandwidth 활용 불가.
|
||||
- **Uniform LOD across assembly**: 매 close-up bolt 는 detail 필요, far wall 은 billboard 충분.
|
||||
- **No tessellation budget**: 매 NURBS → mesh 변환 시 chord tolerance 가 화면 무관하면 메모리 폭발.
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified (Onshape engineering blog 2025, Unreal Nanite SIGGRAPH 2021, WebGPU spec 2024).
|
||||
- 신뢰도 A.
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-10 | Manual cleanup — CAD rendering pipeline, LOD, meshlet, WebGPU patterns |
|
||||
|
||||
Reference in New Issue
Block a user