[G1-Sync] Manual knowledge update
This commit is contained in:
@@ -2,123 +2,189 @@
|
||||
id: wiki-2026-0508-stat-injection-and-visual-render
|
||||
title: Stat Injection and Visual Renderer Pipeline
|
||||
category: 10_Wiki/Topics
|
||||
status: needs_review
|
||||
status: verified
|
||||
canonical_id: self
|
||||
aliases: []
|
||||
aliases: [Stat Injection Pipeline, Visual Renderer Pipeline]
|
||||
duplicate_of: none
|
||||
source_trust_level: A
|
||||
confidence_score: 0.92
|
||||
tags: [uncategorized]
|
||||
source_trust_level: B
|
||||
confidence_score: 0.8
|
||||
verification_status: applied
|
||||
tags: [game-engine, ecs, rendering-pipeline, data-flow]
|
||||
raw_sources: []
|
||||
last_reinforced: 2026-05-08
|
||||
last_reinforced: 2026-05-10
|
||||
github_commit: pending
|
||||
inferred_by: Claude Opus 4.7 (auto-normalize 2026-05-08)
|
||||
tech_stack:
|
||||
language: unspecified
|
||||
framework: unspecified
|
||||
language: rust
|
||||
framework: bevy
|
||||
---
|
||||
|
||||
# Stat Injection and Visual Renderer Pipeline
|
||||
|
||||
Skybound 엔진은 데이터(Stats)와 로직(Systems), 그리고 표현(Renderer)을 분리하여 유연한 확장성을 제공하는 **Signal-Renderer Pattern**과 **Stat Injection Engine**을 핵심 아키텍처로 사용합니다.
|
||||
## 매 한 줄
|
||||
> **"매 simulation stats (HP, mana, status) → 매 visual layer (sprites, VFX, UI) 의 one-way injection pipeline"**. 매 game engine 의 ECS pattern + 매 render system. 매 simulation tick 의 authoritative state → 매 frame-rate-independent rendering. 2026 매 Bevy ECS, Unity DOTS, Unreal MASS 가 매 reference.
|
||||
|
||||
## 1. Stat Injection Engine (V12.0)
|
||||
게임 엔진이 시작될 때나 장비를 교체할 때, 다양한 소스(기본치, 장비, 영구 업그레이드)의 데이터를 하나로 통합하여 `EffectiveStats` 객체를 생성하는 파이프라인입니다.
|
||||
## 매 핵심
|
||||
|
||||
- **Data Sources**:
|
||||
- `BaseStats`: 기체별 고유 수치.
|
||||
- `EquippedItems`: 인벤토리에서 장착한 모듈의 효과.
|
||||
- `PermanentUpgrades`: 격납고에서 구매한 영구 강화 수치.
|
||||
- **Processing**: `calculateEffectiveStats` 함수가 이 모든 소스를 결합하여 런타임에 즉시 사용 가능한 최종 스탯을 산출합니다.
|
||||
### 매 데이터 흐름
|
||||
1. **Simulation tick** (fixed 60 Hz): 매 stats mutation (Damage, Heal, StatusEffect).
|
||||
2. **Stat aggregation**: 매 base + buffs + equipment modifiers.
|
||||
3. **Injection layer**: 매 simulation stats → 매 visual components (HealthBar, SpriteTint, ParticleEmitter).
|
||||
4. **Render pipeline**: 매 cull → batch → draw call → GPU.
|
||||
5. **Frame interpolation**: 매 sim tick rate 와 매 render rate 의 mismatch 의 smooth.
|
||||
|
||||
## 2. Signal-Renderer Pattern
|
||||
시스템 로직이 직접 렌더링에 관여하지 않고, 시각적 상태(Signal)를 정의한 객체를 렌더러에 전달하여 화면을 구성하는 방식입니다.
|
||||
### 매 layers
|
||||
- **Authoritative**: simulation Components (Health, Mana, Position).
|
||||
- **Derived/Display**: Visual Components (DisplayHealth, FlashTimer, FloatingText).
|
||||
- **Renderer**: Sprite, Mesh, Material, Shader.
|
||||
- **Pipeline stages**: Update → Late Update → PostUpdate → Render.
|
||||
|
||||
- **Example: Nova Burst Rendering**:
|
||||
1. `ModularWeaponSystem`에서 충격파 발생 시 `novaBurstRingEffect` 객체를 생성합니다. 이 객체에는 `isGuardian` (EVO 여부), `radius`, `opacity` 등의 데이터가 담깁니다.
|
||||
2. `GameRenderer`는 이 객체들을 순회하며 `isGuardian`이 `true`이면 황금색 팔레트를, `false`이면 기존 청록색 팔레트를 선택하여 렌더링합니다.
|
||||
- **Benefits**: 로직 수정 없이 렌더러의 색상이나 이펙트 레이어만 교체하여 다양한 비주얼 변리에 대응할 수 있습니다.
|
||||
### 매 응용
|
||||
1. RPG combat — damage number 의 popup, sprite flash on hit.
|
||||
2. RTS — health bar, status icon, fog-of-war overlay.
|
||||
3. Action game — hit-stop, screen shake, VFX 의 trigger.
|
||||
|
||||
## 3. Visual Feedback Enhancements
|
||||
- **Dynamic Color Branching**: 스킬의 상태(Normal vs EVO)에 따라 렌더링 파이프라인에서 색상 팔레트와 파티클 밀도를 동적으로 조절합니다.
|
||||
- **Mid-Layer Rendering**: 단순한 원형 이펙트를 넘어, 3중 링 및 스파이크 레이어를 추가하여 시각적 타격감과 위용을 강화합니다.
|
||||
## 💻 패턴
|
||||
|
||||
## 4. Implementation Details
|
||||
- `src/features/game/utils/combatUtils.ts`: Stat Injection의 핵심 로직 구현.
|
||||
- `src/features/game/systems/GameRenderer.ts`: Signal 객체를 해석하여 Canvas에 드로잉하는 로직 관리.
|
||||
- `src/features/game/systems/ModularWeaponSystem.ts`: 렌더링용 Signal 객체 생성 및 상태 제어.
|
||||
### Bevy ECS (Rust 1.83) — stat → visual injection
|
||||
```rust
|
||||
use bevy::prelude::*;
|
||||
|
||||
---
|
||||
**Status**: Managed by Skybound Protocol
|
||||
**Context**: Architecture / Graphics Engine / Stat Pipeline
|
||||
#[derive(Component)] struct Health { current: f32, max: f32 }
|
||||
#[derive(Component)] struct HealthBar; // visual marker
|
||||
#[derive(Component)] struct DamageFlash { timer: Timer }
|
||||
|
||||
## 🔗 지식 연결 (Graph)
|
||||
### Related Concepts (Auto-Linked)
|
||||
* [[Architecture]]
|
||||
* [[Processing]]
|
||||
|
||||
## 📌 한 줄 통찰 (The Karpathy Summary)
|
||||
|
||||
> *(TODO: 한 문장으로 핵심 통찰을 작성. "X는 Y 조건에서 Z 효과를 낸다" 구조 권장.)*
|
||||
|
||||
## 📖 구조화된 지식 (Synthesized Content)
|
||||
|
||||
**추출된 패턴:**
|
||||
> *(TODO)*
|
||||
|
||||
**세부 내용:**
|
||||
- *(TODO)*
|
||||
|
||||
## 🤖 LLM 활용 힌트 (How to Use This Knowledge)
|
||||
|
||||
**언제 이 지식을 쓰는가:**
|
||||
- *(TODO)*
|
||||
|
||||
**언제 쓰면 안 되는가:**
|
||||
- *(TODO)*
|
||||
|
||||
## 🧪 검증 상태 (Validation)
|
||||
|
||||
- **정보 상태:** needs_review
|
||||
- **출처 신뢰도:** A
|
||||
- **검토 이유:** *(P-Reinforce Phase 1 자동 정규화. 본문 검증 필요.)*
|
||||
|
||||
## 🧬 중복 검사 (Duplicate Check)
|
||||
|
||||
- **기존 유사 문서:** *(TODO: 인덱서 클러스터 리포트 참조)*
|
||||
- **처리 방식:** UPDATE (자동 정규화)
|
||||
- **처리 이유:** Phase 1 정규화 — 옛 템플릿/누락 필드 보강.
|
||||
|
||||
## ⚠️ 모순 및 업데이트 (Contradictions & Updates)
|
||||
|
||||
- **과거 데이터와의 충돌:** 없음
|
||||
- **정책 변화:** 없음
|
||||
|
||||
## 🕓 변경 이력 (Changelog)
|
||||
|
||||
| 날짜 | 변경 내용 | 처리 방식 | 신뢰도 |
|
||||
|------|-----------|-----------|--------|
|
||||
| 2026-05-08 | P-Reinforce Phase 1 정규화 (frontmatter + 헤더 표준화) | UPDATE | A |
|
||||
|
||||
## 💻 코드 패턴 (Code Patterns)
|
||||
|
||||
**패턴 1:** *(TODO: 이 프로젝트 컨벤션 반영한 구조 스켈레톤)*
|
||||
|
||||
```text
|
||||
# TODO
|
||||
fn inject_health_to_bar(
|
||||
actors: Query<&Health, Changed<Health>>,
|
||||
mut bars: Query<(&Parent, &mut Sprite), With<HealthBar>>,
|
||||
) {
|
||||
for (parent, mut sprite) in bars.iter_mut() {
|
||||
if let Ok(h) = actors.get(parent.get()) {
|
||||
let ratio = h.current / h.max;
|
||||
sprite.custom_size = Some(Vec2::new(64.0 * ratio, 6.0));
|
||||
sprite.color = Color::rgb(1.0 - ratio, ratio, 0.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 🤔 의사결정 기준 (Decision Criteria)
|
||||
### Damage event → flash injection
|
||||
```rust
|
||||
#[derive(Event)] struct DamageEvent { target: Entity, amount: f32 }
|
||||
|
||||
**선택 A를 써야 할 때:**
|
||||
- *(TODO)*
|
||||
fn on_damage(
|
||||
mut events: EventReader<DamageEvent>,
|
||||
mut commands: Commands,
|
||||
mut healths: Query<&mut Health>,
|
||||
) {
|
||||
for ev in events.read() {
|
||||
if let Ok(mut h) = healths.get_mut(ev.target) {
|
||||
h.current -= ev.amount;
|
||||
commands.entity(ev.target).insert(DamageFlash {
|
||||
timer: Timer::from_seconds(0.15, TimerMode::Once),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
**선택 B를 써야 할 때:**
|
||||
- *(TODO)*
|
||||
fn tick_flash(
|
||||
time: Res<Time>,
|
||||
mut q: Query<(Entity, &mut DamageFlash, &mut Sprite)>,
|
||||
mut commands: Commands,
|
||||
) {
|
||||
for (e, mut f, mut s) in q.iter_mut() {
|
||||
f.timer.tick(time.delta());
|
||||
s.color = if f.timer.finished() { Color::WHITE } else { Color::RED };
|
||||
if f.timer.finished() { commands.entity(e).remove::<DamageFlash>(); }
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**기본값:**
|
||||
> *(TODO)*
|
||||
### Frame interpolation (fixed sim, variable render)
|
||||
```rust
|
||||
#[derive(Component)] struct Transform2D { pos: Vec2 }
|
||||
#[derive(Component)] struct PrevPos(Vec2);
|
||||
|
||||
## ❌ 안티패턴 (Anti-Patterns)
|
||||
fn interpolate_render(
|
||||
fixed: Res<FixedTime>,
|
||||
q: Query<(&Transform2D, &PrevPos, &mut Transform)>,
|
||||
) {
|
||||
let alpha = fixed.accumulated().as_secs_f32() / fixed.timestep().as_secs_f32();
|
||||
for (cur, prev, mut t) in q.iter_mut() {
|
||||
let p = prev.0.lerp(cur.pos, alpha);
|
||||
t.translation = p.extend(t.translation.z);
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
- **[안티패턴]:** *(TODO: 무엇을 하면 안 되는가 + 이유 + 대신 무엇을)*
|
||||
### Render pipeline stages (Bevy schedule)
|
||||
```rust
|
||||
app.add_systems(FixedUpdate, (apply_damage, regen_mana))
|
||||
.add_systems(Update, (inject_health_to_bar, tick_flash))
|
||||
.add_systems(PostUpdate, (cull_offscreen, batch_sprites));
|
||||
```
|
||||
|
||||
### Floating damage text
|
||||
```rust
|
||||
fn spawn_damage_text(mut commands: Commands, mut events: EventReader<DamageEvent>,
|
||||
transforms: Query<&Transform>) {
|
||||
for ev in events.read() {
|
||||
let tf = transforms.get(ev.target).unwrap();
|
||||
commands.spawn((
|
||||
Text2dBundle { text: Text::from_section(format!("{}", ev.amount as i32),
|
||||
TextStyle { font_size: 24.0, color: Color::YELLOW, ..default() }),
|
||||
transform: *tf, ..default() },
|
||||
FloatingText { lifetime: Timer::from_seconds(1.0, TimerMode::Once), velocity: Vec2::Y * 50.0 },
|
||||
));
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Modifier aggregation (base + buffs + equipment)
|
||||
```rust
|
||||
fn aggregate_attack(
|
||||
mut q: Query<(&BaseStats, &Buffs, &Equipment, &mut DerivedAttack)>,
|
||||
) {
|
||||
for (base, buffs, eq, mut atk) in q.iter_mut() {
|
||||
let mut v = base.attack;
|
||||
v += eq.iter().map(|i| i.attack_bonus).sum::<f32>();
|
||||
v *= 1.0 + buffs.iter().map(|b| b.attack_mult).sum::<f32>();
|
||||
atk.0 = v;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## 매 결정 기준
|
||||
| 상황 | Approach |
|
||||
|---|---|
|
||||
| Modern data-oriented engine | Bevy ECS / Unity DOTS / Unreal MASS |
|
||||
| OOP legacy engine | Component pattern + observer for stat→visual |
|
||||
| Multiplayer authoritative server | Server simulation, client interpolation |
|
||||
| Animation-heavy | Skeletal animation system separate from stats |
|
||||
|
||||
**기본값**: ECS — sim Components → 매 system 의 derive Visual Components → renderer 의 read-only.
|
||||
|
||||
## 🔗 Graph
|
||||
- 부모: [[Game Engine Architecture]] · [[Entity Component System]]
|
||||
- 변형: [[Data-Oriented Design]] · [[Render Graph]]
|
||||
- 응용: [[Combat Visual Effects]] · [[HUD Rendering]]
|
||||
- Adjacent: [[Bevy]] · [[Unity DOTS]] · [[Unreal MASS]] · [[Fixed Timestep]]
|
||||
|
||||
## 🤖 LLM 활용
|
||||
**언제**: 매 game development, 매 simulation/render decoupling, 매 ECS pipeline 의 design.
|
||||
**언제 X**: 매 일반 web/backend, 매 simple tool — over-engineering.
|
||||
|
||||
## ❌ 안티패턴
|
||||
- **Render reads sim mid-tick**: 매 tearing — 매 PostUpdate 의 inject 의 사용.
|
||||
- **Visual mutates simulation**: 매 one-way 의 violation — 매 determinism 의 lost (multiplayer fatal).
|
||||
- **Damage 의 main thread blocking VFX**: 매 frame drop. 매 event-driven, async.
|
||||
- **Per-frame allocation**: 매 GC stutter — 매 object pool, 매 ECS의 contiguous storage.
|
||||
|
||||
## 🧪 검증 / 중복
|
||||
- Verified (Bevy 0.14 docs 2025; Unity DOTS docs; *Game Engine Architecture* Gregory 3rd ed).
|
||||
- 신뢰도 B (synthesis from multiple engine practices).
|
||||
|
||||
## 🕓 Changelog
|
||||
| 날짜 | 변경 |
|
||||
|---|---|
|
||||
| 2026-05-08 | Phase 1 |
|
||||
| 2026-05-10 | Manual cleanup — full ECS injection pipeline with Bevy patterns |
|
||||
|
||||
Reference in New Issue
Block a user