Files
2nd/10_Wiki/Topic_Programming/Architecture/Stat-Injection-and-Visual-Renderer-Pipeline.md
T
Antigravity Agent 9148c358d0 docs(10_Wiki): 위키 전체 재구성 — Topic_* 폴더를 4개 카테고리로 통합 + 대규모 중복 제거
Topic_Agent/Topic_Blog/Topics/Topics_Biz/Topics_Meeting/Topics_Rag의 마크다운 지식 문서를
Topic_General/Topic_Programming/Topic_Graphic/Topic_Business 4개 카테고리로 재분류.

- 중복 제거: frontmatter의 status:duplicate/merged + duplicate_of/redirect_to 필드로
  자기 자신을 중복으로 선언한 리다이렉트 stub 1032개 제거, 완전 동일 내용 파일 472개 제거,
  동일 파일명·다른 내용 충돌 시 더 큰(완전한) 버전만 유지(162개 제거) — 총 1639개 중복 제거.
- 분류: 폴더 단위로 명확한 항목(AI_and_ML/Coding/Architecture 등 → Programming,
  Comfyui/Visual_Effects → Graphic, Topics_Biz/Topics_Meeting/사업 등 → Business,
  Poetic_Blog_Writing/창의성/Game_Design 등 → General)은 폴더 우선순위로,
  나머지 혼재 폴더(Topic_Agent/Topic_Blog/Topics 루트/Thinking & Reasoning/Other/UI_UX_Assets)는
  title/tags 키워드 스코어링으로 파일 단위 분류(불명확한 경우 General로 폴백).
  원본 폴더명은 "From_*" 서브폴더로 보존해 추적 가능성 유지.
- 최종 배치: Programming 2784 / General 1608 / Graphic 285 / Business 249 = 4926개 문서.
- 에이전트 운영 상태(.astra/.agent/.obsidian/sessions/memory/_company/docs/lessons/_shared/src)는
  지식 콘텐츠가 아니므로 재분류 대상에서 제외하고 원위치 유지.
- Topics/Topic_email(상위 보호 폴더 Topic_email과 파일명 100% 중복) 삭제 — 보호 폴더 자체는 미변경.
- 완전히 비게 된 Topic_Agent/Topic_Blog/Topics_Biz/Topics_Rag 폴더 제거.
2026-07-05 00:33:48 +09:00

6.5 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-stat-injection-and-visual-render Stat Injection and Visual Renderer Pipeline 10_Wiki/Topics verified self
Stat Injection Pipeline
Visual Renderer Pipeline
none B 0.8 applied
game-engine
ecs
rendering-pipeline
data-flow
2026-05-10 pending
language framework
rust bevy

Stat Injection and Visual Renderer Pipeline

매 한 줄

"매 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. 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.

매 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.

매 응용

  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.

💻 패턴

Bevy ECS (Rust 1.83) — stat → visual injection

use bevy::prelude::*;

#[derive(Component)] struct Health { current: f32, max: f32 }
#[derive(Component)] struct HealthBar; // visual marker
#[derive(Component)] struct DamageFlash { timer: Timer }

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);
        }
    }
}

Damage event → flash injection

#[derive(Event)] struct DamageEvent { target: Entity, amount: f32 }

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),
            });
        }
    }
}

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>(); }
    }
}

Frame interpolation (fixed sim, variable render)

#[derive(Component)] struct Transform2D { pos: Vec2 }
#[derive(Component)] struct PrevPos(Vec2);

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);
    }
}

Render pipeline stages (Bevy schedule)

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

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)

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

🤖 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