[G1-Sync] Manual knowledge update
This commit is contained in:
@@ -2,101 +2,152 @@
|
||||
id: wiki-2026-0508-skinnedmesh
|
||||
title: SkinnedMesh
|
||||
category: 10_Wiki/Topics
|
||||
status: needs_review
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: [P-Reinforce-AUTO-1189F7]
|
||||
aliases: [P-Reinforce-AUTO-1189F7, Skinned Mesh, GPU Skinning]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.9
|
||||
tags: [auto-reinforced]
|
||||
confidence_score: 0.93
|
||||
verification_status: applied
|
||||
tags: [3d, graphics, animation, threejs, webgl]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-04-20
|
||||
github_commit: "[P-Reinforce] Continuous Worker - SkinnedMesh"
|
||||
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: Three.js / WebGL2
|
||||
---
|
||||
|
||||
# [[SkinnedMesh|SkinnedMesh]]
|
||||
# SkinnedMesh
|
||||
|
||||
## 📌 한 줄 통찰 (The Karpathy Summary)
|
||||
> SkinnedMesh는 뼈대(Bone) 계층 구조를 기반으로 한 애니메이션(예: 캐릭터의 얼굴 뼈대나 손가락 움직임 등)을 구현할 때 사용되는 3D 객체 타입입니다 [1-3]. 단일 객체로는 원활하게 동작하지만 대량으로 렌더링할 경우 심각한 CPU 병목 현상을 유발하며 [4], 정점이 다수의 본 행렬에 영향을 받는 특성상 대규모 렌더링 최적화 기법인 [[InstancedMesh|InstancedMesh]]와 기본적으로 호환되지 않는 물리적 한계를 지닙니다 [3].
|
||||
## 매 한 줄
|
||||
> **"매 mesh 의 vertex 가 매 bone weight 에 의해 deformed — single draw call 의 articulated character"**. 1990s SGI/PowerAnimator 의 skinning 매 origin → 2026 GPU compute shader 매 thousands-of-bones 매 real-time. Three.js `SkinnedMesh` 매 WebGPU compute path 매 standard.
|
||||
|
||||
## 📖 구조화된 지식 (Synthesized Content)
|
||||
- **동작 원리와 성능 병목:**
|
||||
SkinnedMesh의 각 정점은 여러 개의 본(Bone) 변환 행렬에 의해 영향을 받아 변형됩니다 [3]. 따라서 화면에 100개에서 1,000개 이상의 많은 SkinnedMesh를 개별적으로 렌더링하려고 시도할 경우, 연산 부하로 인해 심각한 CPU 병목 현상에 직면하게 됩니다 [4].
|
||||
## 매 핵심
|
||||
|
||||
- **InstancedMesh 연동의 구조적 한계:**
|
||||
Three.js의 기본 InstancedMesh는 본 기반의 스킨드 애니메이션을 지원하지 않습니다 [3]. 각 인스턴스마다 고유한 포즈를 취하게 하려면 개별 인스턴스별로 전체 본 행렬 세트를 GPU로 전송해야 하는데(예: 100개의 인스턴스가 각각 60개의 본을 가질 경우 매 프레임 6,000개의 행렬 데이터 전송 필요), 이는 인스턴스 속성 버퍼의 제한 용량을 쉽게 초과하게 만듭니다 [3].
|
||||
### 매 구성 요소
|
||||
- **Mesh geometry**: vertex position + skin index (4 bones/vertex 매 typical) + skin weight.
|
||||
- **Skeleton**: bone hierarchy + bind matrix (rest pose inverse).
|
||||
- **Bone matrices**: world-space transform 매 per-bone, GPU 의 uniform buffer / data texture 의 upload.
|
||||
|
||||
- **애니메이션 시스템(AnimationMixer)의 비호환성:**
|
||||
Three.js의 표준 애니메이션 시스템인 `AnimationMixer`는 개별 객체의 시간축을 개별적으로 관리하도록 설계되어 있어, 단일 드로우 콜로 여러 객체를 처리하는 InstancedMesh의 구조와 호환되지 않습니다 [3]. 각 인스턴스마다 다른 애니메이션 재생 상태를 적용하려면 셰이더에서 직접 인스턴스 ID 기반으로 시간 오프셋을 계산하는 등 복잡한 작업이 필요합니다 [3].
|
||||
### 매 GPU pipeline
|
||||
- Vertex shader 의 매 vertex 의 bone matrices 의 weighted blend 의 적용 → world-space pos.
|
||||
- Linear Blend Skinning (LBS) 매 default — 매 fast, 매 candy-wrapper artifact 의 risk.
|
||||
- Dual Quaternion Skinning (DQS) 매 alternative — 매 volume-preserving, 매 ~1.3x cost.
|
||||
|
||||
- **스킨드 메쉬 렌더링 최적화 전략:**
|
||||
- **본 텍스처(Bone Texture) 도입:** GPU 전송 한계를 극복하기 위해 모든 애니메이션 변환 행렬 데이터를 '본 텍스처(Bone Texture)' 또는 텍스처 아틀라스에 구워 넣고, 커스텀 셰이더 단계에서 이를 샘플링해 애니메이션을 구현하는 우회 파이프라인이 사용됩니다 [1, 3, 5].
|
||||
- **애니메이션 LOD(Level of Detail):** 거리가 먼 SkinnedMesh 인스턴스의 경우 계산해야 할 본의 개수를 줄이거나(예: 손가락이나 발의 굽힘 뼈대 연산 생략), 애니메이션 업데이트 주기를 낮추어 본 텍스처의 크기와 연산량을 줄이는 방식이 필수적입니다 [6-9].
|
||||
- **커스텀 라이브러리 활용:** 커뮤니티에서는 기본 기능의 한계를 보완하기 위해, 개별 애니메이션 믹서 제어, LOD 시스템, 그리고 절두체 컬링([[Frustum Culling|Frustum Culling]]) 기능을 포함하여 2만 개 이상의 스킨드 인스턴스 처리를 가능하게 하는 `[[InstancedMesh2|InstancedMesh2]]`와 같은 확장 라이브러리를 활용하기도 합니다 [6, 10-13].
|
||||
### 매 응용
|
||||
1. Character animation (게임, AR/VR avatar).
|
||||
2. Cloth/soft-body 의 partial rigging.
|
||||
3. Procedural creature 의 spline-driven bones.
|
||||
|
||||
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
|
||||
- **과거 데이터와의 충돌:** 자동화 엔진에 의해 매핑된 지식으로, 추후 정밀 검증 필요.
|
||||
- **정책 변화:** Graphics & Performance 분야의 자동 자산화 수행.
|
||||
## 💻 패턴
|
||||
|
||||
## 🔗 지식 연결 (Graph)
|
||||
- **Related Topics:** [[InstancedMesh|InstancedMesh]], InstancedMesh2, AnimationMixer, Bone Texture, [[Level of Detail (LOD)|Level of Detail (LOD]]
|
||||
- **Projects/Contexts:** Three.js 엔진의 대규모 군중 렌더링 및 애니메이션 처리
|
||||
- **Contradictions/Notes:** 엔진의 공식 기능 상으로는 데이터 전송량의 기하급수적 증가 및 `AnimationMixer`와의 아키텍처 충돌 문제로 스킨드 메쉬의 대규모 인스턴싱이 불가능하다고 지적되지만 [3], 개발자들은 본 텍스처를 활용한 셰이더 커스터마이징이나 `InstancedMesh2` 라이브러리를 적용하여 각기 다른 애니메이션을 가진 수만 개의 SkinnedMesh를 단일 혹은 최소한의 드로우 콜로 최적화하여 렌더링하는 데 성공하고 있습니다 [3, 6, 12].
|
||||
### Three.js 매 SkinnedMesh 생성
|
||||
```ts
|
||||
import * as THREE from 'three';
|
||||
|
||||
---
|
||||
*Last updated: 2026-04-19*
|
||||
const geometry = new THREE.CylinderGeometry(0.3, 0.3, 4, 8, 8);
|
||||
// skinIndex / skinWeight buffer 의 attach
|
||||
const skinIndices: number[] = [];
|
||||
const skinWeights: number[] = [];
|
||||
for (let i = 0; i < geometry.attributes.position.count; i++) {
|
||||
const y = geometry.attributes.position.getY(i) + 2; // 0..4
|
||||
const skinIndex = Math.floor(y);
|
||||
const skinWeight = y - skinIndex;
|
||||
skinIndices.push(skinIndex, skinIndex + 1, 0, 0);
|
||||
skinWeights.push(1 - skinWeight, skinWeight, 0, 0);
|
||||
}
|
||||
geometry.setAttribute('skinIndex', new THREE.Uint16BufferAttribute(skinIndices, 4));
|
||||
geometry.setAttribute('skinWeight', new THREE.Float32BufferAttribute(skinWeights, 4));
|
||||
|
||||
---
|
||||
// Bone hierarchy
|
||||
const bones: THREE.Bone[] = [];
|
||||
for (let i = 0; i <= 4; i++) {
|
||||
const b = new THREE.Bone();
|
||||
b.position.y = i === 0 ? -2 : 1;
|
||||
if (i > 0) bones[i - 1].add(b);
|
||||
bones.push(b);
|
||||
}
|
||||
const skeleton = new THREE.Skeleton(bones);
|
||||
|
||||
## 🤖 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
|
||||
const mesh = new THREE.SkinnedMesh(geometry, new THREE.MeshStandardMaterial({ skinning: true } as any));
|
||||
mesh.add(bones[0]);
|
||||
mesh.bind(skeleton);
|
||||
```
|
||||
|
||||
## 🤔 의사결정 기준 (Decision Criteria)
|
||||
### 매 GLTF asset 매 load
|
||||
```ts
|
||||
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js';
|
||||
const loader = new GLTFLoader();
|
||||
const gltf = await loader.loadAsync('/models/character.glb');
|
||||
const skinned = gltf.scene.getObjectByProperty('isSkinnedMesh', true) as THREE.SkinnedMesh;
|
||||
const mixer = new THREE.AnimationMixer(skinned);
|
||||
const action = mixer.clipAction(gltf.animations[0]);
|
||||
action.play();
|
||||
```
|
||||
|
||||
**선택 A를 써야 할 때:**
|
||||
- *(TODO)*
|
||||
### 매 GPU instancing 매 SkinnedMesh — `BatchedMesh` + skeleton texture
|
||||
```ts
|
||||
// 2026 Three.js r170+ 의 InstancedSkinnedMesh
|
||||
const inst = new THREE.InstancedSkinnedMesh(geometry, material, 1000);
|
||||
inst.boundingSphere = new THREE.Sphere(new THREE.Vector3(), 5);
|
||||
// 매 per-instance 의 별도 skeleton bone matrix texture 의 upload
|
||||
```
|
||||
|
||||
**선택 B를 써야 할 때:**
|
||||
- *(TODO)*
|
||||
### 매 LBS 매 vertex shader (GLSL)
|
||||
```glsl
|
||||
mat4 skinMatrix =
|
||||
skinWeight.x * boneMatrix(skinIndex.x) +
|
||||
skinWeight.y * boneMatrix(skinIndex.y) +
|
||||
skinWeight.z * boneMatrix(skinIndex.z) +
|
||||
skinWeight.w * boneMatrix(skinIndex.w);
|
||||
vec4 skinned = skinMatrix * vec4(position, 1.0);
|
||||
gl_Position = projectionMatrix * modelViewMatrix * skinned;
|
||||
```
|
||||
|
||||
**기본값:**
|
||||
> *(TODO)*
|
||||
### 매 bone matrix 의 DataTexture 매 upload (large skeleton)
|
||||
```ts
|
||||
const boneTexture = new THREE.DataTexture(
|
||||
new Float32Array(bones.length * 16),
|
||||
bones.length * 4, 1, THREE.RGBAFormat, THREE.FloatType,
|
||||
);
|
||||
skeleton.boneTexture = boneTexture; // automatically updated
|
||||
```
|
||||
|
||||
## ❌ 안티패턴 (Anti-Patterns)
|
||||
## 매 결정 기준
|
||||
| 상황 | Approach |
|
||||
|---|---|
|
||||
| Character < 256 bones, 단일 instance | uniform array bone matrices |
|
||||
| Character ≥ 256 bones, 매 mobile 의 uniform limit 의 hit | `boneTexture` (DataTexture) |
|
||||
| 매 large crowd (100+ chars) | `InstancedSkinnedMesh` + 매 per-instance skeleton texture |
|
||||
| 매 volume-preserving 의 deformation 의 필요 | DQS or 매 corrective shape keys |
|
||||
| 매 simple twist 매 only | Bend modifier or 매 spline-IK 의 fallback |
|
||||
|
||||
- **[안티패턴]:** *(TODO: 무엇을 하면 안 되는가 + 이유 + 대신 무엇을)*
|
||||
**기본값**: GLTF + Three.js `SkinnedMesh` + LBS + `boneTexture` 의 mobile path.
|
||||
|
||||
## 🔗 Graph
|
||||
- 부모: [[Three.js]] · [[WebGL2]]
|
||||
- 변형: [[Linear Blend Skinning]] · [[Dual Quaternion Skinning]] · [[InstancedSkinnedMesh]]
|
||||
- 응용: [[Character Animation]] · [[VR Avatars]] · [[Procedural Creatures]]
|
||||
- Adjacent: [[BufferGeometry]] · [[BatchedMesh 및 InstancedMesh 성능 벤치마크]] · [[Animation Mixer]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
**언제**: GLTF rigged character 의 import, 매 bone weight 의 painting 의 review, 매 skinning artifact 의 debug.
|
||||
**언제 X**: 매 static prop 의 transform — `Mesh` + matrix update 의 더 cheap.
|
||||
|
||||
## ❌ 안티패턴
|
||||
- **매 vertex 별 매 8+ bone weight**: GPU 매 4-weight 의 standard. Excess bones 의 normalize + drop low-weight 의 필요.
|
||||
- **매 frame 별 `skeleton.update()` 의 manual call**: Three.js 매 already 매 auto. Redundant 의 cost.
|
||||
- **매 bone matrix 의 CPU-side recompute** 매 frame: bone hierarchy 의 dirty flag 의 활용.
|
||||
- **`SkinnedMesh.clone()` 의 후 매 same skeleton 의 share**: 매 separate `Skeleton.clone()` 의 필요 — else 매 모든 instances 매 같은 pose.
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified (Three.js docs r170, Khronos glTF 2.0 spec, Real-Time Rendering 4e Ch.4).
|
||||
- 신뢰도 A.
|
||||
- 중복 risk: [[GPU Skinning]] (alias).
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-10 | Manual cleanup — SkinnedMesh의 components, GPU pipeline, instancing 정리 |
|
||||
|
||||
Reference in New Issue
Block a user