Replace the tracked JSON-in-header bake with a deterministic, bounds-checked CLB binary cooked by the build step. cntrl now loads only the binary; direct JSON loading is restricted to debug builds. Add codec/CLI tests, binary checker, editor bake-on-playtest, and pipeline docs.
7 KiB
7 KiB
FBC: NIGHT SHIFT — Technical Design
Stack (locked)
- C++23 (GCC 13+; developed on GCC 16)
- CMake 3.15+ (developed on 4.3)
- raylib 6.2, pinned via CMake
FetchContent(GIT_TAG 6.2, link targetraylib). 6.2 is the current release (Oct 2026) and fixed CMake-4.x build issues; builds GLFW from source (X11/GL dev headers required). raylib 6.x adds the Image/Draw API alignment (procedural textures) and skeletal model animation (UpdateModelAnimation, GLTF/IQM/M3D). S17 uses that path for the single player agent:agent.glbcarries a 19-bone armature and five baked actions;ModelBankadvances the clip withGetFrameTime() * 60and raylib CPU-skins it into the existingactor.vs(the shader deliberately has no bone attributes, so raylib's CPU fallback runs). The horde keeps shader-side procedural rigs, which stay one draw call per actor. - No other third-party deps until they earn their place. Authored level data is
JSON; it is cooked into a small custom binary during the build and only that
binary is loaded at runtime (see
docs/LEVEL_DATA_PIPELINE.md).
Repo layout
CMakeLists.txt
assets/models/ # sculpted GLB actors + props/ OoP set dressing
assets/shaders/ # actor, concrete, aura, bloom_*, post_fx
assets/textures/ # concrete/ PBR set, actor/ lighting ramp LUT
assets/blender/ # source .blend scenes
tools/blender/ # actor_kit, build_enemies/props/materials/scene, build_lut
docs/ # this is the design source of truth
src/
main.cpp # CLI (--seed N), window, fixed-tick loop, bloom render targets
core/ # NO raylib includes here. math, rng (PCG32), events
game/ # NO raylib includes here. simulation
input.hpp # InputState contract (filled by main from raylib)
corruption.* # RoR2-style difficulty coefficient + tier ladder
player.* # movement, dash, stats
enemies.* # archetypes, AI steering + separation, contact damage
weapons.* # auto-fire, projectiles, targeting
pickups.* # XP shards, magnet
buffs.* # scene-wide buffs/debuffs (ECS-like)
ritual.* # OoP ritual quest flow
game.* # Game class: state machine (Playing/GameOver), fixed-tick update
render/ # raylib lives here only (+ main.cpp)
presenter.* # 3D diorama camera, actor draws, sparks, blob shadows, bars
models.* # GLB bank + gradient-ramp actor shader + limb rig uniforms
concrete.* # one merged triplanar PBR mesh for floor/curbs/pillars
layout.hpp # shared pillar/open-room anchors for concrete + presenter
camera_tuning.hpp # live FOV/height/forward dev slider values
aura.* # reusable SDF ground waves for tier-ups / bosses
ui.* # HUD, death screen, camera dev slider
Architecture decisions
- Sim/render split.
core/andgame/never include raylib;main.cppfills anInputStateand the presenter reads the world. This keeps the sim portable (the planned--headless --bot-runspacing telemetry), testable, and lets the presenter be swapped (pure 2D, full 3D) without touching game logic. The sim is a floor-plane (Vec2) game regardless of how it is drawn. - Fixed 60 Hz logic tick with a render-rate accumulator in
main.cpp. - Deterministic seeded RNG (PCG32) in the sim; presentation-only randomness (screen shake) uses raylib's RNG and cannot touch game state.
- Event queue (
EventQueue, consumed and cleared by the presenter each frame): kills, hits, player damage, tier-ups -> VFX / SFX / screen shake / damage numbers. - Object pooling (
core/pool.hpp, dense swap-remove pool — no alloc churn after warmup, O(alive) iteration) for projectiles, enemies, shards. - Spatial hash (
core/spatial_hash.hpp, sorted-bucket, zero per-insert allocation) for enemy separation and projectile collision at horde scale. - Credit-based spawn Director (
game/director.*) with RoR2's "too cheap" rule and the elite-bank rule (implemented in M2). - Data pipeline, not code-generated data. Levels are authored in JSON,
validated and cooked to a deterministic binary by
level_tool --bakeduring the asset build step, and the client loads only the binary. Debug/editor builds may read JSON directly for hot-reload; release builds cannot.
Rendering pipeline (hybrid)
Camera3Dthree-quarter view following the player (default fovy 55 / height 16 m / forward 15 m after the S16 critical-lens pass, all live-tunable from the HUD's CAMERA DEV panel), target clamped 8 m inside the arena curb so the unlit outer floor never dominates.- One merged triplanar concrete mesh (
concrete.*) for floor, curbs, pillars and door frame, sharing one tileable 2K PBR set frombuild_materials.py. - Sculpted GLB actors (
models.*,assets/models/) lit by a gradient-ramp shader with faction rims. The horde uses a procedural limb rig (uRigMode1 humanoid, 2 blob, 3 crystal) — no skeletons, no extra draw calls. The single player agent instead has a Blender skeleton and baked actions, CPU-skinned by raylib. Hiss actors and the agent get a cheap expanded-backface ink outline. - Hard shadow map (
render/shadow_map.*) — one 2048² depth-only FBO built from rlgl primitives (raylib 6.2 has no shadow API). An orthographic light camera follows the player with texel snapping; the caster pass reuses the environment/actor vertex shaders with a depth-only fragment shader so the procedural rigs match, and culls to the light frustum.concrete.fsandactor.fsdo a single NEAREST depth compare (no PCF) with a slope-scaled bias, darkening only the direct term. Blob quads remain as contact shading.--shadows offdisables the pass and the receiver lookup. - Sparks / glows / world objects are camera-facing billboards using one
procedural glow sprite; damage numbers and health bars use
GetWorldToScreen. - Post FX: scene into a full-res
RenderTexture, half-res bright pass + separable blur for bloom, thenpost_fx.fs(VHS noise, mild aberration, red Hiss tint, teal/warm grade, vignette) keyed to the corruption coefficient. HUD is drawn into the same target so post FX applies to it too — aberration is kept low to preserve legibility.
Conventions
snake_casefiles/functions,PascalCasetypes,kConstantfor constants.#pragma onceheaders; include paths relative tosrc/(#include "game/game.hpp").- Compile clean with
-Wallsemantics; no warnings ignored globally.
CLI
--seed Nrun seed (implemented).--screenshot <path>saves a PNG of the framebuffer (optionally--screenshot-at <sec>, default 3 s); F12 saves one on demand (implemented — dev tool, works under Wayland where root-window grabs cannot see composited windows).--botkiting autopilot: seeks shards, repels enemies, dashes (implemented — validation tool and the seed of the M6 balance-bot).--no-damagestress mode for horde/pacing captures (implemented).--headless --bot-runs Npacing telemetry (planned M6).