Files
2nd/10_Wiki/Topics/Domain_Programming/DevOps_and_Security/Geometry Merging.md
T
Antigravity Agent c24165b8bc refactor(topics): 멀티 에이전트용 지식 재편 — _Common(공통 기본기) + Domain_* 구조
에이전트 8종(대화형/프로그래머 C·S/디자이너/설계자/기획자/QA/PD/PM)에게
[공통 기본 능력 + 롤별 Specialty] 2층으로 지식을 주입하기 위한 재분류.
문서 내용·포맷은 무수정, 폴더 이동만 (6,372개 문서 수 보존 확인).

- Topic_Programming → Domain_Programming (내부 구조 보존)
- Topic_Graphic → Domain_Design
- Topic_Business → Domain_Product
- Topic_General → Domain_General
- _Common 신설: Math(구 Topic_Math_Specialty), Reasoning(구 General/From_Thinking & Reasoning),
  Reasoning_Creativity(구 General/From_창의성), Communication(Poetic_Blog_Writing + From_writing)
- 타 도메인의 From_* 폴더는 유지 (출처 표기일 뿐, 이미 도메인에 맞게 분류된 문서)
- 빈 폴더 정리 (memory/procedures)
- 에이전트→폴더 매핑은 workspace의 .astra/agent-knowledge-map.json (9개 에이전트)

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-11 11:05:56 +09:00

4.9 KiB

id, title, category, status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, verification_status, tags, raw_sources, last_reinforced, github_commit, tech_stack
id title category status canonical_id aliases duplicate_of source_trust_level confidence_score verification_status tags raw_sources last_reinforced github_commit tech_stack
wiki-2026-0508-geometry-merging Geometry Merging 10_Wiki/Topics verified self
Mesh Merging
Static Batching
Geometry Batching
none A 0.9 applied
graphics
optimization
rendering
gpu
2026-05-10 pending
language framework
C++/HLSL Unity/Unreal/Three.js

Geometry Merging

매 한 줄

"매 여러 mesh 를 매 단일 vertex/index buffer 로 합쳐 매 draw call 수를 매 줄이는 기법". CPU-GPU command overhead 의 매 frame budget 의 매 dominant share 였던 시대의 매 staple optimization. 매 modern era — GPU instancing, indirect draw, mesh shader 가 매 알 수 있게 대체했지만 매 static scene, mobile, low-end 에서 매 still relevant.

매 핵심

매 종류

  • Static batching: build-time 에 같은 material 의 static mesh 합침.
  • Dynamic batching: runtime 에 small mesh 를 transform & merge (CPU cost ↑).
  • GPU instancing: 같은 mesh 여러 transform — merging 의 modern 대체.
  • Mesh atlas (texture array): material 통합으로 merge 가능 범위 확장.

매 trade-off

  • ↑ Throughput (fewer draw call).
  • ↓ Culling 정확도 (merged AABB 가 매 커짐).
  • ↑ Memory (per-vertex data 의 매 duplication).
  • ↓ Animation flexibility (static 한정).

매 응용

  1. Mobile 게임 — draw call 의 매 hard limit (~100-200).
  2. Architectural visualization — 매 thousands of small props.
  3. Tile-based world streaming.
  4. UI batching (text glyph atlas).

💻 패턴

Manual merge (Three.js)

import { mergeGeometries } from 'three/examples/jsm/utils/BufferGeometryUtils.js';
const geos = props.map(p => p.geometry.clone().applyMatrix4(p.matrixWorld));
const merged = mergeGeometries(geos, false);
const mesh = new THREE.Mesh(merged, sharedMaterial);
scene.add(mesh);
// 1000 draw calls → 1

Unity static batching

// Mark objects as static in Inspector → Unity merges at build time.
// Or runtime:
StaticBatchingUtility.Combine(rootGameObject);
// Caveat: combined mesh 64k vertex 한도 (16-bit index).

GPU instancing (preferred over merge)

// vertex shader (Unity URP)
struct Attributes {
    float3 positionOS : POSITION;
    UNITY_VERTEX_INPUT_INSTANCE_ID
};
UNITY_INSTANCING_BUFFER_START(Props)
    UNITY_DEFINE_INSTANCED_PROP(float4, _Color)
UNITY_INSTANCING_BUFFER_END(Props)

Varyings vert(Attributes IN) {
    UNITY_SETUP_INSTANCE_ID(IN);
    // ...
}

Texture atlas (enable merging across materials)

# Bake separate textures into one atlas → assign UV remap.
import numpy as np
atlas = np.zeros((2048, 2048, 4), np.uint8)
uv_remap = {}
for i, tex in enumerate(textures):
    x, y = (i % 8) * 256, (i // 8) * 256
    atlas[y:y+256, x:x+256] = tex
    uv_remap[i] = (x/2048, y/2048, 256/2048, 256/2048)
# Then rewrite mesh UVs per material id.

Multi-draw indirect (modern alt)

// Instead of merging, keep mesh separate but submit via single indirect call.
struct DrawCmd { uint32_t indexCount, instanceCount, firstIndex, vertexOffset, firstInstance; };
std::vector<DrawCmd> cmds; // one per visible mesh
glMultiDrawElementsIndirect(GL_TRIANGLES, GL_UNSIGNED_INT, cmds.data(), cmds.size(), 0);

Hierarchical merge (octree)

def merge_octree(node):
    if node.is_leaf and len(node.meshes) > 1:
        node.merged = merge(node.meshes)
    else:
        for c in node.children: merge_octree(c)
# Coarse cull on octree node, fine draw merged buffer.

매 결정 기준

상황 Approach
同 mesh 다수 GPU instancing (best)
Static, 多 unique mesh Static merging + atlas
Modern API (Vk/D3D12) Indirect draw + bindless
Mobile / WebGL legacy Static batching + atlas
Animated / dynamic transform Per-object draw + culling

기본값: Modern HW → instancing/indirect. Legacy → static merge + atlas.

🔗 Graph

🤖 LLM 활용

언제: Mobile / web renderer 최적화, asset pipeline 설계. 언제 X: Highly dynamic scenes (animation/destruction).

안티패턴

  • Merge everything: 매 culling 효과 무력화.
  • Material 다른 mesh merge: shader switch 강제 → benefit 없음.
  • Skinned mesh static merge: 매 animation broken.
  • 64k vertex 한계 모름: 16-bit index 의 매 silent overflow.
  • Modern API 에서 merge 만 사용: indirect/instancing 무시.

🧪 검증 / 중복

  • Verified (Unity docs, Three.js BufferGeometryUtils, GPU Pro series).
  • 신뢰도 A.

🕓 Changelog

날짜 변경
2026-05-08 Phase 1
2026-05-10 Manual cleanup — merging vs instancing/indirect 의 trade-off