diff --git a/CMakeLists.txt b/CMakeLists.txt index ff1f921..8b0db2f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,9 @@ FetchContent_MakeAvailable(raylib) add_executable(cntrl src/main.cpp + src/game/buffs.cpp src/game/corruption.cpp + src/game/ritual.cpp src/game/director.cpp src/game/player.cpp src/game/enemies.cpp diff --git a/README.md b/README.md index 5bf56e5..21e3af7 100644 --- a/README.md +++ b/README.md @@ -1,21 +1,25 @@ # FBC: NIGHT SHIFT -A Control-universe horde-survivor (Vampire Survivors-like) built in C++23 + raylib 6.2. -You are an FBC security guard the night of the Hiss breach — hours before Jesse Faden -becomes Director. Move, and everything else is automatic: your Objects of Power fire on -their own while the Oldest House decays around you in real time. +A Control-universe real-time auto-brawler (Vampire Survivors-like) built in C++23 + raylib 6.2. +You are a **nameless worker** in the Oldest House — an everyday FBC worker who never +resonated when the others became Resonant. Move, and everything else is automatic: +your Objects of Power fire on their own while the Oldest House decays around you in +real time. (Jesse Faden walks into the Executive floor — that is the end of the run; +the player is not Jesse.) -**Signature mechanic:** fight an Object of Power's trial — survive it, and it becomes -your permanent skill for the run (Mega Man structure, Control skin). +**Signature mechanic:** reach an Object of Power's ritual — complete it, and it +becomes your permanent skill for the run (Mega Man structure, Control skin). **Difficulty:** Risk of Rain 2-style continuous *Corruption* scaling — the clock is the enemy. See `docs/GAME_DESIGN.md`. ## Status -Pre-alpha vertical slice (M0–M2 plus the M5 art kickoff): movement/dash, four -Objects of Power with Altered Forms, 3 enemy archetypes, XP → Board Directive -level-ups, corruption clock, death screen. The look is a brutalist 3D diorama -with **low-poly Blender actors** (no more 2D standees) and corruption-keyed post +Pre-alpha vertical slice (M0–M2 plus the M5 art kickoff): move/dash + autoshoot, +4 Objects of Power (levels + Altered Forms, enable/disable), real-time skill +offers on level-up (no pause), 3 enemy archetypes, corruption clock, +death screen. Floors & rituals (M3), world objects (M4), debuffs/buffs system +(M4). The look is a brutalist 3D diorama +with **sculpted low-poly Blender actors** (no more 2D standees or box kits) and corruption-keyed post FX. A single tileable 2K concrete PBR set (generated by `tools/blender/build_materials.py`) is shared by floor, curbs and pillars via one triplanar shader and one merged mesh. Art is tracked in `docs/ENV_ENHANCEMENT.md`. @@ -40,8 +44,9 @@ raylib 6.2 is fetched automatically by CMake (FetchContent). Needs a C++23 compi | Input | Action | |---|---| | WASD | Move | +| Stick (XInput/GLFW, M7) | Move | | Shift / Space | Dash (*Evade*) | -| 1 / 2 / 3 | Pick Board Directive on level-up | +| 1 / 2 / 3 | Pick level-up offer (real-time, no pause) | | R | Restart run (on death) | | Esc | Quit | @@ -53,9 +58,10 @@ raylib 6.2 is fetched automatically by CMake (FetchContent). Needs a C++23 compi - `docs/ROADMAP.md` — milestones M0–M6 and current status - `docs/concept/` — rendered Blender concept frames (visual target for M5) - `docs/ENV_ENHANCEMENT.md` — enhancement slices S0–S6 for the environment/actors -- `tools/blender/` — procedural diorama + actor builders and render scripts -- `assets/models/` — game-ready GLB actors (guard, 3 enemies, resonance shard) +- `tools/blender/` — procedural diorama + actor builders (`actor_kit.py` loft/sweep/blob/crystal helpers) and render scripts +- `assets/models/` — game-ready GLB actors (guard, 3 enemies, resonance shard) and `props/` OoP set dressing - `assets/textures/concrete/` — shared seamless albedo/normal/roughness maps +- `assets/textures/actor/actor_ramp.png` — Blender-generated stylised lighting ramp - `assets/blender/fbc_corruption_wave.blend` — reusable SDF wave reference scene ## IP note diff --git a/assets/blender/fbc_enemies.blend b/assets/blender/fbc_enemies.blend index 83a5f6c..f0a5009 100644 Binary files a/assets/blender/fbc_enemies.blend and b/assets/blender/fbc_enemies.blend differ diff --git a/assets/blender/fbc_props.blend b/assets/blender/fbc_props.blend new file mode 100644 index 0000000..bfe0dc3 Binary files /dev/null and b/assets/blender/fbc_props.blend differ diff --git a/assets/models/guard.glb b/assets/models/guard.glb index 3969561..81396d1 100644 Binary files a/assets/models/guard.glb and b/assets/models/guard.glb differ diff --git a/assets/models/hiss_brute.glb b/assets/models/hiss_brute.glb index 6c604c8..d8d4cb9 100644 Binary files a/assets/models/hiss_brute.glb and b/assets/models/hiss_brute.glb differ diff --git a/assets/models/hiss_staff.glb b/assets/models/hiss_staff.glb index 736de67..2bc8da7 100644 Binary files a/assets/models/hiss_staff.glb and b/assets/models/hiss_staff.glb differ diff --git a/assets/models/mold_spore.glb b/assets/models/mold_spore.glb index b567f9b..73246fc 100644 Binary files a/assets/models/mold_spore.glb and b/assets/models/mold_spore.glb differ diff --git a/assets/models/props/cabinet.glb b/assets/models/props/cabinet.glb new file mode 100644 index 0000000..bfe0693 Binary files /dev/null and b/assets/models/props/cabinet.glb differ diff --git a/assets/models/props/crate.glb b/assets/models/props/crate.glb new file mode 100644 index 0000000..fc23df7 Binary files /dev/null and b/assets/models/props/crate.glb differ diff --git a/assets/models/props/debris.glb b/assets/models/props/debris.glb new file mode 100644 index 0000000..3216165 Binary files /dev/null and b/assets/models/props/debris.glb differ diff --git a/assets/models/props/duck.glb b/assets/models/props/duck.glb new file mode 100644 index 0000000..414630b Binary files /dev/null and b/assets/models/props/duck.glb differ diff --git a/assets/models/props/hotline.glb b/assets/models/props/hotline.glb new file mode 100644 index 0000000..faa7ae5 Binary files /dev/null and b/assets/models/props/hotline.glb differ diff --git a/assets/models/props/pedestal.glb b/assets/models/props/pedestal.glb new file mode 100644 index 0000000..30f7c55 Binary files /dev/null and b/assets/models/props/pedestal.glb differ diff --git a/assets/models/props/tv.glb b/assets/models/props/tv.glb new file mode 100644 index 0000000..83fc090 Binary files /dev/null and b/assets/models/props/tv.glb differ diff --git a/assets/models/shard.glb b/assets/models/shard.glb index 012d8ad..7b0bb54 100644 Binary files a/assets/models/shard.glb and b/assets/models/shard.glb differ diff --git a/assets/shaders/actor.fs b/assets/shaders/actor.fs index d60d9b7..8e58275 100644 --- a/assets/shaders/actor.fs +++ b/assets/shaders/actor.fs @@ -1,7 +1,10 @@ #version 330 -// FBC: NIGHT SHIFT — actor lighting. Cold fluorescent key, Hiss bleed in the -// shadows, and self-lit saturated resin for the red/teal/yellow palette entries. -// uFlash is the per-actor hit flash; uCorruption drives the slow decay. +// FBC: NIGHT SHIFT — actor lighting (S9 look-dev). +// Risk of Rain 2's gradient-map diffuse and two-tone rim, in Control's graphite +// palette: cool shadows, warm highlights, faction-coloured fresnel edge, +// atmospheric haze and corruption bleed. actor_ramp.png is generated in Blender +// by tools/blender/build_lut.py. uOutline renders the back-face ink silhouette. + in vec2 fragTexCoord; in vec4 fragColor; in vec3 vNormal; @@ -10,41 +13,73 @@ in vec3 vWorld; out vec4 finalColor; uniform sampler2D texture0; +uniform sampler2D actorRamp; uniform vec4 colDiffuse; +uniform vec3 uCameraPos; uniform float uTime = 0.0; uniform float uFlash = 0.0; uniform float uCorruption = 0.0; +uniform float uOutline = 0.0; void main() { vec3 n = normalize(vNormal); - // glTF base factors are linear; raylib uploads them as plain bytes, so undo - // the transfer curve here to recover the Blender palette. + // glTF base factors are linear and uploaded as plain bytes: undo the curve. vec3 base = pow(colDiffuse.rgb * fragColor.rgb, vec3(1.0 / 2.2)); + if (uOutline > 0.5) { + vec3 ink = vec3(0.018, 0.020, 0.026) + + vec3(0.055, 0.0, 0.0) * uCorruption; + finalColor = vec4(ink, 1.0); + return; + } + + float sat = max(base.r, max(base.g, base.b)) + - min(base.r, min(base.g, base.b)); + vec3 keyDir = normalize(vec3(-0.42, 0.86, 0.30)); vec3 fillDir = normalize(vec3(0.55, 0.25, -0.70)); - float key = max(dot(n, keyDir), 0.0); + float ndl = dot(n, keyDir) * 0.5 + 0.5; // half-Lambert + vec3 ramp = texture(actorRamp, vec2(clamp(ndl, 0.0, 1.0), 0.5)).rgb * 1.7; float fill = max(dot(n, fillDir), 0.0); float hemi = 0.5 + 0.5 * n.y; - vec3 lit = base * (0.52 + 0.78 * key + 0.22 * fill + 0.14 * hemi); + vec3 lit = base * ramp * (0.88 + 0.12 * hemi); + lit += base * fill * 0.13; - // Cold fluorescent rim from the ceiling grilles. - float rim = pow(1.0 - max(dot(n, normalize(vec3(0.0, 0.7, 0.7))), 0.0), 3.0); - lit += vec3(0.13, 0.17, 0.20) * rim; + // Two-tone rim: cold fluorescent in the House, faction hue on corrupted + // actors (red Hiss, sickly Mold) with no extra textures or draw calls. + vec3 viewDir = normalize(uCameraPos - vWorld); + float fresnel = pow(1.0 - max(dot(n, viewDir), 0.0), 3.0); + float ceiling = pow(1.0 - max(dot(n, normalize(vec3(0.0, 0.7, 0.7))), 0.0), 3.0); + float rim = max(fresnel * 0.85, ceiling * 0.55); + vec3 cold = vec3(0.40, 0.53, 0.66); + vec3 accent = normalize(base + vec3(1e-4)) * 0.55; + lit += mix(cold, accent, smoothstep(0.16, 0.45, sat)) * rim + * (0.75 + 0.25 * uCorruption); - // Saturated palette entries read as emissive resin (no extra texture maps). + // Saturated palette entries read as emissive resin. float bright = max(base.r, max(base.g, base.b)); - float pulse = 0.9 + 0.1 * sin(uTime * 2.3 + vWorld.x * 1.7); - lit += base * smoothstep(0.40, 0.92, bright) * 0.45 * pulse; + float pulse = 0.88 + 0.12 * sin(uTime * 2.6 + vWorld.x * 1.7 + vWorld.z * 0.9); + lit += base * smoothstep(0.42, 0.88, bright) * 0.20 * pulse; + + // Tight sheen so bevels catch the fluorescent key. + vec3 halfDir = normalize(keyDir + viewDir); + float spec = pow(max(dot(n, halfDir), 0.0), 42.0) + * (0.06 + 0.10 * smoothstep(0.35, 0.8, bright)); + lit += vec3(0.90, 0.88, 0.82) * spec; // The House bleeds red into unlit faces as containment fails. - lit += vec3(0.28, 0.015, 0.02) * (1.0 - key) * uCorruption * 0.32; + lit += vec3(0.26, 0.012, 0.018) * (1.0 - ndl) * uCorruption * 0.30; - // Hit flash washes the whole silhouette toward hot white-red. + // Hit flash washes the silhouette toward hot white-red. lit = mix(lit, vec3(1.0, 0.62, 0.56) * (0.75 + 0.25 * bright), uFlash); - finalColor = vec4(lit * colDiffuse.a * fragColor.a, 1.0); + // Haze pulls distant actors into the room instead of floating on top. + float dist = length(uCameraPos - vWorld); + float fog = (1.0 - exp(-dist * 0.014)) * 0.55; + lit = mix(lit, vec3(0.055, 0.058, 0.070), fog); + + finalColor = vec4(lit, 1.0); } diff --git a/assets/shaders/actor.vs b/assets/shaders/actor.vs index 29ad200..d60b6b6 100644 --- a/assets/shaders/actor.vs +++ b/assets/shaders/actor.vs @@ -1,7 +1,9 @@ #version 330 -// FBC: NIGHT SHIFT — actor vertex stage. -// Raylib feeds vertexPosition/vertexNormal/vertexColor and the matModel uniform; -// we pass world-space normals out so the fragment stage can do flat facet light. +// FBC: NIGHT SHIFT — actor vertex stage (S9 look-dev). +// raylib feeds vertexPosition/vertexNormal/vertexColor and the matModel uniform. +// Procedural motion: saturated (corrupted) vertices jitter, the guard breathes. +// uOutline expands back faces along the normal for the hero/boss ink outline. + in vec3 vertexPosition; in vec3 vertexNormal; in vec2 vertexTexCoord; @@ -9,6 +11,20 @@ in vec4 vertexColor; uniform mat4 mvp; uniform mat4 matModel; +uniform float uTime = 0.0; +uniform float uOutline = 0.0; +uniform float uWalk = 0.0; +uniform float uStagger = 0.0; +uniform float uPhase = 0.0; +uniform vec4 uRig = vec4(0.0); // hipY, shoulderY, legX, armX +uniform float uRigScale = 0.0; // amplitude / enable +uniform float uRigMode = 0.0; // 0 none, 1 humanoid, 2 blob, 3 crystal + +vec3 rot_x(vec3 v, float a) +{ + float c = cos(a), s = sin(a); + return vec3(v.x, c * v.y - s * v.z, s * v.y + c * v.z); +} out vec2 fragTexCoord; out vec4 fragColor; @@ -17,9 +33,75 @@ out vec3 vWorld; void main() { + vec3 p = vertexPosition; + + // Recover the painted palette to tell a faction from its vertex colour. + vec3 paint = pow(max(vertexColor.rgb, vec3(0.0)), vec3(1.0 / 2.2)); + float sat = max(paint.r, max(paint.g, paint.b)) + - min(paint.r, min(paint.g, paint.b)); + float corrupt = smoothstep(0.18, 0.52, sat); + + // Hiss / Mold: nervous high-frequency micro-jitter, deterministic in space. + vec3 jitter = vec3(sin(uTime * 9.3 + p.y * 17.0), + sin(uTime * 6.1 + p.y * 11.0) * 0.35, + cos(uTime * 8.1 + p.y * 13.0)) * (0.011 * corrupt); + // The guard breathes instead of twitching. + float breath = sin(uTime * 1.9) * 0.005 * (1.0 - corrupt) * step(0.25, p.y); + p += jitter; + p.y += breath; + + // Procedural rigs: classify vertices by local position — no skeleton, no + // extra vertex attributes, no extra draw calls. Modes: 1 humanoid, + // 2 blob (Mold), 3 crystal (Resonance shard). + if (uRigMode > 2.5) { + // Crystal: slow facet breathing along the normal plus a shimmer wobble. + float shimmer = sin(uTime * 3.1 + uPhase + p.y * 9.0) * 0.5 + 0.5; + p += vertexNormal * (0.008 + 0.018 * shimmer) * uRigScale; + p.x += sin(uTime * 1.7 + uPhase) * 0.01 * uRigScale; + } else if (uRigMode > 1.5) { + // Mold blob: squash/stretch jelly with height-weighted wobble. + float cycle = uTime * 4.0 + uPhase; + float amp = (0.045 + 0.075 * uWalk) * uRigScale; + float squash = sin(cycle) * amp; + float h = clamp(p.y / 1.3, 0.0, 1.0); + p.y *= 1.0 + squash * (0.35 + 0.65 * h); + p.xz *= 1.0 - squash * 0.7 * (0.35 + 0.65 * h); + p.x += sin(cycle * 1.7 + p.y * 6.0) * 0.025 * h * uRigScale; + if (uStagger > 0.0) { + p.y *= 1.0 - 0.22 * uStagger; + p.x += sin(uTime * 26.0 + uPhase) * 0.04 * uStagger; + } + } else if (uRigMode > 0.5) { + // Humanoid: arms counter-swing the legs. The flat base ring is a + // marker, not anatomy: leave it planted. + float base_ring = step(0.40, length(p.xz)) * step(p.y, 0.12); + if (base_ring < 0.5) { + float cycle = uTime * 8.0 + uPhase; + float swing = sin(cycle) * 0.38 * uWalk * uRigScale; + float side = p.x < 0.0 ? -1.0 : 1.0; + if (abs(p.x) > uRig.w && p.y > 0.55 && p.y < uRig.y) { + vec3 pivot = vec3(side * uRig.w, uRig.y, 0.0); + p = rot_x(p - pivot, swing * side * 0.75) + pivot; + } else if (p.y < uRig.x) { + vec3 pivot = vec3(side * uRig.z, uRig.x, 0.0); + p = rot_x(p - pivot, -swing * side) + pivot; + } else { + p.y += sin(cycle * 2.0) * 0.012 * uWalk * uRigScale; + } + if (uStagger > 0.0) { + vec3 pivot = vec3(0.0, uRig.x, 0.0); + p = rot_x(p - pivot, -0.38 * uStagger) + pivot; + p.x += sin(uTime * 27.0 + uPhase) * 0.025 * uStagger; + } + } + } + + if (uOutline > 0.5) p += vertexNormal * 0.022; + + vec4 world = matModel * vec4(p, 1.0); + vNormal = normalize(mat3(matModel) * vertexNormal); + vWorld = world.xyz; fragTexCoord = vertexTexCoord; fragColor = vertexColor; - vNormal = normalize(mat3(matModel) * vertexNormal); - vWorld = (matModel * vec4(vertexPosition, 1.0)).xyz; - gl_Position = mvp * vec4(vertexPosition, 1.0); + gl_Position = mvp * vec4(p, 1.0); } diff --git a/assets/shaders/aura.fs b/assets/shaders/aura.fs index 92400e1..269d034 100644 --- a/assets/shaders/aura.fs +++ b/assets/shaders/aura.fs @@ -34,11 +34,11 @@ void main() float body = 1.0 - smoothstep(ragged * 0.30, ragged, r); float inner = 1.0 - smoothstep(0.0, 0.52, r); - vec3 dark = vec3(0.012, 0.002, 0.005); - vec3 crimson = vec3(0.78, 0.055, 0.085); - vec3 col = mix(dark, crimson, clamp(ring * 0.95 + (1.0 - inner) * 0.18, 0.0, 1.0)); + vec3 dark = vec3(0.008, 0.004, 0.008); + vec3 crimson = vec3(0.26, 0.015, 0.026); + vec3 col = mix(dark, crimson, clamp(ring * 0.85 + (1.0 - inner) * 0.14, 0.0, 1.0)); - float a = body * (0.34 + 0.16 * uCorruption) + ring * 0.55; + float a = body * (0.34 + 0.16 * uCorruption) + ring * 0.30; a *= smoothstep(1.0, 0.62, r); finalColor = vec4(col * colDiffuse.rgb, a * colDiffuse.a * uIntensity); } diff --git a/assets/shaders/bloom_blur.fs b/assets/shaders/bloom_blur.fs new file mode 100644 index 0000000..e2cc658 --- /dev/null +++ b/assets/shaders/bloom_blur.fs @@ -0,0 +1,27 @@ +#version 330 +// Separable 9-tap gaussian; uDirection is one texel on the half-res target. +in vec2 fragTexCoord; +in vec4 fragColor; +out vec4 finalColor; + +uniform sampler2D texture0; +uniform vec2 uDirection; + +void main() +{ + const float w0 = 0.227027; + const float w1 = 0.194595; + const float w2 = 0.121622; + const float w3 = 0.054054; + const float w4 = 0.016216; + vec3 c = texture(texture0, fragTexCoord).rgb * w0; + c += (texture(texture0, fragTexCoord + uDirection).rgb + + texture(texture0, fragTexCoord - uDirection).rgb) * w1; + c += (texture(texture0, fragTexCoord + 2.0 * uDirection).rgb + + texture(texture0, fragTexCoord - 2.0 * uDirection).rgb) * w2; + c += (texture(texture0, fragTexCoord + 3.0 * uDirection).rgb + + texture(texture0, fragTexCoord - 3.0 * uDirection).rgb) * w3; + c += (texture(texture0, fragTexCoord + 4.0 * uDirection).rgb + + texture(texture0, fragTexCoord - 4.0 * uDirection).rgb) * w4; + finalColor = vec4(c, 1.0); +} diff --git a/assets/shaders/bloom_bright.fs b/assets/shaders/bloom_bright.fs new file mode 100644 index 0000000..3bf5c77 --- /dev/null +++ b/assets/shaders/bloom_bright.fs @@ -0,0 +1,16 @@ +#version 330 +// Half-resolution bright pass for the S12 bloom chain. +in vec2 fragTexCoord; +in vec4 fragColor; +out vec4 finalColor; + +uniform sampler2D texture0; +uniform float uThreshold = 0.62; + +void main() +{ + vec3 c = texture(texture0, fragTexCoord).rgb; + float l = dot(c, vec3(0.2126, 0.7152, 0.0722)); + float k = max(l - uThreshold, 0.0) / max(l, 1e-4); + finalColor = vec4(c * k, 1.0); +} diff --git a/assets/shaders/concrete.fs b/assets/shaders/concrete.fs index de13efd..a8f75ef 100644 --- a/assets/shaders/concrete.fs +++ b/assets/shaders/concrete.fs @@ -11,7 +11,7 @@ uniform sampler2D texture0; // albedo uniform sampler2D texture1; // roughness uniform sampler2D texture2; // tangent normal uniform vec4 colDiffuse; -uniform vec3 cameraPosition; +uniform vec3 uCameraPos; uniform float uScale = 0.42; uniform float uCorruption = 0.0; @@ -51,23 +51,31 @@ void main() vec3 key_dir = normalize(vec3(-0.42, 0.86, 0.30)); vec3 fill_dir = normalize(vec3(0.55, 0.25, -0.70)); - float key = max(dot(n, key_dir), 0.0); + // Stylised half-Lambert ramp — the analytic twin of the Blender-generated + // actor ramp, so the room and its actors share one shading language. + float ndl = dot(n, key_dir) * 0.5 + 0.5; + float ramp = mix(0.62, 1.30, smoothstep(0.06, 0.94, ndl)); float fill = max(dot(n, fill_dir), 0.0); float hemi = 0.5 + 0.5 * n.y; - vec3 lit = albedo * (0.55 + 0.55 * key + 0.28 * fill + 0.14 * hemi); + vec3 lit = albedo * (ramp * (0.92 + 0.08 * hemi) + 0.16 * fill); float rim = pow(1.0 - max(dot(n, normalize(vec3(0.0, 0.6, 0.8))), 0.0), 3.0); lit += vec3(0.05, 0.06, 0.07) * rim; // Sealed-floor sheen: tight highlight on the polished patches. - vec3 view_dir = normalize(cameraPosition - vWorld); + vec3 view_dir = normalize(uCameraPos - vWorld); vec3 half_dir = normalize(key_dir + view_dir); float gloss = mix(48.0, 7.0, rough); float spec = pow(max(dot(n, half_dir), 0.0), gloss) * (1.0 - rough) * 0.30; lit += vec3(0.92, 0.90, 0.82) * spec; // Hiss bleeding into the unlit side of the room as containment fails. - lit += vec3(0.12, 0.008, 0.012) * (1.0 - key) * uCorruption * 0.22; + lit += vec3(0.12, 0.008, 0.012) * (1.0 - ndl) * uCorruption * 0.22; + + // Volumetric haze: distant concrete settles into the Oldest House gloom. + float dist = length(uCameraPos - vWorld); + float fog = (1.0 - exp(-dist * 0.014)) * 0.50; + lit = mix(lit, vec3(0.055, 0.058, 0.070), fog); finalColor = vec4(lit * colDiffuse.rgb * vColor.rgb, 1.0); } diff --git a/assets/shaders/post_fx.fs b/assets/shaders/post_fx.fs index d148083..8906375 100644 --- a/assets/shaders/post_fx.fs +++ b/assets/shaders/post_fx.fs @@ -1,20 +1,20 @@ #version 330 -// FBC: NIGHT SHIFT — corruption-keyed post FX (docs/ART_DIRECTION.md "Post FX"). -// VHS scanlines + noise, chromatic aberration, red Hiss tint, vignette. -// Strength scales with the corruption coefficient — the House decays in -// real time and so does the image. Drawn over the whole frame by main.cpp. +// FBC: NIGHT SHIFT — corruption-keyed post FX + S12 bloom and colour grade. +// VHS scanlines/noise, chromatic aberration, red Hiss tint, teal-shadow / +// warm-highlight grade, damage flash and vignette, all keyed to corruption. in vec2 fragTexCoord; in vec4 fragColor; out vec4 finalColor; -uniform sampler2D texture0; +uniform sampler2D texture0; // scene +uniform sampler2D texture1; // half-res blurred bloom uniform vec4 colDiffuse; uniform float uTime = 0.0; -uniform float uCorruption = 0.05; // ~0.05 .. 2.0 (see game/corruption.hpp) -uniform float uDamage = 0.0; // 0..1 player hit flash +uniform float uCorruption = 0.05; +uniform float uDamage = 0.0; float hash(vec2 p) { return fract(sin(dot(p, vec2(127.1, 311.7))) * 43758.5453); @@ -24,10 +24,10 @@ void main() { vec2 uv = fragTexCoord; // Chromatic aberration: subtle, grows with corruption + on damage. - float aberr = 0.0005 + 0.0018 * uCorruption + 0.006 * uDamage; + float aberr = 0.0003 + 0.0010 * uCorruption + 0.004 * uDamage; vec2 dir = uv - vec2(0.5); float dist = length(dir); - vec2 off = dir * dist * aberr * 6.0; + vec2 off = dir * dist * aberr * 3.0; vec3 col = vec3( texture(texture0, uv + off).r, texture(texture0, uv).g, @@ -35,14 +35,30 @@ void main() { // VHS scanlines + rolling noise (intensity keys to corruption). float scan = sin(uv.y * 720.0) * 0.5 + 0.5; - col *= 1.0 - 0.06 * scan * (0.5 + 0.5 * clamp(uCorruption, 0.0, 1.5)); + col *= 1.0 - 0.055 * scan * (0.5 + 0.5 * clamp(uCorruption, 0.0, 1.5)); float n = hash(uv * vec2(1024.0, 1024.0) + fract(uTime) * 61.7); - col += (n - 0.5) * (0.02 + 0.05 * clamp(uCorruption, 0.0, 1.5)); + col += (n - 0.5) * (0.012 + 0.025 * clamp(uCorruption, 0.0, 1.5)); // Red Hiss tint breathing with corruption. float hiss = clamp(uCorruption * 0.12, 0.0, 0.45); col = mix(col, col * vec3(1.08, 0.93, 0.93) + vec3(0.05, 0.0, 0.0), hiss); + // Grade: cool the shadows, warm the highlights — Control's graphite with + // RoR2's clean value separation rather than a flat grey image. + float lum = dot(col, vec3(0.299, 0.587, 0.114)); + vec3 cool = vec3(0.82, 0.94, 1.09); + vec3 warm = vec3(1.12, 0.99, 0.90); + col *= mix(cool, warm, smoothstep(0.18, 0.82, lum)); + col.r += 0.018 * smoothstep(0.55, 0.95, lum); + // Gentle S-curve: separate graphite shadows from paper highlights a little + // more without crushing the dark diorama or clipping under bloom. + col = mix(col, col * col * (3.0 - 2.0 * col), 0.35); + col *= 1.05; + + // Bloom from fluorescent strips, crystals and Hiss resin. + vec3 bloom = texture(texture1, uv).rgb; + col += bloom * (1.30 + 0.20 * uCorruption); + // Damage flash: red bloom. col = mix(col, vec3(0.8, 0.05, 0.07), uDamage * 0.35); @@ -50,8 +66,6 @@ void main() { float vig = 1.0 - smoothstep(0.45, 1.05, dist) * (0.42 + 0.12 * uCorruption); col *= vig; - // Mild exposure lift to keep the night scene readable under the vignette. - col *= 1.12; - + col *= 1.10; finalColor = vec4(col, 1.0) * colDiffuse * fragColor; } diff --git a/assets/textures/actor/actor_ramp.png b/assets/textures/actor/actor_ramp.png new file mode 100644 index 0000000..8fae522 Binary files /dev/null and b/assets/textures/actor/actor_ramp.png differ diff --git a/docs/ART_DIRECTION.md b/docs/ART_DIRECTION.md index 76c8134..c8a73d4 100644 --- a/docs/ART_DIRECTION.md +++ b/docs/ART_DIRECTION.md @@ -10,10 +10,12 @@ units are little free-standing puppets rather than printed cards: geometry (slabs, pillars, recessed fluorescent light strips, EXIT signs, redacted wall signage). Brutalism is literally parametric boxes, so procedural meshes get ~80% of the look for ~20% of the cost. -- Units are **low-poly puppets** — 0.7–1.4k-triangle actors with readable facets, - ID-badge details, Hiss crystal growths and a little base ring. Thematically the - same bureaucrat-moving-case-files fantasy, but they occupy real depth: they turn - to face the player, bob when floating and are lit by the House's fluorescent key. +- Units are **sculpted low-poly puppets** — lofted bodies, swept limbs and + deformed organic masses rather than a cube kit (guard ~5.7k triangles, enemies + 1.4–2.9k, shard ~150), with readable facets, ID-badge details, Hiss crystal + growths and a little base ring. Thematically the same bureaucrat-moving-case- + files fantasy, but they occupy real depth: they turn to face the player, bob + when floating and are lit by the House's fluorescent key. - **Actors are authored in Blender** (`tools/blender/build_enemies.py`), exported as GLB to `assets/models/` and lit in-engine by `assets/shaders/actor.{vs,fs}`. `UpdateModelAnimation` remains the upgrade path for animated bosses. @@ -79,6 +81,9 @@ not action-rock. - Elites: affix-colored rim + aura (Resonant = pulsing ring, Phasing = afterimage, Volatile = flicker, Shielded = rock shell, Mending = green halo) - Bosses: multiple-screen-height actors, hand-built in the same GLB pipeline +- World objects of power (§4.6): small glow + flavor name on the floor; + glow colors per kind: Slow = blue, Confuse = yellow, Taken = orange, + Vulnerable = deep red, Dot = red ## Concept scene (Blender) — visual target for M5 diff --git a/docs/ENV_ENHANCEMENT.md b/docs/ENV_ENHANCEMENT.md index 1b70777..ca434ff 100644 --- a/docs/ENV_ENHANCEMENT.md +++ b/docs/ENV_ENHANCEMENT.md @@ -21,6 +21,13 @@ Legend: **[B]** Blender scene (`tools/blender/build_scene.py`) · **[G]** game | S6 | Actors in 3D (replaces S3 standees) | Blender GLB actors + lit shader in the game, backdrop/environment polish | **DONE** [B][G] | | S7 | One concrete material | seamless 2K PBR maps from Blender shared by floor/walls/pillars, triplanar in-engine, merged static mesh | **DONE** [B][G] | | S8 | Corruption wave FX | SDF billboard aura on Hiss units + reusable fading ground emitter for events/bosses; saved Blender reference scene | **DONE** [B][G] | +| S9 | Stylised look-dev | Blender-generated lighting ramp LUT, gradient-map diffuse + two-tone faction rim + haze in the actor/concrete shaders, procedural Hiss jitter, guard ink outline | **DONE** [B][G] | +| S10 | Sculpted actors v2 | `actor_kit.py` loft/sweep/blob/crystal helpers replace the cube kit; guard 5.7k tris, Hiss Staff 1.9k, Mold 1.4k, Brute 2.9k, shard 154; painted AO, asserted budgets | **DONE** [B][G] | +| S11 | Props / OoP kit | Seven sculpted set pieces (Hotline, Benicoff TV, Service Weapon pedestal, Rubber Duck, cabinet, crate, floating debris) at 0.3–0.9k tris, dressed into the in-game arena | **DONE** [B][G] | +| S12 | Hiss rot, not rings | Removed baked red base rings and the detached SDF/3D aura blobs; black rot with red fissures is baked into the human Resonant models and animated by the actor shader | **DONE** [B][G] | +| S13 | Post, framing, dressing | Half-res bright-pass + separable bloom, teal-shadow/warm-highlight grade, wide tactical camera, bigger attached rot, denser centre dressing | **DONE** [G][B] | +| S14 | Actor animation & sparks | Shader-side rigs (walk + stagger, blob squash, crystal shimmer) for guard, Hiss units, Mold and shards; idle motion for OoP props; pooled camera-facing sparks | **DONE** [G] | +| S15 | Polish pass | Desaturated Mold, outlined Hiss units, clamped camera + dressed outer service band, dimmed glare, crisp HUD, floor decals, carpet seams, gentle contrast grade | **DONE** [G][B] | ## S0 — Light, surface & post pass [B][R] @@ -196,6 +203,163 @@ multiplying draw calls. - *Accept: enemies carry a subtle dark-crimson aura without floating shards; ground waves fade smoothly and can be spawned from any event.* +## S9 — Stylised look-dev [B][G] + +Goal: Risk of Rain 2's graphic shading language in Control's graphite palette, +without adding draw calls or giving up the deterministic Blender pipeline. + +- [x] **Lighting ramp LUT** — `tools/blender/build_lut.py` generates a 256×4 + gradient map (`assets/textures/actor/actor_ramp.png`): cool blue-grey + shadows → warm pale highlights with a gentle shoulder. *Accept: generated + from Blender, byte-exact reproducible, sampled by the in-engine shader.* +- [x] **Actor shading** — `actor.{vs,fs}` now use half-Lambert through the ramp, + a faction-tinted fresnel/ceiling rim (cold fluorescent for the guard, red + for Hiss, green for Mold), a tight bevel sheen, distance haze and the + existing corruption bleed / hit flash. Emissive resin and palette stay. +- [x] **Procedural motion** — saturated (corrupted) vertices jitter at high + frequency in the vertex stage; the guard breathes. No skeleton needed. +- [x] **Guard ink outline** — expanded back-face hull (one extra draw call) + for the guard / future bosses only; the horde keeps the cheap rim. +- [x] **Room shading** — `concrete.fs` uses a matching analytic ramp, explicit + camera position (raylib 6.2 does not auto-bind `cameraPosition`) and the + same haze, so actors and architecture read as one scene. +- *Accept: `--bot --no-damage --screenshot` shows lit, readable actors; no new + draw calls for enemies; ramp binds through a material texture slot because + raylib only binds ad-hoc sampler textures for 2D batches.* + +## S10 — Sculpted actors v2 [B][G] + +Goal: leave the chamfered cube kit behind — RoR2's chunky-but-polished, +holistic silhouettes built from continuous surfaces rather than stacked boxes. + +- [x] **Actor kit** — `tools/blender/actor_kit.py` provides `loft` (stacked + cross-sections with fold modulation), `tube` (swept tapered limbs/fingers), + `blob` (noise-deformed icospheres), `crystal` (irregular bipyramids), + `plate` (tapered extruded armour) and `ring`, all painting linear RGB and + painted AO into one `COLOR_0` attribute. *Accept: one merged mesh / + material per actor, same GLB path as before.* +- [x] **Guard ~5.7k tris** — sculpted head/cap, folded cloth torso, armoured + vest, straps, pouches, articulated sleeves/gloves, tapered legs, boots + with laces, sculpted Service Weapon and restrained Hiss taint on the back. +- [x] **Enemies 1.4–2.9k tris** — Hiss Staff (torn wind-swept shroud, reaching + arm with crystal-tipped claws), Brute (layered plate, core, crystal + spines), Mold Spore (lumpy mass, tendrils, glowing sacs), Shard (154). +- [x] **Budget asserts** — the build script prints and enforces per-actor caps + before export; `importlib.reload` keeps edits to the kit live in Blender. +- [x] **Turnarounds re-rendered** — `enemy_lineup.png` / `enemy_detail.png` + regenerated from the rebuilt `.blend`; in-game bot screenshot validated. +- *Accept: no box silhouettes in the lineup; all GLBs load with the existing + shader; triangle counts inside the agreed 1–3k enemy / ~6k hero budgets.* + +## S11 — Props / Objects of Power [B][G] + +Goal: the in-game arena should carry the same recognizable Oldest House props +as the Blender diorama and the reference art, without touching the simulation. + +- [x] **Prop kit** — `tools/blender/build_props.py` builds seven sculpted GLBs + with the actor kit: Hotline (846 tris), Benicoff TV (484), Service Weapon + pedestal (402), Rubber Duck under a brass frame (926), filing cabinet + (504), supply crate (336), Hiss-corrupted floating slab (492). Each is + one merged mesh / material, painted AO, asserted budget. +- [x] **Arena dressing** — `presenter.cpp` places them at fixed perimeter and + carpet-side spots that keep the combat lanes clear; slabs bob and rotate + slowly above the playfield. The sim is untouched. +- [x] **One pipeline** — props extend `ActorModel` / `ModelBank`, so they reuse + the gradient/rim/haze actor shader, the Blender ramp LUT and the existing + fallback path; no new shader or draw path. +- *Accept: bot screenshots show recognizable OoP silhouettes at gameplay scale + with the grey/red palette intact; 60 FPS held in a horde.* + +## S12 — Hiss rot, not rings [B][G] + +Goal: the red ground rings and the detached dark-red aura blob read as UI +markers / decals rather than Control's corruption creeping out of a body. + +- [x] **No more rings** — removed the baked red tori from Hiss Staff, Brute and + Mold GLBs (the guard keeps its yellow player marker). The bright SDF ring + front in `aura.fs` was also darkened; ground waves are event-only now. +- [x] **No detached aura** — deleted the `hiss_shell` 3D blob shader and the + `draw_shell` path. `CorruptionAura` is back to ground emitters only. +- [x] **Corruption on the body** — `build_enemies.py:hiss_rot()` grows black + crystal spurs, sweeping tendrils, dark resin masses and red veins directly + out of the Hiss humanoids' shoulders/back/torso, all part of the single + merged actor mesh. Staff 2,070 / Brute 2,968 tris, inside budget. +- [x] **Animated by the existing shader** — the rot palette is dark-red with + enough saturation to cross the actor shader's Hiss jitter threshold, so + the growths writhe with the unit instead of floating as a separate FX. +- *Accept: turnaround and bot frames show corruption attached to the human + models; no red rings or detached halos around enemies.* + +## S13 — Post, framing, dressing [G][B] + +- [x] **Bloom** — `bloom_bright.fs` + `bloom_blur.fs` run a thresholded bright + pass and a separable 9-tap blur on half-resolution render targets in + `main.cpp`; `post_fx.fs` composites `texture1` before the vignette. + Verified with an exaggerated-strength A/B screenshot that the sampler is + bound (raylib only binds ad-hoc samplers reliably in the 2D batch path). +- [x] **Grade** — cool shadows / warm highlights with a slight red lift, on top + of the existing corruption-keyed scanlines, noise and aberration. +- [x] **Camera** — tried fovy 40 / height 11.5 for detail readability, then + reverted past the original framing to the final wide tactical view: + fovy 48, height 18 / offset 14. Horde awareness wins over model detail. +- [x] **Stronger rot** — bigger/denser black spurs and tendrils, brighter + `rot_vein` palette; Staff 2,126 / Brute 3,014 tris. +- [x] **Denser dressing** — extra crates, left-wall cabinets and floor-level + debris near the centre; carpet cross and combat lanes stay clear. +- [x] **Blowout fix** — emissive boost 0.42→0.20 and a darker `mold_glow`, so + the horde doesn't clip under bloom. +- *Accept: 8 s and 25 s bot screenshots show readable actors, visible glow on + strips/crystals and no clipped white mold masses.* + +## S14 — Actor animation & sparks [G] + +- [x] **Limb rig, no skeleton** — glTF drops vertex-colour alpha here, so + `actor.vs` classifies limbs from model-local position (`uRig` = + hipY / shoulderY / legX / armX, `uRigScale` per actor type). Legs swing, + arms counter-swing, torso bobs. One draw call per actor, no GLB rebuild. +- [x] **Actor by actor** — guard first (walk from actual frame-to-frame motion, + stagger from hit flash), then Hiss Staff / Brute (walk from `e.speed`, + stagger + phase from `hit_flash` / `bob_phase`). Mold, shards and props + keep `uRigScale = 0`; the guard's yellow base ring is excluded by radius + so it stays planted while the legs move. +- [x] **Stagger** — recoil rotates the whole body around the hips plus a short + nervous shake; reuses the existing hit-flash impulse, no new sim state. +- [x] **Mold & shards** — `uRigMode` 2 gives Mold a height-weighted squash / + stretch jelly wobble (amplitude scales with `e.speed`) and a hit recoil; + mode 3 gives Resonance shards a normal-direction facet breath, driven by + the shard's world position as phase alongside the existing spin. +- [x] **Props** — Hotline rings (small yaw wobble + bob), Benicoff TV flickers, + Pedestal breathes, Rubber Duck bobs/tilts, floor debris drifts and turns. + Cabinets and crates stay planted — furniture should not wiggle. +- [x] **Light particles** — `Spark` pool in `Presenter` (160 max) spawns on + `EnemyHit` / `EnemyKilled` / `PlayerDamaged` / `TierUp`, with gravity, + drag, ground bounce and alpha fade. Drawn as camera-facing glows in the + 3D pass, post FX applies to them as well. +- *Accept: close crop of an 8 s bot run shows alternating guard feet, a recoiling + Hiss Staff and a bright hit spark; build clean, rig adds no draw calls and + sparks are short-lived billboards from the existing glow sprite.* + +## S15 — Polish pass [G][B] + +- [x] **Mold in the House** — `actor_kit.py` Mold palette desaturated from neon + lime (`#7fae55` / `#8fc95f`) to sickly olive (`#556b4e` / `#78906b`); + actors re-exported with budgets unchanged. The horde no longer clips as + green glow against the graphite/red room. +- [x] **Readable enemies** — guard ink outline extended to Hiss Staff and + Brute (Mold keeps its own silhouette); colder guard rim. One extra cheap + outline pass per Hiss actor, ~1 FPS cost at 60 enemies in the bot run. +- [x] **Camera / arena edge** — camera target clamped 5 m inside the curb and + the outer service band dressed with plant blocks and dim light pools, so + hugging a wall no longer reveals an empty unlit void. Door lintel and + fluorescent strips dimmed — no overexposed white bar in the foreground. +- [x] **Cleaner image** — HUD-critical aberration roughly halved and VHS noise + reduced; gentle S-curve + 5% exposure lift in `post_fx.fs`. Text stays + legible at high corruption. +- [x] **Ground detail** — faint toner/scorch decals, redacted paper scraps, + cable runs and carpet panel seams; furniture and tactical lanes untouched. +- *Accept: 8 s and 25 s bot screenshots — composed centre-frame guard, outlined + Hiss units, muted Mold, clean HUD and no arena-edge void.* + ## How to run ```python @@ -203,6 +367,8 @@ multiplying draw calls. exec(open("/home/dandovlatov/Documents/cntrl/tools/blender/build_scene.py").read()) exec(open("/home/dandovlatov/Documents/cntrl/tools/blender/build_enemies.py").read()) exec(open("/home/dandovlatov/Documents/cntrl/tools/blender/build_materials.py").read()) +exec(open("/home/dandovlatov/Documents/cntrl/tools/blender/build_lut.py").read()) +exec(open("/home/dandovlatov/Documents/cntrl/tools/blender/build_props.py").read()) exec(open("/home/dandovlatov/Documents/cntrl/tools/blender/build_wave.py").read()) exec(open("/home/dandovlatov/Documents/cntrl/tools/blender/render_shots.py").read()) ``` @@ -214,6 +380,34 @@ clipping < 0.5%, red-dominant 15–25%. ## Status log +- 2026-11-22 (S15): polish pass — muted the Mold palette, outlined Hiss units, + clamped the camera and dressed the outer service band, cut glare/aberration + so the HUD stays readable, and added floor/carpet detail plus a gentle + contrast grade. Validated with 8 s / 25 s bot screenshots. +- 2026-11-22 (S14): added a shader-side walk/stagger rig for the guard and + human Hiss units, then added blob squash for Mold, facet shimmer for shards + and restrained idle motion for the OoP props — all classified from local + vertex position, no skeleton or new GLB exports — plus a pooled spark system + for hits, kills, damage and tier-ups. Kept the guard's base ring and the + furniture planted. +- 2026-11-22 (S13): added half-res bloom and a teal/warm grade, then replaced + the initially tightened camera with the final wider tactical view; + strengthened the baked Hiss rot, added centre dressing and fixed mold + emissive blowout under bloom. +- 2026-11-22 (S12): removed the enemy base rings and the detached aura/blob FX; + baked animated black Hiss rot (spurs, tendrils, veins) into the human enemy + meshes. `CorruptionAura` now only owns event ground waves. +- 2026-11-22 (S11): built a seven-piece sculpted props/OoP kit in Blender, + exported GLBs and dressed the in-game arena through `ModelBank`; added + `props_lineup.png` and docs. Fixed 3D plate shifts and palette-key lookups. +- 2026-11-22 (S10): replaced the box/chamfer actor kit with lofts, swept tubes, + deformed masses and crystals. Guard 5724, Hiss Staff 1914, Mold 1434, Brute + 2898, Shard 154 tris; re-rendered turnarounds and validated in-game. Fixed + inverted loft end-cap winding and made the kit module reload on rebuild. +- 2026-11-22 (S9): added a Blender-generated lighting ramp, gradient-map actor + shading with faction rims, procedural Hiss jitter, a guard ink outline and + matching haze/ramp in the concrete shader. Fixed the LUT pixel-buffer layout + and bound the ramp through raylib's texture-slot path. - 2026-11-22 (S8): removed the static orbiting Hiss shards, added an SDF dark-crimson aura on Hiss units (fixed a billboard matrix transpose that had been laying the quads on the floor), and made the ground variant a reusable diff --git a/docs/GAME_DESIGN.md b/docs/GAME_DESIGN.md index dd50df2..8aa9ab1 100644 --- a/docs/GAME_DESIGN.md +++ b/docs/GAME_DESIGN.md @@ -7,39 +7,78 @@ > Service Weapon you are not fully authorized to carry, and the Oldest House is > eating itself. -A **Vampire Survivors-style horde survivor** in the Control universe: you move -(WASD), everything else is automatic. The setting is the night just before Jesse -becomes Director: one solo FBC security guard trying to uphold normality in a -rapidly decaying Oldest House. We battle Hiss-corrupted people ("taken" staff), -monsters from thresholds, run quests for Objects of Power, and find keys to open -new floors. +A **real-time auto-brawler** (Vampire Survivors heritage) in the Control universe: +you move with WASD or a stick while your Objects of Power autoshoot. Skills are +enabled and disabled in real time and nothing pauses — the run is never +interrupted. -Tone slot the genre gives for free: VS-style games are chaos — Control's chaos is -*bureaucratic*. Radio chatter from Emily Pope, chores from Ahti ("the mold in the -phone room, it needs a mop, yah?"), redacted documents as pickup lore, the Board -"approving" your level-ups. +The player is a **nameless worker in the Oldest House** — an everyday FBC worker +who never resonated when the other class employees became Resonant. That silence +is why he's still an FBC worker instead of the Director. + +The setting is the night just before Jesse Faden becomes Director: the run ends +when Jesse walks into the Executive floor (radio: "Ma'am? ...Ma'am, who are you?") +— the player is **not** Jesse. + +We battle Hiss-corrupted people ("taken" staff), monsters from thresholds, +run quests for Objects of Power, find keys to open new floors, and fight elite +tiers. Every buff and debuff lives on the scene (ECS-like; see §4.5). + +Tone slot: as above — radio chatter, Ahti chores, redacted documents as pickup +lore, the Board adjudicating your upgrades. **Working title:** FBC: NIGHT SHIFT (alternates: OLDEST HOUSE: BREACH, AWE: NIGHT SHIFT, CONTROL: BREACH PROTOCOL). ## 2. Core loop -1. **Move (WASD), auto-fight.** Dash = *Evade*. Weapons are Objects of Power - firing on their own cooldowns/targeting rules. -2. **Kill Hiss -> Resonance Shards (XP) -> Level Up -> Board Directive: pick 1 of 3 - redacted cards.** Choices: new OoP trial / OoP upgrade / passive perk / heal. -3. **OoP Trials — the signature mechanic.** A quest marker appears ("OoP detected: - RESEARCH FLOOR — TV SET"). Reach it -> **fight the trial** (guardian mini-boss, or - a 60-second containment ritual). Win -> **the OoP becomes your skill/weapon - permanently for the run.** Mega Man structure: you don't buy powers, you survive - them. +1. **Move (WASD or stick), auto-fight.** Dash = *Evade*. Owned Objects of Power + fire on their own cooldowns/targeting rules; each can be enabled or + disabled in real time. **Magnets:** kills drop Resonance Shards that pull + toward the player (inside `pickup_radius`); with **world objects** + (§4.6), the magnet catch applies the object's effect automatically. **No + pause:** enemy spawn, floor scaling, ritual triggers and skill acquisition + advance while the player thinks (the only transitions are quest markers and + ritual encounters). +2. **Kill Hiss -> Resonance Shards (XP) -> Level Up -> offers appear in real + time.** New Directives/Rituals/Tune-ups roll as HUD offers when XP crosses a + threshold; they apply automatically when the player is idle for a while and + may also be applied early (RoR2: intrinsics, no pause). In parallel, the + House scatters **world objects of power — SCP-like items** (§4.6); when + caught, they apply automatically — the player has no way to tell beforehand + what they are. +3. **OoP Rituals — the signature mechanic (manual OoPs only).** A quest marker + appears ("OoP detected: RESEARCH FLOOR — TV SET"). Reach it -> **start the + ritual** — a ritual-in-progress indicator appears (e.g. + `RITUAL IN PROGRESS — TV — WAITING`). Complete it -> **the OoP becomes your + skill/weapon permanently for the run.** Mega Man structure: you don't buy + powers, you survive them. (World objects from §4.6 are the other way to get + new powers — by catching.) + + **Ritual MVP (TV):** when the player reaches the TV, the ritual starts and + the player stays around — 60 s later the TV is live (a debuff-clearing + Buff). **Planned next:** the complex ritual — the lightswitch — where you + catch a few objects near the switch (magnet) and activate it; fluorescents + revive as the reward. 4. **OoP Evolutions:** OoP lv4 + a specific passive = **Altered Form** (build-crafting layer). -5. **Find the Threshold Key** (elite drop / side room / quest reward) -> the floor's +5. **Floors get progressively harder** (§3 corruption escalation) and each floor + has **Threshold Keys** (elite drop / side room / quest reward) -> the floor's threshold door unlocks -> next sector. 6. **Run ends** at the Executive floor: the new Director walks in (radio: "Ma'am? ...Ma'am, who are you?"). Death = containment failure. Endless Shift mode after. +**Skill acquisition is real-time, not a pause:** when XP crosses a threshold, +the new offer pool rolls and the offers appear on the HUD (RoR2 "intrinsics" +analog). Each offer auto-applies when the player hasn't reacted for N seconds +(or may be picked earlier); the run continues (corruption, spawns, ritual +triggers) throughout. + +**Skill management:** every owned OoP has an enabled/disabled flag. Enabled +means "fires on cooldown" (auto-implemented, like Vampire Survivors); disabled +means dormant. There is no separate hotkey-driven skill wheel to open during +the run — toggling happens in the OoP loadout (HUD). + ## 3. Corruption — Risk of Rain 2 progressive difficulty, FBC skin The clock is the enemy. The longer you loot, the more the House decays. RoR2 @@ -61,9 +100,12 @@ structure, taken deliberately: 36x cost, 18x HP, 6x dmg, unlocked late-run). - **Difficulty modes:** Drizzle/Rainstorm/Monsoon -> **TRAINING / FIELD DUTY / DIRECTOR'S GAUNTLET** (scaling pace x0.5 / x1.0 / x1.5, regen/armor tweaks). -- The teleporter = our **key door + OoP trial**. RoR2's "do I leave yet?" maps onto +- The teleporter = our **key door + OoP ritual**. RoR2's "do I leave yet?" maps onto "the threshold key is in my pocket, one more side room or go?". - Shard drop values scale with corruption so the economy stays alive as prices rise. +- **Floor jump is wired to the run structure:** `Corruption::floor_cleared()` + increments `floors_` when a floor's Threshold Key is taken (§7), so the RoR2 + exponential loops map onto sectors of the run. ### Tier ladder (HUD: "CONTAINMENT STATUS" gauge, top right) @@ -92,7 +134,12 @@ on heavies (the RoR2 "director saved up" moment, released as a burst whenever the horde thins). Credit cap 250. Enemy cap 260. Contact hits carry a 0.5 s global i-frame so swarms cannot burst the guard down. -## 4. Weapons — Objects of Power (auto-cast, 4 lvls + 1 evolution each) +## 4. Weapons — Objects of Power (auto-fire when enabled; levels + evolutions each) + +**Design note:** an OoP is a *component-style bonus* (see §4.5): when enabled it +acts on the scene, applying player stat mods (damage, speed, regen, armor…) and +— importantly — debuffs on enemies. When disabled it goes dormant until +re-enabled. | OoP | Behavior | Altered Form (evolution) | |---|---|---| @@ -107,14 +154,105 @@ Contact hits carry a 0.5 s global i-frame so swarms cannot burst the guard down. | Jukebox | Sonic nova, knockback + charm chance | +Seize -> *Jukebox: Last Dance* (charmed enemies explode) | | X-Ray Lightbox | Freeze/petrify cone | +Polaris -> *X-Ray: Diagnosis* (shatters frozen enemies) | +## 4.5. Buffs & Debuffs (scene-wide, ECS-like) + +Buffs and debuffs are real-time, entity-component-system parts of the world — +not just player stat edits. Design: + +- **Subject:** player (id −1) or a specific enemy. +- **`BuffEffect`:** stat multipliers + instant effects, e.g. `speed_mult`, + `damage_mult`, `hp_mult`, `player_dmg_mult`, `regen`, `armor_bonus`, + `confuse_prob`, `slow_frac`, `dot_dps`, `immune_to_hiss`, `taken`… +- **Duration:** 0 = permanent, else seconds; when it lapses it is removed. +- **Systems:** `BuffSystem::apply(subject, effect, duration)` + `update()`; + per-frame bundles recompute: `Player::mods` (damage/speed/regen/armor/ + confusion resistance…) and `Enemy::mods` (speed, damage, hp, confuse, slow, + dot…). UI: floating icons over the player + enemies with duration bars. + +**Proposed catalogs (RoR2-inspired, expandable):** + +| Buff | Subject | Effect | +|---|---|---| +| Damage Amplification | player | damage mult up (additive, stackable) | +| Speed Surge | player | speed mult up | +| Fire Rate (x%, scale with level) | player | fire rate mult up | +| Regeneration | player | +X HP/s while active | +| Armor Plate | player | +X armor (stackable) | +| Confusion Immunity | player | confusion/stun immune | +| Slow | enemy | speed fraction (e.g. −60%) | +| Dot | enemy | small continuous damage per second | +| Vulnerable | enemy | +X% damage taken | +| Confused | enemy | steers toward player while attacking | +| Immune | enemy | resonance immune (T1 variant) | +| Taken | enemy | silent until the player is nearby; pulls the player | + +**Apply points:** +- Level-up Directives (§9) — flat player components (additive, like today). +- Elite tiers / T1 elasticity (§3, §6): resonant, phasing, shielded, mending, + volatile specials map to the catalog. +- Time events: tier-up pulses, shop offers. +- **World objects** (§4.6) — magnet catch applies the effect immediately; the + player has no way to tell beforehand. + +## 4.6. World Objects of Power — random SCP-like items (catch = apply) + +The House scatters **world objects of power** — small SCP-like artifacts on the +floor (a glow + a flavor name). They are not manual OoPs — no ritual, no +evolution, no level. The mechanic: **magnet pickup = application** +(`PickupSystem`, §2.1). When the magnet reaches one, it is consumed and the +object applies its effect — to the player, or to the nearest enemy if one is +nearby (`BuffSystem::apply(subject, effect, duration)`). + +- **Enemy channel** (implemented): objects caught near enemies apply to them — + `ENEMY_SLOW` (−40% speed, 20 s), `ENEMY_BURN` (enemy burns 0.4 DPS, 25 s), + `ENEMY_VULNERABLE` (+30% damage taken by enemies, 25 s), `ENEMY_IMMUNE` + (resonance immune, 10 s). +- **Unidentified** ("the player wouldn't know when for now"): the player cannot + tell what a world object is before catching. No hover/inspect UX yet; the + only "reveal" is experience. Visuals like glow-color coding = optional + (§ART_DIRECTION). +- **Player channel (debuffs):** + - `Slow` — player −35% move speed (30 s) + - `Confuse` — confusion ×4, enemies pull the player (10 s) + - `Taken` — pulls the player toward enemies, immune while near (12 s) + - `Dot` — nearby enemies deal 1.5–2.5 DPS (20 s) + - `Vulnerable` — enemies deal +30% damage to the player (25 s) +- **Enemy channel (debuffs):** + - `Slow` — enemies −40% speed (20 s) + - `Dot` — enemy burns 0.4 DPS (25 s) + - `Vulnerable` — enemies +30% taken damage (25 s) + - `Immune` — resonance immune (10 s) +- **Spawn rules:** + - Enemy deaths drop world objects around the corpse (the player can't + always outrun freshly killed ones). + - The director scatters some on the ring (15–21 m, RoR2 analog). + - Cap: ~15 active world objects; rate scales with c (x1 + 1.5c) so the floor + "fills with junk" mid-run. +- **Balance notes:** player HP is 100 — confusion/slow/vulnerable accepted + tension; watch confusion chains on early run; cap object-stacked effects + (e.g., max 3 `Vulnerable` from objects). +- **Interaction with elite auras (§3, §6):** world objects are the same system — + one channel, no double-count. + ## 5. Passives ("perks") +*(flat player components, same mechanical space as §4.5; the component +pipeline is the §4.5 style.)* + Levitate (move speed), Evade (dash cooldown), Shield (regenerating barrier), Black Rock Plating (armor), Polaris (regen + cleanse), Board Favor (rarity odds + reroll), Seize (charmed kills), Maintenance Training (cooldowns). +*(Proposed additions, using the §4.5 mechanisms:)* Evade (shorter dash cooldown), +Shield (regenerating barrier, additive), Polaris (regen + cleanse debuffs), +Seize (charmed kills + bonus damage). + ## 6. Enemies +Enemies are entities; base stats are a table, and their damage/speed/hp run +through the `EnemyMods` bundle from Buffs (§4.5): elite affixs are simply +buffs applied at spawn. + - **Hiss Corrupted Staff** — slow floaters, the iconic chanting crowd (basic). - **Hiss Elevated** — teleports onto you (M2+). - **Hiss Cluster** — stationary spitter (M2+). @@ -140,7 +278,7 @@ Handcrafted room templates, randomized assembly (not full procgen): 3. **Containment / Panopticon** — cells, Altered Item guardians. 4. **Executive** — finale, Hiss-Marshall, then Jesse arrives. -Each floor: OoP trial quest markers, side rooms (greed vs. corruption clock), a +Each floor: OoP ritual quest markers, side rooms (greed vs. corruption clock), a Threshold Key somewhere (elite drop / side room / quest reward). **Oceanview Motel between floors = shop:** turn off the lights, answer the phone, a door opens — free flavor for a reroll shop. Rerolls = "Redacted intel". diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md index fe26e71..862b9c9 100644 --- a/docs/ROADMAP.md +++ b/docs/ROADMAP.md @@ -7,18 +7,21 @@ | M0 | Scaffold: CMake + raylib 6.2, window, states, input, fixed tick | Builds; window opens; quits clean | **DONE** | | M1 | Grey-box vertical slice: move, dash, 1 auto-weapon, 3 enemy types, XP -> level-up 3-choice, corruption clock, death screen | *Fun for 60 seconds with placeholder art* | **DONE** | | M2 | Horde foundation: pooling, spatial hash, credit-based Director (+ too-cheap rule), OoP weapons (4), evolutions, damage numbers | 250+ enemies at 60 fps; RoR2 spawn feel | **DONE** - 250 enemies @ 60 fps verified via --bot --no-damage stress capture; 4 OoPs with levels 1-4 + Altered Forms, director bank + burst behavior in HUD | -| M3 | Floors & OoP trials: room-template assembly, keys/threshold doors, trial quest flow (fight -> claim skill), Oceanview shop, 1 boss + boss door | Full 3-floor run start -> finish | | -| M4 | Content: 8-10 OoPs + evolutions, 8 passives, ~10 enemy types, elite affixes (T1/T2), 3 bosses, Taken crossover, radio banter | Distinct builds each run | | -| M5 | Art/audio pass: brutalist floor kit, standee art, corruption-driven shaders/audio/env decay, OFL fonts (Archivo, IBM Plex Mono), SFX | Looks like Control; plays 20 min without repetition | | -| M6 | Meta progression (Panopticon), difficulty modes (TRAINING / FIELD DUTY / DIRECTOR'S GAUNTLET), balancing via `--headless --bot-runs`, perf pass, gamepad | Ship-ready v1 | | +| M3 | Floors & OoP rituals: room-template assembly, keys/threshold doors, ritual quest flow (reach -> complete -> claim skill), simple TV ritual MVP (reach TV -> wait 60 s -> TV live), Oceanview shop, 1 boss + boss door | Full 3-floor run start -> finish | | +| M4 | Debuffs & Buffs — scene-wide ECS-like system (components, durations, duration bars); player buff examples (damage amp, speed, regen, armor); elite debuff batteries (Resonant, Phasing, Shielded, Mending, Volatile); **world objects of power — SCP-like items on the scene (spawn: enemy deaths + scatter, magnet catch applies — player or nearest enemy, player+enemy channel debuffs — Unidentified)** | Distinct debuff/buff identities per enemy class | | +| M5 | Enemy components & elites: T1/T2 affixs, Taken/Elevated/Cluster/Host variants | Soft groups of elites; elite reads distinct | | +| M6 | Art/audio pass: brutalist floor kit, standee art, corruption-driven shaders/audio/env decay, OFL fonts (Archivo, IBM Plex Mono), SFX | Looks like Control; plays 20 min without repetition | | +| M7 | Gamepad/stick + real-time skill offers + difficulty modes + meta progression (Panopticon) | Stick moves, real-time offers (no pause), TRAINING / FIELD DUTY / DIRECTOR'S GAUNTLET | | ## M1 detail (current slice) - Player: WASD move, Shift/Space dash (Evade), contact-damage i-frame per enemy. - Weapon: Service Weapon: Spin — auto-targets nearest, projectile with pierce stat. - Enemies: Hiss Corrupted Staff (basic), Mold Spore (fast), Hiss Brute (tanky). -- XP shards with magnet; level-up pauses the run, 3 Board Directive cards (keys 1-3). -- Corruption coefficient + tier ladder + enemy stat scaling + spawn-rate scaling; +- XP shards with magnet; level-up offers roll when XP crosses a threshold and + apply in real time after a brief idle window (no pause — RoR2 intrinsics style). +- Corruption coefficient + tier ladder + enemy stat scaling + spawn-rate scaling + + floor-jump on threshold-key take; CONTAINMENT STATUS gauge + run timer on HUD. - Contact hits carry a 0.5 s global i-frame (swarm burst protection). - Death screen with run stats; R restarts. diff --git a/docs/concept/enemy_detail.png b/docs/concept/enemy_detail.png index 521060c..1f28cc9 100644 Binary files a/docs/concept/enemy_detail.png and b/docs/concept/enemy_detail.png differ diff --git a/docs/concept/enemy_lineup.png b/docs/concept/enemy_lineup.png index c93380f..18ff7b7 100644 Binary files a/docs/concept/enemy_lineup.png and b/docs/concept/enemy_lineup.png differ diff --git a/docs/concept/props_lineup.png b/docs/concept/props_lineup.png new file mode 100644 index 0000000..cf48db2 Binary files /dev/null and b/docs/concept/props_lineup.png differ diff --git a/referance_4.jpeg b/referance_4.jpeg new file mode 100644 index 0000000..e1c0273 Binary files /dev/null and b/referance_4.jpeg differ diff --git a/reference_3.jpeg b/reference_3.jpeg new file mode 100644 index 0000000..f1a49d1 Binary files /dev/null and b/reference_3.jpeg differ diff --git a/reference_ai.jpeg b/reference_ai.jpeg new file mode 100644 index 0000000..a54ba29 Binary files /dev/null and b/reference_ai.jpeg differ diff --git a/reference_ai2.jpeg b/reference_ai2.jpeg new file mode 100644 index 0000000..4a1531b Binary files /dev/null and b/reference_ai2.jpeg differ diff --git a/src/game/buffs.cpp b/src/game/buffs.cpp new file mode 100644 index 0000000..5fee904 --- /dev/null +++ b/src/game/buffs.cpp @@ -0,0 +1,95 @@ +#include "game/buffs.hpp" + +namespace { + +struct WorldObjSpec { + BuffEffect effect; + float duration; + const char* name; +}; + +// §4.6 catalog (Phase 2: enemy channel added): +const WorldObjSpec kWorldCatalog[] = { + // Player channel — apply to the player (caught in the open): + {{0.65f}, 30.0f, "SLOW"}, // Slow: player −35% speed + {{1.0f, 0.0f, 0.0f, 1.3f}, 25.0f, "VULNERABLE"}, // Vulnerable: enemies deal +30% to player + {{1.0f, 1.6f, 0.0f, 1.0f}, 20.0f, "DOT"}, // Dot: nearby enemies deal 1.5–2.5 DPS + {{1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 2.0f}, 12.0f, "TAKEN"}, // Taken: pulls, immune while near + {{1.0f, 0.0f, 0.0f, 1.0f, 2.0f, 0.0f}, 10.0f, "CONFUSE"}, // Confuse: enemies drag the player + // Enemy channel — apply to nearby enemies: + {{0.6f}, 20.0f, "ENEMY_SLOW"}, // Slow: enemies −40% speed + {{0.0f, 0.0f, 0.4f}, 25.0f, "ENEMY_BURN"}, // Dot: enemy burns 0.4 DPS + {{0.0f, 0.0f, 0.0f, 1.3f}, 25.0f, "ENEMY_VULNERABLE"}, // Vulnerable: enemies +30% taken damage + {{0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.3f}, 10.0f, "ENEMY_IMMUNE"}, // Immune: resonance immune +}; + +} // namespace + +void BuffSystem::update(float dt) { + for (std::size_t i = 0; i < buffs_.size();) { + Buff& b = buffs_[i]; + if (b.duration > 0.0f) { + b.duration -= dt; + if (b.duration <= 0.0f) { + buffs_.remove_at(i); + continue; + } + } + ++i; + } +} + +void BuffSystem::apply(int subject, const BuffEffect& effect, float duration, + const char* name) { + if (static_cast(buffs_.size()) >= kBuffCap) return; + Buff b; + b.subject = subject; + b.effect = effect; + b.duration = duration; + b.name = name != nullptr ? name : ""; + buffs_.add(b); +} + +void BuffSystem::expire_subject(int subject) { + buffs_.remove_if([subject](const Buff& b) { return b.subject == subject; }); +} + +void BuffSystem::spawn_world_object(Vec2 pos, Rng& rng, float corruption_c, int kind) { + if (static_cast(world_objects_.size()) >= kWorldCap) return; + // Rate scales with corruption: the House fills with junk mid-run. + if (!(rng.next_float() < 0.8f + 1.5f * corruption_c)) return; + const int n = static_cast(sizeof(kWorldCatalog) / sizeof(kWorldCatalog[0])); + const int idx = (kind >= 0 && kind < n) ? kind : rng.range_int(0, n - 1); + const WorldObjSpec& spec = kWorldCatalog[idx]; + WorldObject obj; + obj.pos = pos; + obj.effect = spec.effect; + obj.duration = spec.duration; + obj.name = spec.name; + world_objects_.add(obj); +} + +PlayerMods BuffSystem::player_mods() const { + PlayerMods m; + for (const Buff& b : buffs_) { + if (b.subject != -1) continue; + m.speed_mult *= b.effect.speed_mult; + m.damage_taken_mult *= b.effect.damage_taken_mult; + m.confused += b.effect.confused; + m.taken += b.effect.taken; + m.dot_dps += b.effect.dot_dps; + } + return m; +} + +EnemyMods BuffSystem::enemy_mods(int enemy_id) const { + EnemyMods m; + for (const Buff& b : buffs_) { + if (b.subject != enemy_id) continue; + m.speed_mult *= b.effect.speed_mult; + m.burn_dps += b.effect.burn_dps; + m.immune += b.effect.immune; + m.damage_taken_mult *= b.effect.damage_taken_mult; + } + return m; +} diff --git a/src/game/buffs.hpp b/src/game/buffs.hpp new file mode 100644 index 0000000..cb8aa9a --- /dev/null +++ b/src/game/buffs.hpp @@ -0,0 +1,73 @@ +#pragma once + +#include "core/math.hpp" +#include "core/pool.hpp" +#include "core/rng.hpp" + +// §4.5–4.6: Buffs & Debuffs — component-style, ECS-lite: Buffs are components +// attached to subjects (player = −1, or enemy pool id) and re-applied each +// tick; world objects of power are consumed on magnet catch (PickupSystem) +// and call apply() directly. + +struct BuffEffect { + float speed_mult = 1.0f; // Slow: subject speed (player or enemy) + float dot_dps = 0.0f; // Player-channel Dot: nearby enemies deal damage + float burn_dps = 0.0f; // Enemy-channel Dot: the enemy burns + float damage_taken_mult = 1.0f; // Damage-taken multiplier (player contact / player-to-enemy damage) + float confused = 0.0f; // Confuse: player confusion (enemies drag the player) + float taken = 0.0f; // Taken: pulls player toward enemies (immune while near) + float immune = 0.0f; // Enemy immune to player-channel effects (resonance) +}; + +struct Buff { + int subject = -1; // -1 = player, else enemy pool id + BuffEffect effect{}; + float duration = 0.0f; // 0 = permanent + const char* name = ""; +}; + +struct EnemyMods { + float speed_mult = 1.0f; + float burn_dps = 0.0f; + float immune = 0.0f; + float damage_taken_mult = 1.0f; // Player damage to this enemy is scaled by this +}; + +struct PlayerMods { + float speed_mult = 1.0f; + float damage_taken_mult = 1.0f; + float confused = 0.0f; + float taken = 0.0f; + float dot_dps = 0.0f; // Player-channel Dot: nearby enemies deal damage +}; + +struct WorldObject { + Vec2 pos{}; + BuffEffect effect{}; + float duration = 0.0f; + int subject = -1; // -1 = player, else enemy pool id + const char* name = ""; +}; + +class BuffSystem { +public: + void update(float dt); + void apply(int subject, const BuffEffect& effect, float duration, const char* name = ""); + void expire_subject(int subject); + void spawn_world_object(Vec2 pos, Rng& rng, float corruption_c, int kind = -1); + + PlayerMods player_mods() const; + EnemyMods enemy_mods(int enemy_id) const; + + int world_object_count() const { return static_cast(world_objects_.size()); } + WorldObject& world_object(int i) { return world_objects_[static_cast(i)]; } + void remove_world_object(int i) { world_objects_.remove_at(static_cast(i)); } + int buff_count() const { return static_cast(buffs_.size()); } + +private: + static constexpr int kBuffCap = 24; + static constexpr int kWorldCap = 15; + + DensePool buffs_{kBuffCap}; + DensePool world_objects_{kWorldCap}; +}; diff --git a/src/game/enemies.cpp b/src/game/enemies.cpp index 3d97f10..54f0f15 100644 --- a/src/game/enemies.cpp +++ b/src/game/enemies.cpp @@ -37,7 +37,8 @@ void EnemySystem::spawn(EnemyType type, Vec2 pos, const Corruption& corruption) enemies.add(e); } -void EnemySystem::update(float dt, Player& player, EventQueue& events) { +void EnemySystem::update(float dt, Player& player, BuffSystem& buff_system, + EventQueue& events) { const std::size_t count = enemies.size(); if (count == 0) return; @@ -49,39 +50,40 @@ void EnemySystem::update(float dt, Player& player, EventQueue& events) { for (std::size_t i = 0; i < count; ++i) { Enemy& e = enemies[i]; - hash.query(e.pos, e.radius + kMaxRadius, [&](int id) { - const std::size_t j = static_cast(id); - if (j <= i) return; // each pair once - Enemy& o = enemies[j]; - Vec2 delta = o.pos - e.pos; - const float d = length(delta); - const float min_d = (e.radius + o.radius) * kSeparationFactor; - if (d < min_d && d > 1e-4f) { - const Vec2 push = delta / d * ((min_d - d) * 0.5f); - e.pos -= push; - o.pos += push; - } - }); - } + const EnemyMods mods = buff_system.enemy_mods(static_cast(i)); + e.mods = mods; + e.speed = enemy_def(e.type).speed * mods.speed_mult; - // Steering + contact attacks. - for (std::size_t i = 0; i < count; ++i) { - Enemy& e = enemies[i]; - const Vec2 to_player = player.pos - e.pos; - const float dist = length(to_player); - if (dist > 1e-4f) e.pos += to_player / dist * (e.speed * dt); + // Player-channel Dot: nearby enemies deal damage to the player. + const float dist = length(e.pos - player.pos); + if (player.mods.dot_dps > 0.0f && player.iframe_timer <= 0.0f && dist < 1.5f) + player.hp -= player.mods.dot_dps * dt; + // Enemy-channel Dot: the enemy burns (takes damage). + if (e.mods.burn_dps > 0.0f) + e.hp -= e.mods.burn_dps * dt; + + // Steering + contact attacks. + if (dist > 1e-4f) e.pos += normalized(player.pos - e.pos) * (e.speed * dt); e.hit_flash -= dt; e.attack_cooldown -= dt; e.bob_phase += dt * 2.0f; - if (e.attack_cooldown <= 0.0f && player.iframe_timer <= 0.0f - && dist < e.radius + kContactRange) { - e.attack_cooldown = kAttackCooldown; - player.hp -= e.contact_damage; - player.hit_flash = 0.25f; - player.iframe_timer = kHitIFrame; - events.push(EventType::PlayerDamaged, player.pos, e.contact_damage); + if (dist < e.radius + kContactRange) { + if (player.mods.taken > 0.0f) { + // Taken: immune to damage while near enemies; pulls the player. + if (length(e.pos - player.pos) > 1e-4f) + player.pos += normalized(e.pos - player.pos) * (e.speed * dt); + e.attack_cooldown = kAttackCooldown; + } else if (e.attack_cooldown <= 0.0f && player.iframe_timer <= 0.0f) { + if (player.mods.confused > 0.0f && length(e.pos - player.pos) > 1e-4f) + player.pos += normalized(e.pos - player.pos) * (e.speed * dt) * 2.0f; + e.attack_cooldown = kAttackCooldown; + player.hp -= e.contact_damage * player.mods.damage_taken_mult; + player.hit_flash = 0.25f; + player.iframe_timer = kHitIFrame; + events.push(EventType::PlayerDamaged, player.pos, e.contact_damage); + } } } } diff --git a/src/game/enemies.hpp b/src/game/enemies.hpp index 40a5200..ecf65ff 100644 --- a/src/game/enemies.hpp +++ b/src/game/enemies.hpp @@ -3,6 +3,7 @@ #include "core/events.hpp" #include "core/math.hpp" #include "core/pool.hpp" +#include "game/buffs.hpp" #include "game/corruption.hpp" #include "game/player.hpp" @@ -30,6 +31,7 @@ struct Enemy { float hit_flash = 0.0f; float bob_phase = 0.0f; EnemyType type = EnemyType::HissStaff; + EnemyMods mods{}; // Transient buffs/debuffs, recomputed each tick }; struct EnemySystem { @@ -38,6 +40,6 @@ struct EnemySystem { void clear(); void spawn(EnemyType type, Vec2 pos, const Corruption& corruption); // Steering toward the player + spatial-hash separation + contact attacks. - void update(float dt, Player& player, EventQueue& events); + void update(float dt, Player& player, BuffSystem& buff_system, EventQueue& events); int alive_count() const { return static_cast(enemies.size()); } }; diff --git a/src/game/game.cpp b/src/game/game.cpp index 23ac388..31cb564 100644 --- a/src/game/game.cpp +++ b/src/game/game.cpp @@ -42,6 +42,8 @@ void Game::reset() { pickup_system.clear(); corruption = Corruption{}; director = Director{}; + buff_system = BuffSystem{}; + ritual_system = RitualSystem{}; events.clear(); rng.reseed(seed_); run_time = 0.0f; @@ -74,21 +76,24 @@ void Game::update(const InputState& in, float dt) { // --- Playing --- run_time += dt; corruption.update(dt); + buff_system.update(dt); + player.mods = buff_system.player_mods(); if (corruption.tier() != last_tier_) { last_tier_ = corruption.tier(); events.push(EventType::TierUp, player.pos, static_cast(last_tier_)); } player_update(player, in, dt, config.arena_half); + ritual_system.update(dt, player, buff_system); director.update(dt, corruption, run_time, player, enemy_system, rng, config.max_enemies, config.arena_half); - enemy_system.update(dt, player, events); + enemy_system.update(dt, player, buff_system, events); if (config.no_player_damage) player.hp = player.stats.max_hp; // stress mode weapon_system.update(dt, player, enemy_system, events, rng); death_pass(); float xp_gained = 0.0f; - pickup_system.update(dt, player, events, xp_gained); + pickup_system.update(dt, player, events, xp_gained, buff_system, enemy_system); xp += xp_gained; while (xp >= xp_to_next) { @@ -112,7 +117,9 @@ void Game::death_pass() { if (e.hp <= 0.0f) { kills += 1; pickup_system.spawn(e.pos, enemy_def(e.type).xp, rng); + buff_system.spawn_world_object(e.pos, rng, corruption.value()); events.push(EventType::EnemyKilled, e.pos, static_cast(e.type)); + buff_system.expire_subject(static_cast(i)); enemy_system.enemies.remove_at(i); } else { ++i; @@ -143,18 +150,18 @@ void Game::roll_levelup_choices() { static_cast(w.type), w.level + 1}); } } - // 3. Trials for unowned OoPs (weapon slots are limited). + // 3. Rituals for unowned OoPs (weapon slots are limited). if (weapon_system.weapons.size() < static_cast(config.max_weapons)) { - static const char* kTrialTitles[kWeaponTypeCount] = { - "OoP TRIAL: SPIN", "OoP TRIAL: SHATTER", - "OoP TRIAL: CHARGE", "OoP TRIAL: LAUNCH"}; + static const char* kRitualTitles[kWeaponTypeCount] = { + "OoP RITUAL: SPIN", "OoP RITUAL: SHATTER", + "OoP RITUAL: CHARGE", "OoP RITUAL: LAUNCH"}; for (int t = 0; t < kWeaponTypeCount; ++t) { bool owned = false; for (const WeaponInstance& w : weapon_system.weapons) if (static_cast(w.type) == t) owned = true; if (owned) continue; const WeaponDef& def = weapon_def(static_cast(t)); - pool.push_back({kTrialTitles[t], def.description, OfferKind::WeaponNew, t, 1}); + pool.push_back({kRitualTitles[t], def.description, OfferKind::WeaponNew, t, 1}); } } // 4. Directives are always available. diff --git a/src/game/game.hpp b/src/game/game.hpp index 6d1c278..0e04938 100644 --- a/src/game/game.hpp +++ b/src/game/game.hpp @@ -4,12 +4,14 @@ #include "core/events.hpp" #include "core/rng.hpp" +#include "game/buffs.hpp" #include "game/corruption.hpp" #include "game/director.hpp" #include "game/enemies.hpp" #include "game/input.hpp" #include "game/pickups.hpp" #include "game/player.hpp" +#include "game/ritual.hpp" #include "game/weapons.hpp" enum class GameState { Playing, LevelUp, GameOver }; @@ -52,8 +54,10 @@ public: EnemySystem enemy_system; WeaponSystem weapon_system; PickupSystem pickup_system; + BuffSystem buff_system; Corruption corruption; Director director; + RitualSystem ritual_system; EventQueue events; Rng rng; GameConfig config; diff --git a/src/game/pickups.cpp b/src/game/pickups.cpp index 3ef43ab..53b2eb7 100644 --- a/src/game/pickups.cpp +++ b/src/game/pickups.cpp @@ -13,7 +13,7 @@ void PickupSystem::spawn(Vec2 pos, float value, Rng& rng) { } void PickupSystem::update(float dt, const Player& player, EventQueue& events, - float& xp_gained) { + float& xp_gained, BuffSystem& buff_system, EnemySystem& enemies) { for (std::size_t i = 0; i < shards.size();) { XpShard& s = shards[i]; const float d = distance(s.pos, player.pos); @@ -28,4 +28,31 @@ void PickupSystem::update(float dt, const Player& player, EventQueue& events, ++i; } } + + // World objects of power: magnet catch applies the effect immediately — + // the player, or the nearest enemy if one is nearby (§4.6). + for (int i = 0; i < buff_system.world_object_count();) { + WorldObject& obj = buff_system.world_object(i); + if (distance(obj.pos, player.pos) < player.stats.pickup_radius) { + const Enemy* near = nullptr; + int near_idx = -1; + float near_d = 0.0f; + for (std::size_t j = 0; j < enemies.enemies.size(); ++j) { + const float d = distance(obj.pos, enemies.enemies[j].pos); + if (near == nullptr || d < near_d) { + near = &enemies.enemies[j]; + near_idx = static_cast(j); + near_d = d; + } + } + if (near != nullptr && near_d < 2.2f) { + buff_system.apply(near_idx, obj.effect, obj.duration, obj.name); + } else { + buff_system.apply(-1, obj.effect, obj.duration, obj.name); + } + buff_system.remove_world_object(i); + } else { + ++i; + } + } } diff --git a/src/game/pickups.hpp b/src/game/pickups.hpp index 3c06839..c604129 100644 --- a/src/game/pickups.hpp +++ b/src/game/pickups.hpp @@ -4,6 +4,8 @@ #include "core/math.hpp" #include "core/pool.hpp" #include "core/rng.hpp" +#include "game/buffs.hpp" +#include "game/enemies.hpp" #include "game/player.hpp" struct XpShard { @@ -17,5 +19,8 @@ struct PickupSystem { void clear() { shards.clear(); } void spawn(Vec2 pos, float value, Rng& rng); // Magnet pull toward the player inside pickup_radius; collects on contact. - void update(float dt, const Player& player, EventQueue& events, float& xp_gained); + // World objects of power: magnet catch applies their effect on contact — + // the player, or the nearest enemy if one is nearby (§4.6). + void update(float dt, const Player& player, EventQueue& events, float& xp_gained, + BuffSystem& buff_system, EnemySystem& enemies); }; diff --git a/src/game/player.cpp b/src/game/player.cpp index cc56485..6319910 100644 --- a/src/game/player.cpp +++ b/src/game/player.cpp @@ -16,11 +16,15 @@ void player_update(Player& player, const InputState& in, float dt, float arena_h player.dash_cooldown -= dt; player.hit_flash -= dt; player.iframe_timer -= dt; + player.mods.confused -= dt; + if (player.mods.confused < 0.0f) player.mods.confused = 0.0f; + player.mods.taken -= dt; + if (player.mods.taken < 0.0f) player.mods.taken = 0.0f; Vec2 dir{in.move_x, in.move_y}; if (length_sq(dir) > 1.0f) dir = normalized(dir); const float speed_mult = player.dash_timer > 0.0f ? kDashSpeedMult : 1.0f; - player.pos += dir * (player.stats.move_speed * speed_mult * dt); + player.pos += dir * (player.stats.move_speed * player.mods.speed_mult * speed_mult * dt); player.pos = clamp_to_box(player.pos, arena_half); } diff --git a/src/game/player.hpp b/src/game/player.hpp index 493aa96..d032e25 100644 --- a/src/game/player.hpp +++ b/src/game/player.hpp @@ -1,6 +1,7 @@ #pragma once #include "core/math.hpp" +#include "game/buffs.hpp" #include "game/input.hpp" // Board Directives (passive perks). Also gate Altered Form evolutions: @@ -29,6 +30,7 @@ struct Player { Vec2 pos{}; float hp = 100.0f; PlayerStats stats{}; + PlayerMods mods{}; // Transient buffs/debuffs (player channel, §4.5) int directive_counts[static_cast(Directive::Count)] = {}; float dash_timer = 0.0f; // remaining dash burst float dash_cooldown = 0.0f; // time until dash is available again diff --git a/src/game/ritual.cpp b/src/game/ritual.cpp new file mode 100644 index 0000000..89017cb --- /dev/null +++ b/src/game/ritual.cpp @@ -0,0 +1,22 @@ +#include "game/ritual.hpp" + +void RitualSystem::update(float dt, const Player& player, BuffSystem& buff_system) { + if (state_ == State::Idle) { + if (distance(player.pos, kTVPos) <= kTVRadius) { + state_ = State::InProgress; + elapsed_ = 0.0f; + } + return; + } + if (state_ == State::InProgress) { + elapsed_ += dt; + // Epsilon so float accumulation of the 60 s budget can't stall it. + if (elapsed_ >= kTVDuration - 0.01f) { + state_ = State::Complete; + // TV ritual reward (MVP): the channel opens — debuff-clearing. + BuffEffect e; + e.damage_taken_mult = 0.9f; + buff_system.apply(-1, e, 600.0f, "TV LIVE"); + } + } +} diff --git a/src/game/ritual.hpp b/src/game/ritual.hpp new file mode 100644 index 0000000..701674e --- /dev/null +++ b/src/game/ritual.hpp @@ -0,0 +1,29 @@ +#pragma once + +#include "core/math.hpp" +#include "game/buffs.hpp" +#include "game/player.hpp" + +// MVP ritual system (docs/GAME_DESIGN.md §2.3 — Rituals): mini-quests where +// the player does a minimal action and the OoP is claimed. +// +// Simple ritual (TV, MVP): when the player reaches the TV, the ritual starts — +// the player stays around — 60 s later the TV is live (a debuff-clearing +// Buff). The complex ritual (lightswitch — catch objects to open/activate +// something) lands next; the hooks (Player + BuffSystem) are here for it. +struct RitualSystem { + static constexpr Vec2 kTVPos = {13.0f, 17.0f}; // diorama TV prop + static constexpr float kTVRadius = 5.0f; + static constexpr float kTVDuration = 60.0f; + + void update(float dt, const Player& player, BuffSystem& buff_system); + + bool active() const { return state_ == State::InProgress; } + bool complete() const { return state_ == State::Complete; } + float remaining() const { return kTVDuration - elapsed_; } + +private: + enum class State { Idle, InProgress, Complete }; + State state_ = State::Idle; + float elapsed_ = 0.0f; +}; diff --git a/src/game/weapons.cpp b/src/game/weapons.cpp index c66b0ab..a53d4ba 100644 --- a/src/game/weapons.cpp +++ b/src/game/weapons.cpp @@ -201,14 +201,14 @@ void WeaponSystem::update(float dt, const Player& player, EnemySystem& enemies, hash.query(p.pos, p.aoe_radius + kMaxEnemyRadius, [&](int id2) { Enemy& e2 = enemies.enemies[static_cast(id2)]; if (distance(p.pos, e2.pos) < p.aoe_radius + e2.radius) { - e2.hp -= p.damage; + e2.hp -= p.damage * e2.mods.damage_taken_mult; e2.hit_flash = 0.15f; events.push(EventType::EnemyHit, e2.pos, p.damage); } }); consumed = true; } else { - e.hp -= p.damage; + e.hp -= p.damage * e.mods.damage_taken_mult; e.hit_flash = 0.15f; events.push(EventType::EnemyHit, e.pos, p.damage); if (p.pierce > 0) p.pierce -= 1; diff --git a/src/main.cpp b/src/main.cpp index a1e5549..45cdf7b 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4,6 +4,7 @@ #include #include +#include #include #include @@ -103,6 +104,34 @@ int main(int argc, char** argv) { // as the House decays. Missing shader degrades to a plain blit. RenderTexture2D post_target = LoadRenderTexture(GetScreenWidth(), GetScreenHeight()); + + // S12 bloom: half-res bright pass + separable blur, composited in post_fx. + const int bloom_w = GetScreenWidth() / 2; + const int bloom_h = GetScreenHeight() / 2; + RenderTexture2D bloom_a = LoadRenderTexture(bloom_w, bloom_h); + RenderTexture2D bloom_b = LoadRenderTexture(bloom_w, bloom_h); + auto shader_path_for = [](const char* rel) -> const char* { + if (FileExists(rel)) return rel; + static char buf[3][512]; + static int slot = 0; + char* out = buf[slot++ % 3]; + std::snprintf(out, 512, "%s../%s", GetApplicationDirectory(), rel); + return FileExists(out) ? out : nullptr; + }; + Shader bright_shader{}; + Shader blur_shader{}; + bool bloom_ok = false; + if (const char* p = shader_path_for("assets/shaders/bloom_bright.fs")) { + bright_shader = LoadShader(nullptr, p); + bloom_ok = bright_shader.id != 0; + } + if (const char* p = shader_path_for("assets/shaders/bloom_blur.fs")) { + blur_shader = LoadShader(nullptr, p); + bloom_ok = bloom_ok && blur_shader.id != 0; + } + const int loc_blur_dir = bloom_ok + ? GetShaderLocation(blur_shader, "uDirection") : -1; + const char* shader_path = FileExists("assets/shaders/post_fx.fs") ? "assets/shaders/post_fx.fs" : TextFormat("%s../assets/shaders/post_fx.fs", GetApplicationDirectory()); @@ -119,6 +148,8 @@ int main(int argc, char** argv) { const int loc_time = GetShaderLocation(post_shader, "uTime"); const int loc_corruption = GetShaderLocation(post_shader, "uCorruption"); const int loc_damage = GetShaderLocation(post_shader, "uDamage"); + const int loc_bloom = post_ok + ? GetShaderLocation(post_shader, "texture1") : -1; float accumulator = 0.0f; bool screenshot_taken = false; @@ -139,9 +170,52 @@ int main(int argc, char** argv) { ui::draw_all(game); EndTextureMode(); + if (post_ok && bloom_ok) { + const Rectangle full = { + 0.0f, 0.0f, static_cast(post_target.texture.width), + -static_cast(post_target.texture.height)}; + const Rectangle half_src = { + 0.0f, 0.0f, static_cast(bloom_w), + -static_cast(bloom_h)}; + const Rectangle half_dst = { + 0.0f, 0.0f, static_cast(bloom_w), + static_cast(bloom_h)}; + + BeginTextureMode(bloom_a); + BeginShaderMode(bright_shader); + DrawTexturePro(post_target.texture, full, half_dst, + Vector2{0.0f, 0.0f}, 0.0f, WHITE); + EndShaderMode(); + EndTextureMode(); + + const float dir_h[2] = {1.0f / bloom_w, 0.0f}; + const float dir_v[2] = {0.0f, 1.0f / bloom_h}; + BeginTextureMode(bloom_b); + BeginShaderMode(blur_shader); + SetShaderValue(blur_shader, loc_blur_dir, dir_h, + SHADER_UNIFORM_VEC2); + DrawTexturePro(bloom_a.texture, half_src, half_dst, + Vector2{0.0f, 0.0f}, 0.0f, WHITE); + EndShaderMode(); + EndTextureMode(); + + BeginTextureMode(bloom_a); + BeginShaderMode(blur_shader); + SetShaderValue(blur_shader, loc_blur_dir, dir_v, + SHADER_UNIFORM_VEC2); + DrawTexturePro(bloom_b.texture, half_src, half_dst, + Vector2{0.0f, 0.0f}, 0.0f, WHITE); + EndShaderMode(); + EndTextureMode(); + } + BeginDrawing(); if (post_ok) BeginShaderMode(post_shader); if (post_ok) { + if (bloom_ok && loc_bloom >= 0) { + SetShaderValueTexture(post_shader, loc_bloom, + bloom_a.texture); + } const float t = static_cast(GetTime()); const float corruption = game.corruption.value(); const float damage = presenter.damage_flash(); @@ -181,6 +255,12 @@ int main(int argc, char** argv) { presenter.shutdown(); if (post_ok) UnloadShader(post_shader); UnloadRenderTexture(post_target); + if (bloom_ok) { + UnloadShader(bright_shader); + UnloadShader(blur_shader); + } + UnloadRenderTexture(bloom_a); + UnloadRenderTexture(bloom_b); CloseWindow(); return 0; } diff --git a/src/render/aura.cpp b/src/render/aura.cpp index 439278c..7a0f999 100644 --- a/src/render/aura.cpp +++ b/src/render/aura.cpp @@ -1,7 +1,6 @@ #include "render/aura.hpp" #include "raymath.h" -#include "rlgl.h" #include #include @@ -20,12 +19,13 @@ const char* resolve(const char* rel) { void CorruptionAura::init() { const char* vs = resolve("assets/shaders/aura.vs"); const char* fs = resolve("assets/shaders/aura.fs"); - if (vs != nullptr && fs != nullptr) { - shader_ = LoadShader(vs, fs); - shader_ok_ = shader_.id != 0; + if (vs == nullptr || fs == nullptr) { + TraceLog(LOG_WARNING, "AURA: wave shader missing, ground waves disabled"); + return; } - if (!shader_ok_) { - TraceLog(LOG_WARNING, "AURA: shader missing/failed, wave disabled"); + shader_ = LoadShader(vs, fs); + if (shader_.id == 0) { + TraceLog(LOG_WARNING, "AURA: wave shader failed to compile"); return; } loc_time_ = GetShaderLocation(shader_, "uTime"); @@ -46,7 +46,6 @@ void CorruptionAura::init() { for (int i = 0; i < 8; ++i) quad_.texcoords[i] = uvs[i]; for (int i = 0; i < 6; ++i) quad_.indices[i] = indices[i]; UploadMesh(&quad_, false); - mesh_ok_ = true; material_ = LoadMaterialDefault(); material_.shader = shader_; @@ -55,30 +54,16 @@ void CorruptionAura::init() { } void CorruptionAura::shutdown() { - if (mesh_ok_) UnloadMesh(quad_); - if (shader_ok_) UnloadMaterial(material_); // also releases shader_ + if (ready_) { + UnloadMesh(quad_); + UnloadMaterial(material_); // also releases shader_ + } waves_.clear(); - mesh_ok_ = false; - shader_ok_ = false; ready_ = false; } -void CorruptionAura::begin_frame(const Camera3D& camera, float time, - float corruption) { +void CorruptionAura::begin_frame(float time, float corruption) { if (!ready_) return; - const Vector3 forward = Vector3Normalize( - Vector3Subtract(camera.target, camera.position)); - const Vector3 to_cam = Vector3Scale(forward, -1.0f); - const Vector3 right = Vector3Normalize(Vector3CrossProduct(camera.up, to_cam)); - const Vector3 up = Vector3CrossProduct(to_cam, right); - - // raylib stores matrices row-major, so basis vectors go in COLUMNS: - // col0 = right (m0,m4,m8), col1 = up (m1,m5,m9), col2 = toCam (m2,m6,m10). - basis_ = MatrixIdentity(); - basis_.m0 = right.x; basis_.m4 = right.y; basis_.m8 = right.z; - basis_.m1 = up.x; basis_.m5 = up.y; basis_.m9 = up.z; - basis_.m2 = to_cam.x; basis_.m6 = to_cam.y; basis_.m10 = to_cam.z; - SetShaderValue(shader_, loc_time_, &time, SHADER_UNIFORM_FLOAT); SetShaderValue(shader_, loc_corruption_, &corruption, SHADER_UNIFORM_FLOAT); } @@ -86,8 +71,8 @@ void CorruptionAura::begin_frame(const Camera3D& camera, float time, void CorruptionAura::update(float dt) { for (GroundWave& w : waves_) w.age += dt; waves_.erase(std::remove_if(waves_.begin(), waves_.end(), - [](const GroundWave& w) { return w.age >= w.life; }), - waves_.end()); + [](const GroundWave& w) { return w.age >= w.life; }), + waves_.end()); } void CorruptionAura::spawn_ground(Vector3 pos, float radius, float life, @@ -97,24 +82,6 @@ void CorruptionAura::spawn_ground(Vector3 pos, float radius, float life, waves_.push_back({pos, radius, 0.0f, life, phase}); } -void CorruptionAura::set_phase_and_intensity(float phase, float intensity) { - SetShaderValue(shader_, loc_phase_, &phase, SHADER_UNIFORM_FLOAT); - SetShaderValue(shader_, loc_intensity_, &intensity, SHADER_UNIFORM_FLOAT); -} - -void CorruptionAura::draw(Vector3 center, float radius, float phase) { - if (!ready_) return; - Matrix m = basis_; - const Vector3 to_cam{basis_.m2, basis_.m6, basis_.m10}; - m.m3 = center.x - to_cam.x * 0.35f; - m.m7 = center.y - to_cam.y * 0.35f; - m.m11 = center.z - to_cam.z * 0.35f; - m.m0 *= radius; m.m4 *= radius; m.m8 *= radius; - m.m1 *= radius; m.m5 *= radius; m.m9 *= radius; - set_phase_and_intensity(phase, 1.0f); - DrawMesh(quad_, material_, m); -} - Matrix CorruptionAura::ground_transform(const GroundWave& wave) const { // Flat XZ decal: local X -> world X, local Y -> world Z, normal -> +Y. Matrix m = MatrixIdentity(); @@ -133,7 +100,8 @@ void CorruptionAura::draw_ground_waves() { for (const GroundWave& w : waves_) { const float t = w.age / w.life; const float fade = (1.0f - t) * std::min(1.0f, t * 6.0f); - set_phase_and_intensity(w.phase, fade); + SetShaderValue(shader_, loc_phase_, &w.phase, SHADER_UNIFORM_FLOAT); + SetShaderValue(shader_, loc_intensity_, &fade, SHADER_UNIFORM_FLOAT); DrawMesh(quad_, material_, ground_transform(w)); } } diff --git a/src/render/aura.hpp b/src/render/aura.hpp index 4e25b6b..7df0ead 100644 --- a/src/render/aura.hpp +++ b/src/render/aura.hpp @@ -4,10 +4,8 @@ #include "raylib.h" -// Reusable SDF corruption wave. Two uses: -// - billboards attached to Hiss units (subtle dark-crimson aura) -// - flat ground emitters for events / boss entrances (spawn_ground) -// Both share one quad mesh, one shader and no textures. +// Flat ground emitters for tier-ups / boss entrances. Hiss corruption on units +// is part of the actor models themselves (tools/blender/build_enemies.py). struct GroundWave { Vector3 pos{}; float radius = 1.0f; @@ -22,32 +20,24 @@ public: void shutdown(); bool ready() const { return ready_; } - void begin_frame(const Camera3D& camera, float time, float corruption); + void begin_frame(float time, float corruption); void update(float dt); - // Spawns a flat, fading wave on the floor. `pos.y` should be ~0.08. + // `pos.y` should be ~0.08. void spawn_ground(Vector3 pos, float radius, float life, float phase); - - // `phase` decorrelates waves between units (the sim's bob_phase works). - void draw(Vector3 center, float radius, float phase); - void draw_ground_waves(); int active_waves() const { return static_cast(waves_.size()); } private: Matrix ground_transform(const GroundWave& wave) const; - void set_phase_and_intensity(float phase, float intensity); std::vector waves_; Shader shader_{}; Material material_{}; Mesh quad_{}; - Matrix basis_{}; int loc_time_ = -1; int loc_phase_ = -1; int loc_corruption_ = -1; int loc_intensity_ = -1; - bool shader_ok_ = false; - bool mesh_ok_ = false; bool ready_ = false; }; diff --git a/src/render/concrete.cpp b/src/render/concrete.cpp index 293ceb2..3523213 100644 --- a/src/render/concrete.cpp +++ b/src/render/concrete.cpp @@ -91,6 +91,7 @@ void ConcreteMaterial::init(float arena) { } shader_ok_ = true; loc_corruption_ = GetShaderLocation(shader_, "uCorruption"); + loc_camera_ = GetShaderLocation(shader_, "uCameraPos"); // The floor is sealed and glossier than the raw walls/pillars; vertex alpha // carries that difference so everything still shares one material + mesh. @@ -154,8 +155,12 @@ void ConcreteMaterial::shutdown() { ready_ = false; } -void ConcreteMaterial::draw(float corruption) { +void ConcreteMaterial::draw(float corruption, Vector3 camera_pos) { if (!ready_) return; SetShaderValue(shader_, loc_corruption_, &corruption, SHADER_UNIFORM_FLOAT); + if (loc_camera_ >= 0) { + const float cam[3] = {camera_pos.x, camera_pos.y, camera_pos.z}; + SetShaderValue(shader_, loc_camera_, cam, SHADER_UNIFORM_VEC3); + } DrawMesh(mesh_, material_, MatrixIdentity()); } diff --git a/src/render/concrete.hpp b/src/render/concrete.hpp index d2df748..62e6607 100644 --- a/src/render/concrete.hpp +++ b/src/render/concrete.hpp @@ -12,7 +12,7 @@ public: void shutdown(); bool ready() const { return ready_; } - void draw(float corruption); + void draw(float corruption, Vector3 camera_pos); private: void add_box(Vector3 center, Vector3 size, float rough_mult); @@ -29,6 +29,7 @@ private: Texture2D roughness_{}; Mesh mesh_{}; int loc_corruption_ = -1; + int loc_camera_ = -1; bool shader_ok_ = false; bool mesh_ok_ = false; bool ready_ = false; diff --git a/src/render/models.cpp b/src/render/models.cpp index 18973d9..7d84da0 100644 --- a/src/render/models.cpp +++ b/src/render/models.cpp @@ -1,5 +1,7 @@ #include "render/models.hpp" +#include "rlgl.h" + #include #include @@ -14,6 +16,27 @@ const char* resolve(const char* rel) { return FileExists(path) ? path : nullptr; } +// hipY, shoulderY, legX, armX — rough rig pivots per actor (model-local metres). +struct Rig { + float hip_y = 0.0f; + float shoulder_y = 0.0f; + float leg_x = 0.0f; + float arm_x = 0.0f; + float scale = 0.0f; + float mode = 0.0f; +}; + +Rig rig_for(ActorModel id) { + switch (id) { + case ActorModel::Guard: return {0.90f, 1.45f, 0.18f, 0.43f, 1.0f, 1.0f}; + case ActorModel::HissStaff: return {0.60f, 1.40f, 0.20f, 0.38f, 0.85f, 1.0f}; + case ActorModel::HissBrute: return {1.05f, 2.10f, 0.40f, 0.95f, 1.0f, 1.0f}; + case ActorModel::MoldSpore: return {0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 2.0f}; + case ActorModel::Shard: return {0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 3.0f}; + default: return {}; + } +} + } // namespace void ModelBank::init() { @@ -26,6 +49,28 @@ void ModelBank::init() { loc_time_ = GetShaderLocation(shader_, "uTime"); loc_flash_ = GetShaderLocation(shader_, "uFlash"); loc_corruption_ = GetShaderLocation(shader_, "uCorruption"); + loc_camera_ = GetShaderLocation(shader_, "uCameraPos"); + loc_outline_ = GetShaderLocation(shader_, "uOutline"); + loc_ramp_ = GetShaderLocation(shader_, "actorRamp"); + loc_walk_ = GetShaderLocation(shader_, "uWalk"); + loc_stagger_ = GetShaderLocation(shader_, "uStagger"); + loc_phase_ = GetShaderLocation(shader_, "uPhase"); + loc_rig_ = GetShaderLocation(shader_, "uRig"); + loc_rig_scale_ = GetShaderLocation(shader_, "uRigScale"); + loc_rig_mode_ = GetShaderLocation(shader_, "uRigMode"); + const char* ramp = resolve("assets/textures/actor/actor_ramp.png"); + if (ramp != nullptr && loc_ramp_ >= 0) { + ramp_ = LoadTexture(ramp); + SetTextureWrap(ramp_, TEXTURE_WRAP_CLAMP); + SetTextureFilter(ramp_, TEXTURE_FILTER_BILINEAR); + // raylib binds material maps to texture units on every model + // draw, but ad-hoc SetShaderValueTexture samplers are only + // bound for 2D batches. Ride the emissive map slot (unit 3). + const int unit = MATERIAL_MAP_EMISSION; + SetShaderValue(shader_, loc_ramp_, &unit, SHADER_UNIFORM_INT); + } else { + TraceLog(LOG_WARNING, "ACTOR: ramp LUT missing, using flat diffuse"); + } } else { TraceLog(LOG_WARNING, "ACTOR: shader failed to compile, using flat shading"); } @@ -64,25 +109,64 @@ void ModelBank::shutdown() { if (e.loaded) UnloadModel(e.model); e.loaded = false; } + if (ramp_.id != 0) UnloadTexture(ramp_); + ramp_.id = 0; if (shader_ok_) UnloadShader(shader_); shader_ok_ = false; ready_ = false; } -void ModelBank::begin_frame(float time, float corruption) { +void ModelBank::begin_frame(float time, float corruption, Vector3 camera_pos) { if (!shader_ok_) return; + if (ramp_.id != 0) { + rlActiveTextureSlot(MATERIAL_MAP_EMISSION); + rlEnableTexture(ramp_.id); + } SetShaderValue(shader_, loc_time_, &time, SHADER_UNIFORM_FLOAT); SetShaderValue(shader_, loc_corruption_, &corruption, SHADER_UNIFORM_FLOAT); + if (loc_camera_ >= 0) { + const float cam[3] = {camera_pos.x, camera_pos.y, camera_pos.z}; + SetShaderValue(shader_, loc_camera_, cam, SHADER_UNIFORM_VEC3); + } } void ModelBank::draw(ActorModel id, Vector3 pos, float yaw, float scale, - Color tint, float flash) { + Color tint, float flash, bool outline, float walk, + float stagger, float phase) { const int index = static_cast(id); if (index < 0 || index >= static_cast(ActorModel::Count)) return; if (!entries_[index].loaded) { draw_fallback(id, pos, yaw, scale, tint); return; } + if (shader_ok_) { + const Rig rig = rig_for(id); + const float r[4] = {rig.hip_y, rig.shoulder_y, rig.leg_x, rig.arm_x}; + if (loc_rig_ >= 0) SetShaderValue(shader_, loc_rig_, r, SHADER_UNIFORM_VEC4); + if (loc_rig_scale_ >= 0) + SetShaderValue(shader_, loc_rig_scale_, &rig.scale, SHADER_UNIFORM_FLOAT); + if (loc_rig_mode_ >= 0) + SetShaderValue(shader_, loc_rig_mode_, &rig.mode, SHADER_UNIFORM_FLOAT); + if (loc_walk_ >= 0) SetShaderValue(shader_, loc_walk_, &walk, SHADER_UNIFORM_FLOAT); + if (loc_stagger_ >= 0) + SetShaderValue(shader_, loc_stagger_, &stagger, SHADER_UNIFORM_FLOAT); + if (loc_phase_ >= 0) + SetShaderValue(shader_, loc_phase_, &phase, SHADER_UNIFORM_FLOAT); + } + + // Ink silhouette: expanded back faces first, then the lit model over them. + // One extra draw call only for the guard / future bosses — never the horde. + if (outline && shader_ok_ && loc_outline_ >= 0) { + const float on = 1.0f; + const float off = 0.0f; + SetShaderValue(shader_, loc_outline_, &on, SHADER_UNIFORM_FLOAT); + rlSetCullFace(RL_CULL_FACE_FRONT); + DrawModelEx(entries_[index].model, pos, Vector3{0.0f, 1.0f, 0.0f}, yaw, + Vector3{scale, scale, scale}, tint); + rlSetCullFace(RL_CULL_FACE_BACK); + SetShaderValue(shader_, loc_outline_, &off, SHADER_UNIFORM_FLOAT); + } + if (shader_ok_ && loc_flash_ >= 0) { const float f = flash > 0.0f ? 1.0f : 0.0f; SetShaderValue(shader_, loc_flash_, &f, SHADER_UNIFORM_FLOAT); @@ -98,6 +182,13 @@ float ModelBank::height(ActorModel id) { case ActorModel::MoldSpore: return 1.3f; case ActorModel::HissBrute: return 2.9f; case ActorModel::Shard: return 0.8f; + case ActorModel::Hotline: return 1.3f; + case ActorModel::TV: return 2.3f; + case ActorModel::Pedestal: return 1.5f; + case ActorModel::Duck: return 1.5f; + case ActorModel::Cabinet: return 1.8f; + case ActorModel::Crate: return 0.9f; + case ActorModel::Debris: return 1.0f; default: return 1.0f; } } @@ -109,6 +200,13 @@ const char* ModelBank::file_name(ActorModel id) { case ActorModel::MoldSpore: return "assets/models/mold_spore.glb"; case ActorModel::HissBrute: return "assets/models/hiss_brute.glb"; case ActorModel::Shard: return "assets/models/shard.glb"; + case ActorModel::Hotline: return "assets/models/props/hotline.glb"; + case ActorModel::TV: return "assets/models/props/tv.glb"; + case ActorModel::Pedestal: return "assets/models/props/pedestal.glb"; + case ActorModel::Duck: return "assets/models/props/duck.glb"; + case ActorModel::Cabinet: return "assets/models/props/cabinet.glb"; + case ActorModel::Crate: return "assets/models/props/crate.glb"; + case ActorModel::Debris: return "assets/models/props/debris.glb"; default: return ""; } } diff --git a/src/render/models.hpp b/src/render/models.hpp index ff39906..07d7a5a 100644 --- a/src/render/models.hpp +++ b/src/render/models.hpp @@ -4,7 +4,12 @@ // Low-poly GLB actors authored in Blender (tools/blender/build_enemies.py). // All models are metres, origin at the feet, facing +Z (the game camera). -enum class ActorModel { Guard, HissStaff, MoldSpore, HissBrute, Shard, Count }; +// The set-dressing models share the same one-mesh / painted-vertex pipeline. +enum class ActorModel { + Guard, HissStaff, MoldSpore, HissBrute, Shard, + Hotline, TV, Pedestal, Duck, Cabinet, Crate, Debris, + Count +}; class ModelBank { public: @@ -13,12 +18,14 @@ public: bool ready() const { return ready_; } - // Frame-wide shader uniforms (time / corruption). - void begin_frame(float time, float corruption); + // Frame-wide shader uniforms (time / corruption / camera). + void begin_frame(float time, float corruption, Vector3 camera_pos); // Draws one actor. `flash` is a 0..1 hit flash; `yaw` rotates around Y. + // `outline` adds a back-face ink silhouette (guard / bosses, not the horde). void draw(ActorModel id, Vector3 pos, float yaw, float scale, Color tint, - float flash = 0.0f); + float flash = 0.0f, bool outline = false, float walk = 0.0f, + float stagger = 0.0f, float phase = 0.0f); // Per-model visual height, used for health bars / floating labels. static float height(ActorModel id); @@ -34,9 +41,19 @@ private: Entry entries_[static_cast(ActorModel::Count)]; Shader shader_{}; + Texture2D ramp_{}; int loc_time_ = -1; int loc_flash_ = -1; int loc_corruption_ = -1; + int loc_camera_ = -1; + int loc_outline_ = -1; + int loc_ramp_ = -1; + int loc_walk_ = -1; + int loc_stagger_ = -1; + int loc_phase_ = -1; + int loc_rig_ = -1; + int loc_rig_scale_ = -1; + int loc_rig_mode_ = -1; bool shader_ok_ = false; bool ready_ = false; }; diff --git a/src/render/presenter.cpp b/src/render/presenter.cpp index 73d1ae8..836cbad 100644 --- a/src/render/presenter.cpp +++ b/src/render/presenter.cpp @@ -5,6 +5,7 @@ #include #include #include +#include namespace { @@ -40,13 +41,43 @@ float actor_flash(float timer, float scale) { return timer <= 0.0f ? 0.0f : std::min(1.0f, timer * scale); } +// Glow colors per world-object kind (§4.6): the scene carries a faint +// readable signal so the player can see what they're about to catch. +Color world_object_color(const WorldObject& obj) { + const char* name = obj.name; + if (std::strcmp(name, "SLOW") == 0) return Color{70, 130, 190, 200}; + if (std::strcmp(name, "VULNERABLE") == 0) return Color{200, 40, 40, 200}; + if (std::strcmp(name, "DOT") == 0) return Color{200, 30, 30, 200}; + if (std::strcmp(name, "TAKEN") == 0) return Color{255, 150, 40, 200}; + if (std::strcmp(name, "CONFUSE") == 0) return Color{245, 197, 24, 200}; + return Color{200, 200, 205, 200}; +} + } // namespace +void Presenter::spawn_sparks(Vec2 pos, float height, Color color, int count, + float speed) { + for (int i = 0; i < count && sparks_.size() < 160; ++i) { + const float angle = static_cast(GetRandomValue(0, 360)) * DEG2RAD; + const float jitter = static_cast(GetRandomValue(40, 120)) / 100.0f; + const float lift = static_cast(GetRandomValue(120, 320)) / 100.0f; + sparks_.push_back(Spark{ + {pos.x + static_cast(GetRandomValue(-10, 10)) / 40.0f, height, + pos.y + static_cast(GetRandomValue(-10, 10)) / 40.0f}, + {std::cos(angle) * speed * jitter, lift, + std::sin(angle) * speed * jitter}, + color, + 0.0f, + static_cast(GetRandomValue(50, 90)) / 100.0f, + static_cast(GetRandomValue(14, 26)) / 100.0f}); + } +} + void Presenter::init(float arena_half) { - camera_.position = {0.0f, 17.0f, 13.0f}; + camera_.position = {0.0f, 18.0f, 14.0f}; camera_.target = {0.0f, 0.0f, 0.0f}; camera_.up = {0.0f, 1.0f, 0.0f}; - camera_.fovy = 45.0f; // tactical lens; lower height keeps actors readable + camera_.fovy = 48.0f; // wide tactical view: horde awareness over detail camera_.projection = CAMERA_PERSPECTIVE; Image img = GenImageGradientRadial(64, 64, 0.0f, WHITE, Color{255, 255, 255, 0}); @@ -57,6 +88,7 @@ void Presenter::init(float arena_half) { concrete_.init(arena_half); aura_.init(); damage_numbers_.reserve(64); + sparks_.reserve(160); } void Presenter::shutdown() { @@ -73,7 +105,7 @@ void Presenter::draw_environment(const Game& game) { // All concrete (floor, curbs, pillars, door frame) is one merged, triplanar // mesh using the same 2K PBR maps as the Blender diorama. - concrete_.draw(corruption); + concrete_.draw(corruption, camera_.position); const bool concrete_fallback = !concrete_.ready(); if (concrete_fallback) { DrawCube({0.0f, -0.5f, 0.0f}, arena * 2.0f + 40.0f, 1.0f, @@ -96,6 +128,41 @@ void Presenter::draw_environment(const Game& game) { DrawCube({2.82f, 0.033f, 5.0f}, 0.34f, 0.066f, 26.0f, carpet_edge); DrawCube({0.0f, 0.036f, 8.4f}, 26.0f, 0.072f, 0.34f, carpet_edge); DrawCube({0.0f, 0.036f, 13.6f}, 26.0f, 0.072f, 0.34f, carpet_edge); + for (float z = -6.0f; z <= 16.0f; z += 4.0f) { + DrawCube({0.0f, 0.061f, z}, 5.7f, 0.004f, 0.05f, + Color{96, 10, 18, 255}); + } + for (float x = -11.0f; x <= 11.0f; x += 4.0f) { + DrawCube({x, 0.07f, 11.0f}, 0.06f, 0.004f, 4.6f, + Color{96, 10, 18, 255}); + } + + // Spilled toner / scorched stains and redacted paper scraps break up the + // otherwise uniform concrete without touching the tactical lanes. + const float stains[][4] = { + {-9.0f, -14.0f, 1.8f, 0.7f}, {8.0f, -11.0f, 1.2f, 0.5f}, + {-16.0f, 4.0f, 2.2f, 0.6f}, {12.5f, 12.0f, 1.6f, 0.8f}, + {-5.0f, 18.0f, 1.4f, 0.5f}, {17.0f, -3.0f, 1.9f, 0.7f}, + {-19.0f, -8.0f, 1.5f, 0.6f}, {3.0f, -20.0f, 2.1f, 0.7f}, + }; + for (const auto& s : stains) { + DrawCylinder({s[0], 0.016f, s[1]}, s[2], s[2], 0.012f, 10, + Color{28, 12, 14, static_cast(55 * s[3])}); + } + const float scraps[][2] = { + {-7.5f, -9.0f}, {-6.8f, -9.6f}, {5.5f, -15.0f}, {9.5f, 6.5f}, + {10.2f, 7.1f}, {-14.0f, 11.5f}, {15.5f, -9.0f}, {-17.0f, -13.0f}, + {2.0f, 20.0f}, {-3.0f, -17.0f}, {12.0f, 19.0f}, {-11.0f, 1.5f}, + }; + for (int i = 0; i < 12; ++i) { + const float x = scraps[i][0], z = scraps[i][1]; + DrawCube({x, 0.022f, z}, 0.28f, 0.012f, 0.38f, + (i % 3 == 0) ? Color{90, 20, 26, 255} : Color{198, 192, 176, 255}); + } + for (const float x : {-8.6f, 8.6f}) { + DrawCube({x, 0.03f, 0.0f}, 0.09f, 0.03f, 34.0f, + Color{20, 20, 24, 255}); + } // Perimeter curbs (the textured versions live in ConcreteMaterial). if (concrete_fallback) { @@ -106,6 +173,28 @@ void Presenter::draw_environment(const Game& game) { DrawCube({arena + 1.0f, 0.6f, 0.0f}, 1.0f, 1.2f, arena * 2.0f + 4.0f, wall); } + // Outer service band: the textured floor continues past the play curb, so + // dress it with dark plant blocks and dim spill. A player hugging a wall + // then sees more facility instead of an empty unlit void. + for (int side = -1; side <= 1; side += 2) { + const float x = side * (arena + 6.0f); + for (float z = -arena; z <= arena + 12.0f; z += 9.0f) { + DrawCube({x, 0.85f, z}, 1.6f, 1.7f, 1.6f, Color{34, 34, 38, 255}); + DrawCube({x, 1.75f, z}, 1.8f, 0.12f, 1.8f, Color{56, 56, 61, 255}); + } + const float z = side * (arena + 7.0f); + for (float x2 = -arena; x2 <= arena + 10.0f; x2 += 9.0f) { + DrawCube({x2, 0.75f, z}, 1.5f, 1.5f, 1.5f, Color{34, 34, 38, 255}); + DrawCube({x2, 1.56f, z}, 1.7f, 0.12f, 1.7f, Color{56, 56, 61, 255}); + } + for (float z2 = -arena; z2 <= arena; z2 += 12.0f) { + DrawCylinder({side * (arena + 8.0f), 0.05f, z2}, 3.2f, 3.2f, 0.02f, + 12, Color{190, 186, 164, 12}); + DrawCylinder({z2, 0.05f, side * (arena + 8.0f)}, 3.2f, 3.2f, 0.02f, + 12, Color{190, 186, 164, 12}); + } + } + // Fluorescent strips live at curb height — the tactical camera sits above // the room, so a real ceiling would only occlude the play field. One strip // is dead: the sector is failing as containment decays. @@ -115,7 +204,7 @@ void Presenter::draw_environment(const Game& game) { const float inward = x > 0.0f ? -1.0f : 1.0f; DrawCube({x, 1.22f, z}, 0.7f, 0.16f, 6.0f, Color{22, 22, 25, 255}); DrawCube({x + inward * 0.36f, 1.22f, z}, 0.06f, 0.07f, 5.6f, - dead ? Color{90, 26, 28, 255} : Color{238, 236, 214, 255}); + dead ? Color{90, 26, 28, 255} : Color{205, 202, 186, 255}); if (!dead) { DrawCylinder({x + inward * 2.2f, 0.05f, z}, 2.6f, 2.6f, 0.02f, 12, Color{220, 214, 190, 10}); @@ -139,8 +228,8 @@ void Presenter::draw_environment(const Game& game) { Color{46, 170, 76, 255}); DrawCube({10.0f, 2.4f, door_z - 0.2f}, 1.7f, 0.52f, 0.12f, Color{46, 170, 76, 255}); - DrawCube({0.0f, 1.45f, arena + 0.5f}, 38.0f, 0.18f, 0.3f, - Color{255, 232, 180, 255}); + DrawCube({0.0f, 1.45f, arena + 0.5f}, 38.0f, 0.12f, 0.3f, + Color{120, 42, 44, 255}); // Hiss light spill pools widen as the House decays. const unsigned char hiss_alpha = @@ -173,6 +262,64 @@ void Presenter::draw_environment(const Game& game) { } } + // S11: Objects of Power + set dressing. Sculpted GLBs share the actor + // shader; fixed placements keep the tactical lanes clear. + const float t = anim_time_; + // Objects of Power get a restrained idle so they feel alive without + // pulling focus from combat. Furniture (cabinets/crates) stays planted. + models_.draw(ActorModel::Hotline, + {-15.0f, std::sin(t * 2.3f) * 0.012f, 16.0f}, + std::atan2(15.0f, -16.0f) + std::sin(t * 1.1f) * 0.05f, + 1.0f, WHITE); + const float flick = static_cast( + 235.0f + 20.0f * (0.5f + 0.5f * std::sin(t * 13.0f) * std::sin(t * 5.0f))); + models_.draw(ActorModel::TV, {13.0f, 0.0f, 17.0f}, + std::atan2(-13.0f, -17.0f) + std::sin(t * 0.8f) * 0.025f, + 1.0f, + game.ritual_system.complete() ? Color{255, 250, 220, 255} + : Color{flick, flick, flick, 255}); + models_.draw(ActorModel::Pedestal, {-7.0f, 0.0f, 10.5f}, 0.0f, + 1.0f + std::sin(t * 1.6f) * 0.012f, WHITE); + models_.draw(ActorModel::Duck, + {7.0f, std::sin(t * 2.0f) * 0.025f, 10.5f}, + std::sin(t * 1.4f) * 0.09f, 1.0f, WHITE); + for (const float z : {-6.0f, -4.4f, -2.8f}) { + models_.draw(ActorModel::Cabinet, {21.5f, 0.0f, z}, -1.5708f, + 1.0f, WHITE); + } + models_.draw(ActorModel::Crate, {18.0f, 0.0f, 6.0f}, 0.4f, 1.0f, WHITE); + models_.draw(ActorModel::Crate, {-17.5f, 0.0f, 3.0f}, -0.7f, 1.0f, WHITE); + models_.draw(ActorModel::Crate, {16.0f, 0.0f, -12.0f}, 1.1f, 1.0f, WHITE); + // Denser centre-adjacent dressing; the carpet cross and combat lanes stay + // clear, but the arena no longer reads as an empty floor. + models_.draw(ActorModel::Crate, {-11.0f, 0.0f, 8.0f}, 0.25f, 0.85f, WHITE); + models_.draw(ActorModel::Crate, {11.5f, 0.0f, 4.0f}, -0.5f, 0.9f, WHITE); + models_.draw(ActorModel::Cabinet, {-21.6f, 0.0f, -4.0f}, 1.5708f, + 1.0f, WHITE); + models_.draw(ActorModel::Cabinet, {-21.6f, 0.0f, -2.6f}, 1.5708f, + 1.0f, WHITE); + const float debris_specs[][4] = { + {-14.0f, 0.35f, 9.0f, 1.2f}, {15.0f, 0.35f, -7.0f, 0.3f}, + {-12.0f, 0.35f, -12.0f, 2.1f}, + }; + const float debris_scales[] = {0.6f, 0.65f, 0.55f}; + for (int i = 0; i < 3; ++i) { + const auto& d = debris_specs[i]; + models_.draw(ActorModel::Debris, + {d[0], d[1] + std::sin(t * 0.9f + i * 2.1f) * 0.035f, d[2]}, + d[3] + t * 0.12f, debris_scales[i], WHITE); + } + // Hiss-corrupted slabs drift slowly above the playfield (reference art). + const float slabs[][4] = { + {14.0f, 4.6f, 12.0f, 0.0f}, {-13.0f, 5.2f, 7.0f, 1.7f}, + {9.0f, 3.8f, -13.0f, 0.6f}, {-9.0f, 4.2f, -10.0f, 2.3f}, + }; + for (const auto& s : slabs) { + const float bob = std::sin(anim_time_ * 0.7f + s[3]) * 0.18f; + models_.draw(ActorModel::Debris, {s[0], s[1] + bob, s[2]}, + anim_time_ * 0.08f + s[3], 1.0f, WHITE); + } + // Scattered grime patches break up the slab's flat colour. const Vector3 grime[] = {{-9.0f, 0.0f, -7.0f}, {8.0f, 0.0f, -14.0f}, {-16.0f, 0.0f, 9.0f}, {14.0f, 0.0f, 4.0f}}; @@ -187,16 +334,22 @@ void Presenter::draw_scene(Game& game) { if (e.type == EventType::PlayerDamaged) { shake_ = std::max(shake_, 0.45f); damage_flash_ = 1.0f; + spawn_sparks(e.pos, 1.0f, Color{255, 80, 70, 255}, 6, 3.0f); } else if (e.type == EventType::EnemyKilled) { shake_ = std::max(shake_, 0.10f); + spawn_sparks(e.pos, 0.9f, Color{255, 60, 50, 255}, 8, 3.4f); } else if (e.type == EventType::TierUp) { shake_ = std::max(shake_, 0.60f); tier_wave_pending_ = true; - } else if (e.type == EventType::EnemyHit && damage_numbers_.size() < 48) { - damage_numbers_.push_back( - {e.pos + Vec2{static_cast(GetRandomValue(-8, 8)) / 20.0f, - static_cast(GetRandomValue(-8, 8)) / 20.0f}, - e.magnitude, 0.0f}); + spawn_sparks(game.player.pos, 0.8f, Color{255, 210, 90, 255}, 12, 4.0f); + } else if (e.type == EventType::EnemyHit) { + if (damage_numbers_.size() < 48) { + damage_numbers_.push_back( + {e.pos + Vec2{static_cast(GetRandomValue(-8, 8)) / 20.0f, + static_cast(GetRandomValue(-8, 8)) / 20.0f}, + e.magnitude, 0.0f}); + } + spawn_sparks(e.pos, 1.1f, Color{255, 240, 200, 255}, 3, 2.4f); } } shake_ = std::max(0.0f, shake_ - 0.06f); @@ -209,20 +362,42 @@ void Presenter::draw_scene(Game& game) { std::remove_if(damage_numbers_.begin(), damage_numbers_.end(), [](const DamageNumber& n) { return n.age > 0.8f; }), damage_numbers_.end()); + for (Spark& s : sparks_) { + s.age += frame_dt; + s.pos.x += s.vel.x * frame_dt; + s.pos.y += s.vel.y * frame_dt; + s.pos.z += s.vel.z * frame_dt; + s.vel.y -= 9.0f * frame_dt; + s.vel.x *= 0.96f; + s.vel.z *= 0.96f; + if (s.pos.y < 0.08f) { + s.pos.y = 0.08f; + s.vel.y *= -0.3f; + } + } + sparks_.erase(std::remove_if(sparks_.begin(), sparks_.end(), + [](const Spark& s) { return s.age > s.life; }), + sparks_.end()); const float sx = static_cast(GetRandomValue(-100, 100)) / 100.0f * shake_; const float sy = static_cast(GetRandomValue(-100, 100)) / 100.0f * shake_; const Vec2 p = game.player.pos; - camera_.position = {p.x + sx * 0.6f, 14.0f + sy * 0.4f, p.y + 10.5f}; - camera_.target = {p.x + sx * 0.3f, 0.0f, p.y}; + // Keep the arena rim out of frame when the player hugs a wall — showing + // the unlit floor beyond the curb breaks the contained-facility illusion. + const float margin = 5.0f; + const float bound = game.config.arena_half - margin; + const float cx = std::clamp(p.x, -bound, bound); + const float cz = std::clamp(p.y, -bound, bound); + camera_.position = {cx + sx * 0.6f, 18.0f + sy * 0.4f, cz + 14.0f}; + camera_.target = {cx + sx * 0.3f, 0.0f, cz}; if (tier_wave_pending_) { // Reusable scene wave: also callable for boss entrances / events. aura_.spawn_ground({p.x, 0.09f, p.y}, 11.0f, 2.6f, anim_time_); tier_wave_pending_ = false; } - models_.begin_frame(anim_time_, game.corruption.value()); - aura_.begin_frame(camera_, anim_time_, game.corruption.value()); + models_.begin_frame(anim_time_, game.corruption.value(), camera_.position); + aura_.begin_frame(anim_time_, game.corruption.value()); BeginMode3D(camera_); @@ -234,16 +409,11 @@ void Presenter::draw_scene(Game& game) { draw_blob_shadow(e.pos, e.radius * 0.85f); } - // Corruption waves: one SDF quad behind each Hiss unit. Depth writes - // are off so overlapping auras blend instead of clipping each other. + // Hiss corruption is now baked into the human Resonant models + // (build_enemies.py) and animated by the actor shader — no detached + // aura blob. Only event ground waves remain here. rlDisableDepthMask(); aura_.draw_ground_waves(); - for (const Enemy& e : game.enemy_system.enemies) { - if (e.type == EnemyType::MoldSpore) continue; - const bool brute = e.type == EnemyType::HissBrute; - aura_.draw({e.pos.x, brute ? 1.4f : 0.95f, e.pos.y}, - e.radius * (brute ? 1.95f : 2.45f), e.bob_phase); - } rlEnableDepthMask(); // Player: derive facing from motion (presentation-only, no sim change). @@ -251,8 +421,11 @@ void Presenter::draw_scene(Game& game) { if (length_sq(moved) > 1e-5f) player_yaw_ = std::atan2(moved.x, moved.y); last_player_pos_ = p; const float guard_bob = std::sin(anim_time_ * 6.0f) * 0.02f; + const float player_walk = std::min(1.0f, length(moved) * 14.0f); + const float player_flash = actor_flash(game.player.hit_flash, 4.0f); models_.draw(ActorModel::Guard, {p.x, guard_bob, p.y}, player_yaw_, 1.0f, - WHITE, actor_flash(game.player.hit_flash, 4.0f)); + WHITE, player_flash, true, player_walk, player_flash, + anim_time_); // Enemies face the player; Hiss units add a nervous jitter. for (const Enemy& e : game.enemy_system.enemies) { @@ -264,8 +437,10 @@ void Presenter::draw_scene(Game& game) { const ActorModel model = mold ? ActorModel::MoldSpore : (e.type == EnemyType::HissBrute ? ActorModel::HissBrute : ActorModel::HissStaff); + const float flash = actor_flash(e.hit_flash, 6.0f); + const float walk = std::min(1.0f, e.speed / 4.5f); models_.draw(model, {e.pos.x, bob, e.pos.y}, yaw, 1.0f, WHITE, - actor_flash(e.hit_flash, 6.0f)); + flash, !mold, walk, flash, e.bob_phase); } // Resonance shards: slowly spinning 3D crystals. @@ -273,7 +448,19 @@ void Presenter::draw_scene(Game& game) { const float spin = anim_time_ * 2.2f + s.pos.x * 0.7f; const float bob = std::sin(spin * 1.3f) * 0.07f; models_.draw(ActorModel::Shard, {s.pos.x, 0.55f + bob, s.pos.y}, spin, - 0.8f, WHITE); + 0.8f, WHITE, 0.0f, false, 0.0f, 0.0f, + anim_time_ + s.pos.x * 0.7f); + } + + // World objects of power: small camera-facing glows (§4.6). + const Texture2D object_glow = spr_glow_.id != 0 ? spr_glow_ : soft_disc_; + for (int i = 0; i < game.buff_system.world_object_count(); ++i) { + const WorldObject& obj = game.buff_system.world_object(i); + const Color c = world_object_color(obj); + DrawBillboardRec(camera_, object_glow, + Rectangle{0.0f, 0.0f, static_cast(object_glow.width), + static_cast(object_glow.height)}, + {obj.pos.x, 0.75f, obj.pos.y}, Vector2{0.45f, 0.45f}, c); } // Projectile glow remains camera-facing — it is an FX, not a card. @@ -287,8 +474,28 @@ void Presenter::draw_scene(Game& game) { projectile_color(pr.source)); } + // Light particles from hits, kills and tier-ups — camera-facing glows. + for (const Spark& s : sparks_) { + const float fade = 1.0f - s.age / s.life; + Color tint = s.color; + tint.a = static_cast(255.0f * fade * fade); + DrawBillboardRec(camera_, glow, + Rectangle{0.0f, 0.0f, static_cast(glow.width), + static_cast(glow.height)}, + s.pos, Vector2{s.size, s.size}, tint); + } + EndMode3D(); + // World-object flavor names hover near each glow. + for (int i = 0; i < game.buff_system.world_object_count(); ++i) { + const WorldObject& obj = game.buff_system.world_object(i); + if (obj.name[0] == '\0') continue; + const Vector2 screen = GetWorldToScreen({obj.pos.x, 0.75f, obj.pos.y}, camera_); + DrawText(obj.name, static_cast(screen.x) - MeasureText(obj.name, 12) / 2, + static_cast(screen.y) - 14, 12, Color{255, 255, 255, 200}); + } + // World-anchored health bars for damaged enemies. for (const Enemy& e : game.enemy_system.enemies) { if (e.hp >= e.max_hp) continue; diff --git a/src/render/presenter.hpp b/src/render/presenter.hpp index 18bdbc8..2fcbd29 100644 --- a/src/render/presenter.hpp +++ b/src/render/presenter.hpp @@ -19,6 +19,15 @@ struct DamageNumber { float age = 0.0f; }; +struct Spark { + Vector3 pos{}; + Vector3 vel{}; + Color color{}; + float age = 0.0f; + float life = 0.5f; + float size = 0.12f; +}; + class Presenter { public: void init(float arena_half); @@ -32,6 +41,7 @@ public: private: void draw_environment(const Game& game); + void spawn_sparks(Vec2 pos, float height, Color color, int count, float speed); Camera3D camera_{}; Texture2D soft_disc_{}; // projectile glow fallback @@ -46,4 +56,5 @@ private: bool tier_wave_pending_ = false; Vec2 last_player_pos_{}; std::vector damage_numbers_; + std::vector sparks_; }; diff --git a/src/render/ui.cpp b/src/render/ui.cpp index 9556fb0..7f79a52 100644 --- a/src/render/ui.cpp +++ b/src/render/ui.cpp @@ -49,6 +49,19 @@ void draw_hud(const Game& game) { std::snprintf(misc, sizeof(misc), "KILLS %d CLEARANCE LV %d", game.kills, game.level); DrawText(misc, 20, 52, 18, Color{200, 198, 192, 235}); + // Ritual in progress — mini-game indicator (the player understands the + // ritual starts when it appears). MVP: the TV ritual. + if (game.ritual_system.active()) { + char rit[160]; + std::snprintf(rit, sizeof(rit), "RITUAL IN PROGRESS — The TV must flash (%.0f s)", + std::max(0.0f, game.ritual_system.remaining())); + DrawText(rit, 20, 70.0f, 16, Color{245, 197, 24, 255}); + } + if (game.ritual_system.complete()) { + DrawText("RITUAL COMPLETE — The TV is live", 20, 70.0f, 16, + Color{245, 197, 24, 255}); + } + // Owned OoP loadout (left column). float oy = 84.0f; DrawText("OoP LOADOUT", 20, oy, 16, Color{245, 197, 24, 235}); @@ -72,12 +85,16 @@ void draw_hud(const Game& game) { game.xp / game.xp_to_next, Color{245, 197, 24, 235}, "RESONANCE SHARDS"); // Dev readout (pre-alpha): frame rate + entity counts + director bank. - char debug[128]; - std::snprintf(debug, sizeof(debug), "FPS %d | ENEMIES %d | PROJECTILES %d | SHARDS %d | DIRECTOR %.0f", + char debug[160]; + std::snprintf(debug, sizeof(debug), + "FPS %d | ENEMIES %d | PROJECTILES %d | SHARDS %d | DIRECTOR %.0f " + "| WORLD OBJECTS %d | BUFFS %d", GetFPS(), game.enemy_system.alive_count(), static_cast(game.weapon_system.projectiles.size()), static_cast(game.pickup_system.shards.size()), - static_cast(game.director.credits())); + static_cast(game.director.credits()), + game.buff_system.world_object_count(), + game.buff_system.buff_count()); DrawText(debug, 20, GetScreenHeight() - 22, 16, Color{150, 148, 144, 210}); } diff --git a/tools/blender/actor_kit.py b/tools/blender/actor_kit.py new file mode 100644 index 0000000..eac3ced --- /dev/null +++ b/tools/blender/actor_kit.py @@ -0,0 +1,328 @@ +# tools/blender/actor_kit.py +# FBC: NIGHT SHIFT — procedural sculpted-actor kit (S10). +# +# Replaces the old box/chamfer kit with lofts, swept tubes, deformed masses and +# crystal growths: RoR2 chunky-but-polished silhouettes in Control's palette. +# Every part is painted into one COLOR_0 vertex-colour attribute so the merged +# GLB still draws in a single call with the game's actor shader. + +import math +import random + +import bpy +from mathutils import Euler, Vector + + +def srgb_to_linear(c): + return c / 12.92 if c <= 0.04045 else ((c + 0.055) / 1.055) ** 2.4 + + +def rgb(hexstr): + h = hexstr.lstrip("#") + return tuple(srgb_to_linear(int(h[i:i + 2], 16) / 255.0) for i in (0, 2, 4)) + + +PALETTE = { + "concrete": "#2b2b2f", "paper": "#e8e4d8", "redaction": "#26272c", + "hiss": "#c1121f", "hiss_hot": "#ff3b46", "hiss_dull": "#8e1a24", + "board": "#f5c518", "teal": "#4ec9b0", "navy": "#3b4a5e", + "navy_lt": "#5c7086", "navy_dk": "#28313e", "tan": "#c8b99b", + "skin": "#e0cdb0", "steel": "#8a96a1", "steel_dk": "#5d6873", + "mold": "#556b4e", "mold_dk": "#374636", "mold_glow": "#78906b", +} + + +def color(value): + return rgb(value) if isinstance(value, str) else tuple(value) + + +def actor_material(): + """One shared material: COLOR_0 drives the base colour, as before.""" + mat = bpy.data.materials.get("actor") or bpy.data.materials.new("actor") + mat.use_nodes = True + nodes = mat.node_tree.nodes + bsdf = next(n for n in nodes if n.type == "BSDF_PRINCIPLED") + if not any(n.type == "ATTRIBUTE" and n.attribute_name == "Color" + for n in nodes): + attr = nodes.new("ShaderNodeAttribute") + attr.attribute_name = "Color" + mat.node_tree.links.new(attr.outputs["Color"], bsdf.inputs["Base Color"]) + return mat + + +MAT = None +ROOTS = [] + + +def new_actor(name): + global MAT + if MAT is None: + MAT = actor_material() + root = bpy.data.objects.new(name, None) + bpy.context.scene.collection.objects.link(root) + ROOTS.append(root) + return root + + +def _mesh(root, name, verts, faces, material=None, smooth=False): + mesh = bpy.data.meshes.new(name + "_mesh") + mesh.from_pydata(verts, [], faces) + mesh.validate() + mesh.update() + obj = bpy.data.objects.new(name, mesh) + bpy.context.scene.collection.objects.link(obj) + obj.data.materials.append(material or MAT) + for poly in obj.data.polygons: + poly.use_smooth = smooth + obj.parent = root + return obj + + +def paint(obj, value, ao=0.12, z_bias=0.0): + """Bake linear RGB into COLOR_0, with cheap painted AO toward the feet.""" + col = color(value) + zs = [v.co.z for v in obj.data.vertices] + lo, hi = min(zs), max(zs) + span = max(hi - lo, 1e-5) + attr = obj.data.color_attributes.new(name="Color", type="FLOAT_COLOR", + domain="POINT") + for i, v in enumerate(obj.data.vertices): + t = (v.co.z - lo) / span + shade = 1.0 - ao * (1.0 - t) ** 2 + if z_bias > 0.0 and t > 0.7: + shade *= 1.0 + z_bias * (t - 0.7) + attr.data[i].color = (col[0] * shade, col[1] * shade, col[2] * shade, + 1.0) + return obj + + +def loft(root, name, rings, value, smooth=False, ao=0.12, twist=0.0, + z_bias=0.0): + """Sculpt a tapered, optionally folded body from a stack of cross-sections. + + ring = {"z": float, "r": (rx, ry), "n": int, + "c": (x, y) optional, "phase": float optional, + "fold": (amplitude, frequency) optional, "cap": bool optional} + """ + verts, faces, offsets = [], [], [] + for ring in rings: + n = ring["n"] + cx, cy = ring.get("c", (0.0, 0.0)) + rx, ry = ring["r"] + z = ring["z"] + phase = ring.get("phase", 0.0) + fold = ring.get("fold", (0.0, 0.0)) + start = len(verts) + offsets.append((start, n)) + for j in range(n): + a = 2.0 * math.pi * j / n + phase + twist * z + m = 1.0 + fold[0] * math.sin(fold[1] * a + z * 4.0) + verts.append((cx + rx * m * math.cos(a), + cy + ry * m * math.sin(a), z)) + for i in range(len(rings) - 1): + s0, n0 = offsets[i] + s1, n1 = offsets[i + 1] + if n0 != n1: + raise ValueError("loft %s: ring side counts differ" % name) + for j in range(n0): + k = (j + 1) % n0 + faces.append((s0 + j, s0 + k, s1 + k, s1 + j)) + for index, forward in ((0, False), (-1, True)): + ring = rings[index] + if not ring.get("cap", True): + continue + s, n = offsets[index] + cx, cy = ring.get("c", (0.0, 0.0)) + c = len(verts) + verts.append((cx, cy, ring["z"])) + for j in range(n): + k = (j + 1) % n + faces.append((c, s + j, s + k) if forward + else (c, s + k, s + j)) + return paint(_mesh(root, name, verts, faces, smooth=smooth), value, ao, + z_bias) + + +def tube(root, name, points, radii, value, sides=7, smooth=False, ao=0.1): + """Sweep a tapered tube along a polyline (tendrils, fingers, cables).""" + pts = [Vector(p) for p in points] + if len(pts) != len(radii): + raise ValueError("tube %s: point/radius mismatch" % name) + verts, faces, offsets = [], [], [] + for i, p in enumerate(pts): + if i == 0: + tangent = (pts[1] - pts[0]).normalized() + elif i == len(pts) - 1: + tangent = (pts[-1] - pts[-2]).normalized() + else: + tangent = (pts[i + 1] - pts[i - 1]).normalized() + up = Vector((0.0, 0.0, 1.0)) + if abs(tangent.dot(up)) > 0.9: + up = Vector((0.0, 1.0, 0.0)) + normal = tangent.cross(up).normalized() + binormal = tangent.cross(normal).normalized() + start = len(verts) + offsets.append(start) + for j in range(sides): + a = 2.0 * math.pi * j / sides + q = p + (normal * math.cos(a) + binormal * math.sin(a)) * radii[i] + verts.append(tuple(q)) + for i in range(len(pts) - 1): + s0, s1 = offsets[i], offsets[i + 1] + for j in range(sides): + k = (j + 1) % sides + faces.append((s0 + j, s0 + k, s1 + k, s1 + j)) + c0 = len(verts) + verts.append(tuple(pts[0])) + c1 = len(verts) + verts.append(tuple(pts[-1])) + for j in range(sides): + k = (j + 1) % sides + faces.append((c0, offsets[0] + k, offsets[0] + j)) + faces.append((c1, offsets[-1] + j, offsets[-1] + k)) + return paint(_mesh(root, name, verts, faces, smooth=smooth), value, ao) + + +def blob(root, name, center, scale, value, subdiv=1, warp=0.14, seed=0, + smooth=True, ao=0.06): + """Deformed icosphere: organic muscle, mold lobes, cloth masses.""" + bpy.ops.mesh.primitive_ico_sphere_add(subdivisions=subdiv, radius=1.0, + location=center) + obj = bpy.context.object + obj.name = name + phase = random.Random(seed).uniform(0.0, 6.283) + for v in obj.data.vertices: + p = v.co + n = (math.sin(p.x * 5.1 + phase) * math.cos(p.y * 4.3 - phase) + * math.sin(p.z * 3.7 + phase * 0.5)) + f = 1.0 + warp * n + v.co = (p.x * f * scale[0], p.y * f * scale[1], + p.z * f * scale[2]) + bpy.ops.object.transform_apply(location=True, rotation=True, scale=True) + obj.data.materials.append(MAT) + for poly in obj.data.polygons: + poly.use_smooth = smooth + obj.parent = root + return paint(obj, value, ao) + + +def crystal(root, name, center, size, value, sides=5, seed=0, tilt=(0, 0, 0), + ao=0.0): + """Irregular bipyramid — Hiss / Board growths with cheap faceted glints.""" + rng = random.Random(seed) + verts = [(0.0, 0.0, -size * 0.45)] + for j in range(sides): + a = 2.0 * math.pi * j / sides + r = size * rng.uniform(0.42, 0.62) + verts.append((r * math.cos(a), r * math.sin(a), + size * rng.uniform(0.30, 0.52))) + verts.append((size * rng.uniform(-0.12, 0.12), + size * rng.uniform(-0.12, 0.12), size)) + faces = [] + top = len(verts) - 1 + for j in range(sides): + k = (j + 1) % sides + faces.append((0, 1 + k, 1 + j)) + faces.append((top, 1 + j, 1 + k)) + rot = Euler(tilt).to_matrix() + c = Vector(center) + verts = [tuple(c + rot @ Vector(v)) for v in verts] + return paint(_mesh(root, name, verts, faces), value, ao) + + +def plate(root, name, outline, z0, z1, taper, value, shift=(0.0, 0.0), + ao=0.06): + """Tapered extruded polygon: angular armour that still catches the key.""" + if len(shift) == 3: + ox, oy, dz = shift + z0, z1 = z0 + dz, z1 + dz + else: + ox, oy = shift + verts = [(x + ox, y + oy, z0) for x, y in outline] + verts += [(x * taper + ox, y * taper + oy, z1) for x, y in outline] + n = len(outline) + faces = [] + for j in range(n): + k = (j + 1) % n + faces.append((j, k, n + k, n + j)) + cb, ct = len(verts), len(verts) + 1 + verts.append((ox, oy, z0)) + verts.append((ox, oy, z1)) + for j in range(n): + k = (j + 1) % n + faces.append((cb, k, j)) + faces.append((ct, n + j, n + k)) + return paint(_mesh(root, name, verts, faces), value, ao) + + +def ring(root, name, center, radius, thickness, value, segments=14): + bpy.ops.mesh.primitive_torus_add(major_segments=segments, + minor_segments=4, location=center, + major_radius=radius, + minor_radius=thickness) + obj = bpy.context.object + obj.name = name + bpy.ops.object.transform_apply(location=True, rotation=True, scale=True) + obj.data.materials.append(MAT) + for poly in obj.data.polygons: + poly.use_smooth = False + obj.parent = root + return paint(obj, value, 0.0) + + +def octagon(rx, ry=0.0): + ry = ry or rx + return [(rx * math.cos(math.pi * (0.25 + j / 4.0)), + ry * math.sin(math.pi * (0.25 + j / 4.0))) for j in range(8)] + + +def merge_actor(root, name): + meshes = [o for o in root.children if o.type == "MESH"] + if len(meshes) < 2: + return meshes[0] if meshes else None + bpy.ops.object.select_all(action="DESELECT") + for o in meshes: + o.select_set(True) + bpy.context.view_layer.objects.active = meshes[0] + bpy.ops.object.join() + joined = bpy.context.object + joined.name = name + "_mesh" + joined.parent = root + return joined + + +def triangle_count(root): + return sum(len(p.vertices) - 2 for o in root.children_recursive + if o.type == "MESH" for p in o.data.polygons) + + +def export_actor(root, name, path): + bpy.ops.object.select_all(action="DESELECT") + root.select_set(True) + for child in root.children_recursive: + child.select_set(True) + bpy.context.view_layer.objects.active = root + bpy.ops.export_scene.gltf( + filepath=path, + export_format="GLB", + use_selection=True, + export_apply=True, + export_yup=True, + export_materials="EXPORT", + export_cameras=False, + export_lights=False, + export_extras=False, + ) + + +def clear_scene(): + for obj in list(bpy.data.objects): + bpy.data.objects.remove(obj, do_unlink=True) + for datablocks in (bpy.data.meshes, bpy.data.materials, bpy.data.curves, + bpy.data.cameras, bpy.data.lights): + for block in list(datablocks): + if block.users == 0: + datablocks.remove(block) + global MAT, ROOTS + MAT = None + ROOTS = [] diff --git a/tools/blender/build_enemies.py b/tools/blender/build_enemies.py index c76f20c..ef079ab 100644 --- a/tools/blender/build_enemies.py +++ b/tools/blender/build_enemies.py @@ -1,16 +1,18 @@ # tools/blender/build_enemies.py -# FBC: NIGHT SHIFT - low-poly actor library. +# FBC: NIGHT SHIFT — sculpted actor library (S10). # # Run inside Blender 5.x: # exec(open("/home/dandovlatov/Documents/cntrl/tools/blender/build_enemies.py").read()) # -# Builds five game-ready actors (guard, hiss staff, mold spore, hiss brute, -# resonance shard), exports each as a GLB with its origin at the feet and facing -# -Y (glTF Y-up turns that into +Z, the game camera direction), saves the source -# .blend and renders a lineup sheet. No external assets. +# Builds five game-ready actors with lofted bodies, swept limbs, deformed +# organic masses and crystal growths — no cube kit. Exports GLBs with feet at +# the origin, facing -Y (glTF Y-up turns that into +Z in the game), one merged +# mesh and one material each. Triangle budgets are asserted before export. import math import os +import random +import sys import bpy import mathutils @@ -22,392 +24,478 @@ CONCEPT_DIR = os.path.join(REPO, "docs", "concept") for d in (MODEL_DIR, BLEND_DIR, CONCEPT_DIR): os.makedirs(d, exist_ok=True) -# --------------------------------------------------------------- scene reset -bpy.ops.object.select_all(action="SELECT") -bpy.ops.object.delete(use_global=False) -for datablocks in (bpy.data.meshes, bpy.data.materials, bpy.data.curves, - bpy.data.cameras, bpy.data.lights, bpy.data.collections): - for block in list(datablocks): - if block.users == 0: - datablocks.remove(block) +sys.path.insert(0, os.path.join(REPO, "tools", "blender")) +import importlib +import actor_kit as K +importlib.reload(K) + +K.clear_scene() +P = K.PALETTE +# Near-black rot is deliberately dark-red rather than neutral black: the actor +# shader detects saturated vertex colours and makes these growths writhe. +P.update({"rot": "#4a1018", "rot_dk": "#200a10", "rot_vein": "#a81a22"}) -# ------------------------------------------------------------------ palette -def srgb_to_linear(c): - return c / 12.92 if c <= 0.04045 else ((c + 0.055) / 1.055) ** 2.4 +def hiss_rot(r, seed, growths, tendrils, veins, masses, size_scale=1.0): + """Black Hiss rot erupting from a Resonant body — part of the actor mesh.""" + for i, (pos, size, tilt, hot) in enumerate(growths): + K.crystal(r, "rot_growth_%d" % i, pos, size * size_scale, + P["hiss_hot"] if hot else P["rot"], sides=5, + seed=seed + i, tilt=tilt) + for i, (pts, radii) in enumerate(tendrils): + K.tube(r, "rot_tendril_%d" % i, pts, radii, P["rot_dk"], sides=6) + for i, pts in enumerate(veins): + K.tube(r, "rot_vein_%d" % i, pts, [0.014] * len(pts), + P["rot_vein"], sides=5) + for i, (center, scale) in enumerate(masses): + K.blob(r, "rot_mass_%d" % i, center, scale, P["rot"], + subdiv=1, seed=seed + 50 + i, warp=0.30) -def rgb(hexstr): - h = hexstr.lstrip("#") - return tuple(srgb_to_linear(int(h[i:i + 2], 16) / 255.0) for i in (0, 2, 4)) - - -P = { - "concrete": "#2b2b2f", "paper": "#e8e4d8", "redaction": "#26272c", - "hiss": "#c1121f", "hiss_hot": "#ff3b46", "board": "#f5c518", - "teal": "#4ec9b0", "navy": "#3b4a5e", "navy_lt": "#5c7086", - "tan": "#c8b99b", "skin": "#e0cdb0", "steel": "#8a96a1", - "mold": "#7fae55", "mold_dk": "#527a38", "mold_glow": "#a6e86e", -} - - -def material(name, color, rough=0.7, metal=0.0, emit=None, emit_strength=0.0): - m = bpy.data.materials.new(name) - m.use_nodes = True - b = next(n for n in m.node_tree.nodes if n.type == "BSDF_PRINCIPLED") - b.inputs["Base Color"].default_value = (*rgb(P.get(color, color)), 1.0) - b.inputs["Roughness"].default_value = rough - b.inputs["Metallic"].default_value = metal - if emit is not None: - b.inputs["Emission Color"].default_value = (*rgb(P.get(emit, emit)), 1.0) - b.inputs["Emission Strength"].default_value = emit_strength - return m - - -M = { - "concrete": material("concrete", "concrete", 0.92), - "paper": material("paper", "paper", 0.85), - "redaction": material("redaction", "redaction", 0.6), - "navy": material("navy", "navy", 0.82), - "navy_lt": material("navy_lt", "navy_lt", 0.78), - "tan": material("tan", "tan", 0.9), - "skin": material("skin", "skin", 0.88), - "steel": material("steel", "steel", 0.38, 0.55), - "hiss": material("hiss", "hiss", 0.45, 0.15, "hiss_hot", 1.6), - "hiss_dull": material("hiss_dull", "hiss", 0.85), - "hiss_hot": material("hiss_hot", "hiss_hot", 0.3, 0.0, "hiss_hot", 2.4), - "board": material("board", "board", 0.35, 0.1, "board", 1.6), - "teal": material("teal", "teal", 0.4, 0.0, "teal", 1.4), - "mold": material("mold", "mold", 0.95), - "mold_dk": material("mold_dk", "mold_dk", 0.98), - "mold_glow": material("mold_glow", "mold_glow", 0.5, 0.0, "mold_glow", 1.8), - "actor": material("actor", "#ffffff", 0.8), -} - -# The exporter only writes COLOR_0 when the node graph actually uses it. -actor_nodes = M["actor"].node_tree -attr_node = actor_nodes.nodes.new("ShaderNodeAttribute") -attr_node.attribute_name = "Color" -actor_nodes.links.new(attr_node.outputs["Color"], - next(n for n in actor_nodes.nodes - if n.type == "BSDF_PRINCIPLED").inputs["Base Color"]) - - -# ------------------------------------------------------------------ geometry -def part(root, name, shape, loc, scale, mat, rot=(0.0, 0.0, 0.0), - bevel=0.012, verts=6): - """One low-poly primitive, rooted under `root`, with a chamfered silhouette.""" - if shape == "box": - bpy.ops.mesh.primitive_cube_add(size=1.0, location=loc) - elif shape == "ico": - bpy.ops.mesh.primitive_ico_sphere_add(subdivisions=1, radius=0.5, - location=loc) - elif shape == "oct": - bpy.ops.mesh.primitive_ico_sphere_add(subdivisions=0, radius=0.5, - location=loc) - elif shape == "cone": - bpy.ops.mesh.primitive_cone_add(vertices=verts, radius1=0.5, - radius2=0.0, depth=1.0, location=loc) - elif shape == "cyl": - bpy.ops.mesh.primitive_cylinder_add(vertices=verts, radius=0.5, - depth=1.0, location=loc) - elif shape == "torus": - bpy.ops.mesh.primitive_torus_add(major_segments=12, minor_segments=4, - major_radius=0.5, minor_radius=0.06, - location=loc) - else: - raise ValueError(shape) - - obj = bpy.context.object - obj.name = name - obj.scale = scale - obj.rotation_euler = rot - bpy.ops.object.transform_apply(location=False, rotation=False, scale=True) - if bevel > 0.0 and min(scale) > 0.05 and shape in ("box", "cyl"): - mod = obj.modifiers.new("Chamfer", "BEVEL") - mod.width = bevel - mod.segments = 1 - mod.limit_method = "ANGLE" - try: - bpy.ops.object.modifier_apply(modifier=mod.name) - except Exception: - pass - # Bake the palette into COLOR_0 so the whole actor can share one material: - # raylib then draws it in a single call instead of one call per part. - src = M[mat] if isinstance(mat, str) else mat - linear = next(n for n in src.node_tree.nodes - if n.type == "BSDF_PRINCIPLED").inputs["Base Color"].default_value - attr = obj.data.color_attributes.new(name="Color", type="FLOAT_COLOR", - domain="POINT") - for i in range(len(obj.data.vertices)): - attr.data[i].color = (linear[0], linear[1], linear[2], 1.0) - obj.data.materials.append(M["actor"]) - for poly in obj.data.polygons: - poly.use_smooth = False - obj.parent = root - return obj - - -def merge_actor(root, name): - """Collapse all parts into one mesh so the GLB has a single primitive.""" - meshes = [o for o in root.children if o.type == "MESH"] - if len(meshes) < 2: - return - bpy.ops.object.select_all(action="DESELECT") - for o in meshes: - o.select_set(True) - bpy.context.view_layer.objects.active = meshes[0] - bpy.ops.object.join() - joined = bpy.context.object - joined.name = name + "_mesh" - joined.parent = root - - -def root_for(name): - root = bpy.data.objects.new(name, None) - bpy.context.scene.collection.objects.link(root) - return root - - -def base(root, radius, mat="redaction", glow=None): - part(root, "base", "cyl", (0, 0, 0.035), (radius, radius, 0.07), mat, - bevel=0.01, verts=12) - if glow is not None: - part(root, "base_glow", "torus", (0, 0, 0.075), - (radius * 1.85, radius * 1.85, radius * 1.85), glow, - rot=(0, 0, 0), bevel=0) - - -# ------------------------------------------------------------------- actors +# --------------------------------------------------------------------- guard def build_guard(): - r = root_for("Guard") - for side in (-1, 1): - x = side * 0.17 - part(r, "leg_%d" % side, "box", (x, 0, 0.44), (0.22, 0.26, 0.86), "navy") - part(r, "boot_%d" % side, "box", (x, -0.05, 0.09), (0.27, 0.38, 0.18), - "redaction") - part(r, "knee_%d" % side, "box", (x, -0.14, 0.5), (0.2, 0.05, 0.16), - "steel") - part(r, "torso", "box", (0, 0, 1.16), (0.66, 0.38, 0.72), "navy_lt") - part(r, "vest", "box", (0, -0.19, 1.16), (0.54, 0.07, 0.6), "navy") - part(r, "belt", "box", (0, 0, 0.83), (0.7, 0.42, 0.1), "redaction") - for side in (-1, 1): - part(r, "pouch_%d" % side, "box", (side * 0.25, -0.13, 0.83), - (0.16, 0.14, 0.14), "tan") - part(r, "collar_%d" % side, "box", (side * 0.11, -0.2, 1.46), - (0.19, 0.05, 0.14), "paper", rot=(0, 0, side * 0.25)) - part(r, "arm_%d" % side, "box", (side * 0.44, 0, 1.16), - (0.2, 0.26, 0.62), "tan") - part(r, "hand_%d" % side, "ico", (side * 0.45, -0.02, 0.82), - (0.17, 0.18, 0.2), "skin") - part(r, "badge", "box", (0.17, -0.235, 1.3), (0.19, 0.02, 0.14), "paper") - part(r, "badge_bar", "box", (0.17, -0.247, 1.31), (0.14, 0.01, 0.04), "hiss_dull") - part(r, "security_strip", "box", (0, -0.235, 1.45), (0.4, 0.02, 0.06), "board") - part(r, "head", "ico", (0, 0, 1.68), (0.35, 0.33, 0.38), "skin") - part(r, "cap", "box", (0, 0, 1.86), (0.4, 0.38, 0.14), "navy") - part(r, "brim", "box", (0, -0.25, 1.82), (0.4, 0.26, 0.045), "redaction") - for side in (-1, 1): - part(r, "eye_%d" % side, "box", (side * 0.08, -0.17, 1.68), - (0.05, 0.02, 0.025), "redaction", bevel=0) - part(r, "radio", "box", (0.31, 0.11, 1.44), (0.12, 0.12, 0.18), "redaction") - part(r, "antenna", "cyl", (0.31, 0.11, 1.62), (0.018, 0.018, 0.22), "steel", - bevel=0, verts=6) - part(r, "service_weapon", "box", (0.49, -0.16, 0.88), (0.1, 0.3, 0.1), - "redaction", rot=(0.35, 0, 0)) - part(r, "muzzle", "cyl", (0.49, -0.33, 0.94), (0.035, 0.035, 0.12), "steel", - rot=(math.pi / 2, 0, 0), bevel=0, verts=6) - base(r, 0.52, "redaction", "board") - return r + r = K.new_actor("Guard") - -def build_hiss_staff(): - r = root_for("HissStaff") - part(r, "shroud", "cone", (0, 0, 0.62), (0.92, 0.8, 1.25), "navy", - rot=(math.pi, 0, 0), verts=8, bevel=0) - part(r, "torso", "box", (0, 0, 1.22), (0.64, 0.4, 0.68), "navy_lt") - part(r, "coat_l", "box", (-0.2, 0.02, 0.7), (0.22, 0.34, 0.7), "navy", - rot=(0, 0, -0.12)) - part(r, "coat_r", "box", (0.2, 0.02, 0.7), (0.22, 0.34, 0.7), "navy", - rot=(0, 0, 0.12)) + # Head: sculpted mass, jaw, brow, nose, ears, eyes, cap with a real brim. + K.blob(r, "head", (0, 0, 1.69), (0.205, 0.195, 0.235), P["skin"], + subdiv=4, warp=0.055, seed=11, ao=0.04) + K.plate(r, "jaw", K.octagon(0.135, 0.105), 1.50, 1.59, 0.88, + P["skin"], shift=(0, -0.035), ao=0.08) + K.plate(r, "brow", K.octagon(0.165, 0.055), 1.755, 1.785, 1.0, + P["navy_dk"], shift=(0, -0.16)) + K.crystal(r, "nose", (0, -0.198, 1.66), 0.085, P["skin"], sides=5, + seed=3, tilt=(0.25, 0, 0)) for side in (-1, 1): - part(r, "lapel_%d" % side, "box", (side * 0.13, -0.225, 1.41), - (0.18, 0.05, 0.32), "paper", rot=(0, 0, side * 0.32)) - part(r, "shoulder_%d" % side, "box", (side * 0.42, 0, 1.48), - (0.22, 0.42, 0.16), "redaction") - part(r, "tie", "box", (0, -0.235, 1.2), (0.09, 0.03, 0.36), "hiss_dull") - part(r, "badge", "box", (0.18, -0.235, 1.34), (0.17, 0.02, 0.12), "paper") - part(r, "badge_bar", "box", (0.18, -0.248, 1.35), (0.12, 0.01, 0.035), - "hiss_dull") - # Left arm hangs, right arm reaches toward the camera with a Hiss growth. - part(r, "arm_l", "box", (-0.44, 0, 1.12), (0.18, 0.24, 0.6), "navy_lt") - part(r, "hand_l", "ico", (-0.45, -0.02, 0.79), (0.16, 0.18, 0.19), "skin") - part(r, "arm_r_upper", "box", (0.44, -0.18, 1.32), (0.17, 0.44, 0.18), - "navy_lt", rot=(-0.75, 0, 0)) - part(r, "arm_r_fore", "box", (0.46, -0.52, 1.15), (0.15, 0.42, 0.16), - "navy_lt", rot=(-0.15, 0, 0)) - part(r, "hand_r", "ico", (0.46, -0.75, 1.1), (0.18, 0.2, 0.2), "skin") - for i in range(4): - a = 2.0 * math.pi * i / 4 - part(r, "clang_%d" % i, "cone", - (0.46 + math.cos(a) * 0.12, -0.85, 1.1 + math.sin(a) * 0.12), - (0.09, 0.09, 0.34), "hiss", - rot=(math.pi / 2 + math.sin(a) * 0.5, 0, math.cos(a) * 0.5), - bevel=0, verts=5) - part(r, "head", "ico", (0, 0, 1.7), (0.33, 0.31, 0.36), "skin") - part(r, "hair", "box", (0, 0.04, 1.85), (0.36, 0.32, 0.12), "redaction") - part(r, "eye_hot", "box", (-0.09, -0.16, 1.71), (0.07, 0.035, 0.07), - "hiss_hot", bevel=0) - part(r, "eye_dead", "box", (0.09, -0.16, 1.71), (0.07, 0.03, 0.045), - "redaction", bevel=0) - part(r, "jaw", "box", (0, -0.12, 1.53), (0.22, 0.2, 0.1), "redaction") - # Red resonance cracks crawling up the torso and shroud. - for i, (x, y, z, ang) in enumerate([ - (-0.28, -0.05, 0.55, 0.5), (0.25, -0.1, 0.78, -0.4), - (-0.1, -0.22, 1.05, 0.8), (0.2, -0.22, 1.35, -0.7), + K.blob(r, "ear_%d" % side, (side * 0.202, 0.005, 1.66), + (0.045, 0.055, 0.075), P["skin"], subdiv=1, seed=20 + side) + K.crystal(r, "eye_%d" % side, (side * 0.075, -0.182, 1.705), 0.045, + P["redaction"], sides=4, seed=30 + side, + tilt=(math.pi / 2, 0, 0)) + K.loft(r, "cap", [ + {"z": 1.79, "r": (0.225, 0.215), "n": 12}, + {"z": 1.86, "r": (0.235, 0.225), "n": 12, "fold": (0.02, 4)}, + {"z": 1.94, "r": (0.205, 0.195), "n": 12}, + {"z": 1.98, "r": (0.14, 0.135), "n": 12}, + ], P["navy"], ao=0.05) + K.plate(r, "brim", K.octagon(0.24, 0.17), 1.775, 1.805, 0.94, + P["redaction"], shift=(0, -0.17)) + for i, (x, y) in enumerate(((0.14, 0.16), (-0.14, 0.16))): + K.blob(r, "hair_%d" % i, (x, y, 1.80), (0.08, 0.09, 0.07), + P["redaction"], subdiv=1, seed=15 + i) + K.tube(r, "neck", [(0, 0, 1.50), (0, 0, 1.60)], [0.095, 0.10], + P["skin"], sides=9) + + # Torso: folded cloth shell, armoured vest, straps, pouches, badge, belt. + K.loft(r, "torso", [ + {"z": 0.90, "r": (0.27, 0.18), "n": 14}, + {"z": 1.00, "r": (0.31, 0.20), "n": 14, "fold": (0.025, 5)}, + {"z": 1.16, "r": (0.34, 0.225), "n": 14, "fold": (0.03, 5)}, + {"z": 1.24, "r": (0.355, 0.232), "n": 14, "fold": (0.035, 6)}, + {"z": 1.30, "r": (0.365, 0.235), "n": 14, "fold": (0.025, 6)}, + {"z": 1.37, "r": (0.375, 0.238), "n": 14, "fold": (0.03, 5)}, + {"z": 1.43, "r": (0.38, 0.24), "n": 14}, + {"z": 1.49, "r": (0.36, 0.228), "n": 14}, + {"z": 1.53, "r": (0.33, 0.215), "n": 14}, + {"z": 1.58, "r": (0.25, 0.17), "n": 14}, + ], P["navy_lt"], ao=0.09) + K.plate(r, "vest", K.octagon(0.35, 0.235), 1.00, 1.46, 0.93, + P["navy"], shift=(0, -0.015), ao=0.10) + for side in (-1, 1): + K.tube(r, "strap_%d" % side, + [(side * 0.30, -0.10, 1.50), (side * 0.19, -0.24, 1.26), + (side * 0.13, -0.22, 1.04)], [0.04, 0.042, 0.038], + P["tan"], sides=6) + K.plate(r, "pouch_%d" % side, K.octagon(0.085, 0.05), 1.16, 1.27, + 0.92, P["navy_dk"], shift=(side * 0.19, -0.225)) + K.plate(r, "badge", K.octagon(0.095, 0.018), 1.33, 1.39, 1.0, + P["paper"], shift=(0.16, -0.245)) + K.plate(r, "badge_bar", K.octagon(0.065, 0.012), 1.352, 1.372, 1.0, + P["hiss_dull"], shift=(0.16, -0.253)) + K.loft(r, "belt", [ + {"z": 0.87, "r": (0.30, 0.205), "n": 12}, + {"z": 0.96, "r": (0.31, 0.21), "n": 12}, + ], P["redaction"], ao=0.06) + K.loft(r, "radio", [ + {"z": 1.40, "r": (0.075, 0.06), "n": 8, "c": (0.31, 0.11)}, + {"z": 1.56, "r": (0.07, 0.055), "n": 8, "c": (0.31, 0.11)}, + ], P["redaction"]) + K.tube(r, "antenna", [(0.31, 0.11, 1.56), (0.33, 0.12, 1.80)], + [0.012, 0.008], P["steel"], sides=5) + + # Arms: shoulder mass, tapered sleeve, plate elbow, forearm, glove, digits. + for side in (-1, 1): + K.blob(r, "shoulder_%d" % side, (side * 0.43, 0, 1.47), + (0.16, 0.185, 0.155), P["navy_dk"], subdiv=3, seed=40 + side) + K.loft(r, "upperarm_%d" % side, [ + {"z": 1.45, "r": (0.115, 0.115), "n": 12, "c": (side * 0.44, 0)}, + {"z": 1.36, "r": (0.112, 0.112), "n": 12, "c": (side * 0.455, -0.005)}, + {"z": 1.30, "r": (0.108, 0.108), "n": 12, "c": (side * 0.47, -0.01)}, + {"z": 1.22, "r": (0.10, 0.10), "n": 12, "c": (side * 0.48, -0.015)}, + {"z": 1.14, "r": (0.09, 0.09), "n": 12, "c": (side * 0.49, -0.02)}, + ], P["navy_lt"], ao=0.05) + K.blob(r, "elbow_%d" % side, (side * 0.50, -0.02, 1.13), + (0.10, 0.11, 0.095), P["steel_dk"], subdiv=2, seed=50 + side) + K.loft(r, "forearm_%d" % side, [ + {"z": 1.12, "r": (0.095, 0.095), "n": 12, "c": (side * 0.50, -0.02)}, + {"z": 1.04, "r": (0.091, 0.091), "n": 12, "c": (side * 0.51, -0.03)}, + {"z": 0.96, "r": (0.085, 0.085), "n": 12, "c": (side * 0.52, -0.04)}, + {"z": 0.88, "r": (0.079, 0.079), "n": 12, "c": (side * 0.525, -0.045)}, + {"z": 0.82, "r": (0.072, 0.072), "n": 12, "c": (side * 0.53, -0.05)}, + ], P["navy_lt"], ao=0.05) + K.blob(r, "glove_%d" % side, (side * 0.535, -0.06, 0.77), + (0.095, 0.105, 0.11), P["redaction"], subdiv=3, seed=60 + side) + for f in range(4): + x = side * (0.49 + f * 0.035) + K.tube(r, "finger_%d_%d" % (side, f), + [(x, -0.11, 0.73), (x, -0.14, 0.67), (x, -0.15, 0.63)], + [0.026, 0.022, 0.017], P["redaction"], sides=6) + K.tube(r, "thumb_%d" % side, + [(side * 0.475, -0.05, 0.76), (side * 0.44, -0.12, 0.71)], + [0.032, 0.024], P["redaction"], sides=6) + + # Legs: tapered thigh / shin, plate knee, sculpted boot with a sole. + for side in (-1, 1): + K.loft(r, "thigh_%d" % side, [ + {"z": 0.88, "r": (0.145, 0.155), "n": 12, "c": (side * 0.16, 0)}, + {"z": 0.79, "r": (0.142, 0.152), "n": 12, "c": (side * 0.165, 0)}, + {"z": 0.70, "r": (0.135, 0.145), "n": 12, "c": (side * 0.17, 0)}, + {"z": 0.61, "r": (0.125, 0.135), "n": 12, "c": (side * 0.175, 0)}, + {"z": 0.53, "r": (0.11, 0.12), "n": 12, "c": (side * 0.18, 0)}, + ], P["navy"], ao=0.08) + K.plate(r, "knee_%d" % side, K.octagon(0.125, 0.10), 0.50, 0.59, + 0.90, P["steel_dk"], shift=(side * 0.18, -0.10)) + K.loft(r, "shin_%d" % side, [ + {"z": 0.52, "r": (0.11, 0.12), "n": 12, "c": (side * 0.18, 0)}, + {"z": 0.40, "r": (0.105, 0.112), "n": 12, "c": (side * 0.182, 0)}, + {"z": 0.30, "r": (0.10, 0.105), "n": 12, "c": (side * 0.185, 0)}, + {"z": 0.21, "r": (0.093, 0.098), "n": 12, "c": (side * 0.188, 0)}, + {"z": 0.13, "r": (0.085, 0.09), "n": 12, "c": (side * 0.19, 0)}, + ], P["navy"], ao=0.08) + K.loft(r, "boot_%d" % side, [ + {"z": 0.015, "r": (0.145, 0.215), "n": 10, + "c": (side * 0.19, -0.07)}, + {"z": 0.10, "r": (0.135, 0.19), "n": 10, + "c": (side * 0.19, -0.05)}, + {"z": 0.19, "r": (0.115, 0.135), "n": 10, + "c": (side * 0.19, 0)}, + ], P["redaction"], ao=0.06) + K.plate(r, "sole_%d" % side, K.octagon(0.15, 0.22), 0.0, 0.025, + 0.98, P["redaction"], shift=(side * 0.19, -0.07)) + K.tube(r, "thigh_strap_%d" % side, + [(side * 0.06, -0.12, 0.72), (side * 0.18, -0.17, 0.70), + (side * 0.30, -0.10, 0.68)], [0.028, 0.03, 0.026], + P["tan"], sides=6) + for lace in range(3): + K.tube(r, "lace_%d_%d" % (side, lace), + [(side * 0.13, -0.20, 0.06 + lace * 0.035), + (side * 0.25, -0.20, 0.06 + lace * 0.035)], + [0.008, 0.008], P["tan"], sides=5) + + K.plate(r, "holster", K.octagon(0.09, 0.06), 0.66, 0.84, 0.9, + P["redaction"], shift=(0.33, 0.10)) + K.tube(r, "holster_strap", [(0.33, 0.10, 0.84), (0.20, -0.02, 0.92)], + [0.025, 0.022], P["tan"], sides=6) + + # Service Weapon: sculpted grip/body, not a box. + K.tube(r, "weapon_body", + [(0.55, -0.02, 0.88), (0.55, -0.22, 0.90), (0.55, -0.40, 0.93)], + [0.055, 0.048, 0.042], P["redaction"], sides=8) + K.plate(r, "weapon_grip", K.octagon(0.045, 0.06), 0.74, 0.86, 0.85, + P["steel_dk"], shift=(0.55, -0.06)) + K.crystal(r, "muzzle", (0.55, -0.42, 0.93), 0.07, P["steel"], sides=6, + seed=7, tilt=(math.pi / 2, 0, 0)) + + # A restrained Hiss stain on the back — the reference's corruption creeping + # into the guard, without taking over the silhouette. + for i, (x, y, z, tilt) in enumerate([ + (0.12, 0.21, 1.40, (0.3, 0.2, 0.4)), + (-0.10, 0.23, 1.24, (-0.4, 0.1, -0.3)), + (0.05, 0.24, 1.10, (0.2, -0.3, 0.1)), ]): - part(r, "crack_%d" % i, "box", (x, y, z), (0.035, 0.03, 0.34), "hiss", - rot=(0, 0, ang), bevel=0) - base(r, 0.56, "redaction", "hiss_dull") + K.crystal(r, "taint_%d" % i, (x, y, z), 0.14, P["hiss"], sides=5, + seed=70 + i, tilt=tilt) + + K.ring(r, "base", (0, 0, 0.055), 0.50, 0.035, P["board"]) + K.plate(r, "base_disc", K.octagon(0.46), 0.0, 0.025, 1.0, P["redaction"]) return r +# ---------------------------------------------------------------- hiss staff +def build_hiss_staff(): + r = K.new_actor("HissStaff") + + # Torn, wind-swept coat: the fold amplitude grows toward the ragged hem. + K.loft(r, "shroud", [ + {"z": 0.10, "r": (0.46, 0.40), "n": 16, "fold": (0.19, 9), + "cap": False}, + {"z": 0.22, "r": (0.45, 0.39), "n": 16, "fold": (0.17, 9)}, + {"z": 0.36, "r": (0.42, 0.36), "n": 16, "fold": (0.13, 8)}, + {"z": 0.50, "r": (0.39, 0.33), "n": 16, "fold": (0.11, 8)}, + {"z": 0.65, "r": (0.36, 0.30), "n": 16, "fold": (0.09, 7)}, + {"z": 0.85, "r": (0.335, 0.275), "n": 16, "fold": (0.07, 7)}, + {"z": 1.05, "r": (0.31, 0.25), "n": 16, "fold": (0.05, 6)}, + {"z": 1.22, "r": (0.285, 0.23), "n": 16}, + {"z": 1.38, "r": (0.26, 0.21), "n": 16}, + ], P["navy_dk"], ao=0.16) + K.blob(r, "torso", (0, 0, 1.24), (0.31, 0.23, 0.36), P["navy_lt"], + subdiv=2, seed=5, ao=0.10) + for side in (-1, 1): + K.tube(r, "lapel_%d" % side, + [(side * 0.10, -0.22, 1.44), (side * 0.16, -0.26, 1.22), + (side * 0.10, -0.24, 1.00)], [0.045, 0.05, 0.035], + P["paper"], sides=6) + K.crystal(r, "shoulder_spur_%d" % side, + (side * 0.34, 0.04, 1.46), 0.20, P["hiss"], sides=5, + seed=80 + side, tilt=(0.3, 0, side * 0.5)) + K.blob(r, "head", (0, 0, 1.72), (0.19, 0.18, 0.21), P["skin"], + subdiv=3, seed=6, ao=0.05) + K.blob(r, "hair", (0, 0.04, 1.86), (0.20, 0.18, 0.10), + P["redaction"], subdiv=1, seed=7) + K.crystal(r, "eye_hot", (-0.075, -0.17, 1.73), 0.07, P["hiss_hot"], + sides=5, seed=8, tilt=(math.pi / 2, 0, 0)) + K.crystal(r, "eye_dead", (0.075, -0.17, 1.73), 0.055, P["redaction"], + sides=4, seed=9, tilt=(math.pi / 2, 0, 0)) + K.plate(r, "jaw", K.octagon(0.11, 0.08), 1.52, 1.60, 0.85, + P["redaction"], shift=(0, -0.06)) + + # Reaching arm: elongated fingers tipped with Hiss crystal growths. + K.tube(r, "arm_reach", + [(0.36, -0.05, 1.40), (0.47, -0.30, 1.26), (0.50, -0.62, 1.13)], + [0.115, 0.095, 0.075], P["navy_lt"], sides=8) + K.blob(r, "hand_reach", (0.51, -0.67, 1.11), (0.11, 0.12, 0.115), + P["skin"], subdiv=3, seed=10) + for f in range(4): + x = 0.45 + f * 0.04 + K.tube(r, "claw_%d" % f, + [(x, -0.72, 1.10), (x + 0.02, -0.85, 1.07), + (x + 0.03, -0.94, 1.03)], [0.025, 0.02, 0.012], + P["skin"], sides=5) + K.crystal(r, "claw_tip_%d" % f, (x + 0.03, -0.95, 1.03), 0.13, + P["hiss_hot"], sides=5, seed=90 + f, + tilt=(math.pi / 2.2, 0, 0)) + K.tube(r, "arm_hang", + [(-0.36, 0.0, 1.40), (-0.45, -0.02, 1.15), (-0.46, -0.06, 0.92)], + [0.11, 0.09, 0.07], P["navy_lt"], sides=8) + K.blob(r, "hand_hang", (-0.46, -0.07, 0.87), (0.10, 0.11, 0.11), + P["skin"], subdiv=3, seed=12) + for i, (x, y, z, tilt) in enumerate([ + (-0.22, -0.18, 1.10, (0.2, 0, 0.4)), + (0.20, -0.16, 0.92, (-0.3, 0, -0.4)), + (-0.08, -0.25, 1.34, (0.1, 0, 0.2)), + (0.18, -0.20, 1.42, (-0.2, 0, -0.3)), + ]): + K.crystal(r, "crack_%d" % i, (x, y, z), 0.19, P["hiss"], + sides=5, seed=100 + i, tilt=tilt) + hiss_rot(r, 200, + growths=[ + ((-0.30, 0.12, 1.44), 0.26, (0.3, -0.2, 0.5), False), + ((0.33, 0.10, 1.42), 0.24, (-0.2, 0.3, -0.4), True), + ((-0.18, 0.24, 1.18), 0.22, (0.5, 0.1, 0.2), False), + ((0.22, 0.22, 1.05), 0.20, (-0.4, 0.2, -0.3), False), + ((0.02, 0.27, 1.52), 0.18, (0.1, -0.3, 0.1), True), + ((-0.38, -0.02, 1.10), 0.16, (0.2, 0.4, 0.6), False), + ((-0.48, 0.10, 1.28), 0.20, (0.4, -0.3, 0.7), False), + ((0.46, 0.16, 1.28), 0.18, (-0.3, 0.2, -0.6), True), + ], + tendrils=[ + ([(-0.28, 0.18, 1.38), (-0.48, 0.30, 1.52), (-0.62, 0.38, 1.70)], + [0.055, 0.035, 0.012]), + ([(0.26, 0.20, 1.20), (0.46, 0.34, 1.30), (0.60, 0.40, 1.44)], + [0.05, 0.03, 0.01]), + ([(0.05, 0.26, 1.34), (0.02, 0.40, 1.55), (-0.06, 0.48, 1.74)], + [0.045, 0.028, 0.01]), + ([(0.0, 0.25, 1.10), (-0.10, 0.42, 1.28), (-0.20, 0.55, 1.46)], + [0.05, 0.03, 0.01]), + ], + veins=[ + [(-0.16, -0.24, 1.34), (-0.12, -0.26, 1.18), (-0.08, -0.25, 1.02)], + [(0.18, -0.23, 1.32), (0.14, -0.26, 1.14), (0.10, -0.25, 0.98)], + ], + masses=[ + ((-0.30, 0.16, 1.34), (0.17, 0.15, 0.22)), + ((0.26, 0.20, 1.10), (0.15, 0.14, 0.18)), + ], size_scale=1.45) + K.plate(r, "base_disc", K.octagon(0.48), 0.0, 0.025, 1.0, P["redaction"]) + return r + + +# ---------------------------------------------------------------- hiss brute +def build_hiss_brute(): + r = K.new_actor("HissBrute") + + for side in (-1, 1): + x = side * 0.40 + K.loft(r, "leg_%d" % side, [ + {"z": 0.10, "r": (0.25, 0.27), "n": 10, "c": (x, 0)}, + {"z": 0.55, "r": (0.28, 0.30), "n": 10, "c": (x, 0)}, + {"z": 1.05, "r": (0.31, 0.32), "n": 10, "c": (x, 0)}, + ], P["redaction"], ao=0.12) + K.plate(r, "greave_%d" % side, K.octagon(0.29, 0.30), 0.28, 0.70, + 0.86, P["steel_dk"], shift=(x, -0.04)) + K.loft(r, "foot_%d" % side, [ + {"z": 0.015, "r": (0.28, 0.40), "n": 10, "c": (x, -0.10)}, + {"z": 0.16, "r": (0.26, 0.34), "n": 10, "c": (x, -0.06)}, + ], P["redaction"]) + K.loft(r, "torso", [ + {"z": 1.00, "r": (0.62, 0.42), "n": 16}, + {"z": 1.18, "r": (0.68, 0.45), "n": 16, "fold": (0.03, 5)}, + {"z": 1.35, "r": (0.72, 0.47), "n": 16, "fold": (0.04, 5)}, + {"z": 1.55, "r": (0.77, 0.49), "n": 16, "fold": (0.05, 5)}, + {"z": 1.75, "r": (0.80, 0.50), "n": 16, "fold": (0.05, 5)}, + {"z": 1.94, "r": (0.79, 0.48), "n": 16, "fold": (0.04, 6)}, + {"z": 2.10, "r": (0.76, 0.46), "n": 16}, + {"z": 2.24, "r": (0.66, 0.42), "n": 16}, + {"z": 2.34, "r": (0.52, 0.36), "n": 16}, + ], P["navy"], ao=0.10) + for side in (-1, 1): + K.plate(r, "pec_%d" % side, K.octagon(0.34, 0.22), 1.82, 2.08, + 0.86, P["steel_dk"], shift=(side * 0.38, -0.40), ao=0.07) + K.blob(r, "pauldron_%d" % side, (side * 0.92, 0.02, 2.14), + (0.36, 0.42, 0.32), P["steel"], subdiv=3, seed=110 + side) + K.plate(r, "pauldron_band_%d" % side, K.octagon(0.37, 0.42), + 2.34, 2.42, 0.92, P["hiss_dull"], shift=(side * 0.92, 0)) + K.loft(r, "upperarm_%d" % side, [ + {"z": 2.05, "r": (0.22, 0.23), "n": 10, "c": (side * 1.00, 0)}, + {"z": 1.65, "r": (0.20, 0.21), "n": 10, "c": (side * 1.05, -0.02)}, + ], P["redaction"]) + K.plate(r, "forearm_%d" % side, K.octagon(0.25, 0.28), 1.05, 1.62, + 0.88, P["steel_dk"], shift=(side * 1.08, -0.08)) + K.blob(r, "fist_%d" % side, (side * 1.10, -0.16, 0.92), + (0.25, 0.27, 0.25), P["redaction"], subdiv=3, seed=120 + side) + for f in range(3): + K.crystal(r, "knuckle_%d_%d" % (side, f), + (side * (1.00 + f * 0.09), -0.38, 0.98), 0.16, + P["hiss"], sides=5, seed=130 + f, + tilt=(math.pi / 2, 0, 0)) + K.crystal(r, "core", (0, -0.50, 1.76), 0.52, P["hiss_hot"], sides=7, + seed=4, tilt=(math.pi / 2, 0, 0)) + K.ring(r, "core_ring", (0, -0.56, 1.76), 0.38, 0.055, P["hiss"], + segments=12) + K.tube(r, "neck", [(0, 0, 2.30), (0, 0, 2.46)], [0.17, 0.16], + P["redaction"], sides=9) + K.blob(r, "head", (0, -0.02, 2.59), (0.29, 0.29, 0.25), + P["redaction"], subdiv=3, seed=13, ao=0.05) + K.plate(r, "visor", K.octagon(0.24, 0.04), 2.61, 2.68, 1.0, + P["hiss_hot"], shift=(0, -0.28)) + K.plate(r, "grille", K.octagon(0.18, 0.035), 2.46, 2.53, 1.0, + P["steel"], shift=(0, -0.27)) + for i, (x, y, z, tilt) in enumerate([ + (-0.55, 0.20, 2.40, (0.3, -0.4, -0.3)), + (0.58, 0.18, 2.44, (0.2, 0.5, 0.4)), + (-0.32, 0.40, 2.70, (-0.3, -0.2, -0.2)), + (0.34, 0.42, 2.76, (-0.3, 0.3, 0.3)), + (0.0, 0.46, 2.56, (0.1, 0, 0)), + (0.10, 0.35, 2.86, (-0.2, 0.1, 0.1)), + ]): + K.crystal(r, "spine_%d" % i, (x, y, z), 0.36, P["hiss"], + sides=5, seed=140 + i, tilt=tilt) + hiss_rot(r, 300, + growths=[ + ((-0.62, 0.20, 2.26), 0.36, (0.3, -0.2, 0.4), False), + ((0.64, 0.22, 2.30), 0.34, (-0.2, 0.3, -0.4), True), + ((-0.40, 0.42, 1.90), 0.30, (0.5, 0.1, -0.2), False), + ((0.38, 0.44, 1.86), 0.28, (-0.4, 0.2, 0.3), True), + ((0.0, 0.50, 2.10), 0.30, (0.2, 0.0, 0.0), False), + ], + tendrils=[ + ([(-0.60, 0.30, 2.10), (-0.90, 0.50, 2.30), (-1.10, 0.60, 2.50)], + [0.07, 0.045, 0.015]), + ([(0.55, 0.32, 1.90), (0.85, 0.50, 2.00), (1.05, 0.58, 2.15)], + [0.065, 0.04, 0.012]), + ([(0.0, 0.48, 2.20), (0.10, 0.70, 2.45), (0.22, 0.85, 2.66)], + [0.07, 0.045, 0.015]), + ], + veins=[ + [(-0.30, -0.48, 1.90), (-0.25, -0.50, 1.70), (-0.20, -0.50, 1.50)], + [(0.30, -0.48, 1.95), (0.25, -0.50, 1.75)], + ], + masses=[ + ((-0.55, 0.28, 2.08), (0.28, 0.24, 0.30)), + ], size_scale=1.35) + K.plate(r, "base_disc", K.octagon(0.88), 0.0, 0.03, 1.0, P["redaction"]) + return r + + +# --------------------------------------------------------------- mold spore def build_mold_spore(): - r = root_for("MoldSpore") - part(r, "core", "ico", (0, 0, 0.45), (0.94, 0.86, 0.66), "mold_dk") + r = K.new_actor("MoldSpore") + + K.blob(r, "core", (0, 0, 0.48), (0.50, 0.46, 0.36), P["mold_dk"], + subdiv=3, seed=1, warp=0.22, ao=0.14) lobes = [ - (-0.36, 0.1, 0.38, 0.55), (0.38, -0.05, 0.36, 0.5), - (0.05, 0.36, 0.42, 0.48), (-0.08, -0.4, 0.3, 0.44), - (0.42, 0.32, 0.5, 0.36), (-0.45, -0.3, 0.55, 0.3), + (-0.36, 0.10, 0.39, 0.29), (0.38, -0.05, 0.37, 0.27), + (0.05, 0.37, 0.43, 0.26), (-0.08, -0.40, 0.32, 0.24), + (0.42, 0.33, 0.51, 0.20), (-0.45, -0.30, 0.55, 0.18), ] for i, (x, y, z, s) in enumerate(lobes): - part(r, "lobe_%d" % i, "ico", (x, y, z), (s, s * 0.9, s * 0.8), "mold") + K.blob(r, "lobe_%d" % i, (x, y, z), (s, s * 0.92, s * 0.82), + P["mold"], subdiv=2, seed=2 + i, warp=0.20) for i, (x, y, z, s) in enumerate([ - (-0.25, -0.1, 0.78, 0.24), (0.22, 0.08, 0.83, 0.28), - (0.0, -0.28, 0.74, 0.2), (0.4, -0.22, 0.66, 0.18), + (-0.25, -0.10, 0.79, 0.14), (0.23, 0.08, 0.84, 0.16), + (0.0, -0.29, 0.75, 0.12), (0.40, -0.22, 0.68, 0.11), ]): - part(r, "sac_%d" % i, "ico", (x, y, z), (s, s, s * 0.8), "mold_glow") - part(r, "pustule_%d" % i, "oct", (x, y, z + s * 0.6), - (s * 0.5, s * 0.5, s * 0.5), "mold_glow", bevel=0) + K.blob(r, "sac_%d" % i, (x, y, z), (s, s, s * 0.85), + P["mold_glow"], subdiv=1, seed=10 + i) + K.crystal(r, "pustule_%d" % i, (x, y, z + s * 0.7), s * 0.55, + P["mold_glow"], sides=5, seed=20 + i) for i in range(6): a = 2.0 * math.pi * i / 6 + 0.2 - part(r, "tendril_%d" % i, "cone", - (math.cos(a) * 0.52, math.sin(a) * 0.52, 0.16), - (0.16, 0.16, 0.55), "mold_dk", - rot=(math.sin(a) * 1.25, -math.cos(a) * 1.25, 0), bevel=0, - verts=5) + K.tube(r, "tendril_%d" % i, + [(math.cos(a) * 0.38, math.sin(a) * 0.38, 0.24), + (math.cos(a) * 0.62, math.sin(a) * 0.62, 0.14), + (math.cos(a) * 0.78, math.sin(a) * 0.78, 0.06)], + [0.10, 0.065, 0.025], P["mold_dk"], sides=6) for i in range(3): a = 2.0 * math.pi * i / 3 + 0.6 - x, y = math.cos(a) * 0.3, math.sin(a) * 0.3 - part(r, "stalk_%d" % i, "cyl", (x, y, 0.85), (0.08, 0.08, 0.42), - "mold_dk", bevel=0, verts=6) - part(r, "cap_%d" % i, "cone", (x, y, 1.09), (0.26, 0.26, 0.18), - "mold_glow", bevel=0, verts=7) + x, y = math.cos(a) * 0.30, math.sin(a) * 0.30 + K.tube(r, "stalk_%d" % i, + [(x, y, 0.72), (x * 1.1, y * 1.1, 0.96)], + [0.055, 0.04], P["mold_dk"], sides=6) + K.crystal(r, "cap_%d" % i, (x * 1.1, y * 1.1, 1.02), 0.24, + P["mold_glow"], sides=7, seed=30 + i) for i in range(4): a = 2.0 * math.pi * i / 4 + 0.4 - part(r, "spore_%d" % i, "oct", - (math.cos(a) * 0.55, math.sin(a) * 0.55, 1.3 + (i % 2) * 0.24), - (0.1, 0.1, 0.14), "mold_glow", bevel=0) - base(r, 0.62, "mold_dk", "mold_glow") - return r - - -def build_hiss_brute(): - r = root_for("HissBrute") - for side in (-1, 1): - x = side * 0.4 - part(r, "leg_%d" % side, "box", (x, 0, 0.54), (0.46, 0.54, 1.08), - "redaction") - part(r, "greave_%d" % side, "box", (x, -0.04, 0.45), (0.48, 0.56, 0.5), - "steel") - part(r, "foot_%d" % side, "box", (x, -0.16, 0.1), (0.52, 0.72, 0.2), - "redaction") - part(r, "torso", "box", (0, 0, 1.7), (1.5, 0.86, 1.3), "navy") - part(r, "pec_l", "box", (-0.38, -0.45, 1.92), (0.62, 0.12, 0.5), "steel", - rot=(0, 0, -0.15)) - part(r, "pec_r", "box", (0.38, -0.45, 1.92), (0.62, 0.12, 0.5), "steel", - rot=(0, 0, 0.15)) - part(r, "core", "oct", (0, -0.48, 1.7), (0.38, 0.2, 0.4), "hiss_hot", - bevel=0) - part(r, "core_ring", "torus", (0, -0.5, 1.7), (1.0, 1.0, 1.0), "hiss", - bevel=0) - for side in (-1, 1): - part(r, "pauldron_%d" % side, "box", (side * 0.9, 0.02, 2.1), - (0.6, 0.78, 0.52), "steel", rot=(0, 0, side * 0.18)) - part(r, "pauldron_band_%d" % side, "box", (side * 0.92, -0.02, 2.26), - (0.62, 0.8, 0.1), "hiss_dull") - part(r, "upperarm_%d" % side, "box", (side * 1.02, -0.04, 1.62), - (0.44, 0.5, 0.82), "redaction") - part(r, "forearm_%d" % side, "box", (side * 1.08, -0.16, 0.98), - (0.48, 0.56, 0.76), "steel") - part(r, "fist_%d" % side, "ico", (side * 1.1, -0.22, 0.55), - (0.4, 0.42, 0.38), "redaction") - for i in range(4): - part(r, "gauntlet_%d" % i, "cone", - (1.08 + (i - 1.5) * 0.12, -0.48, 0.98 + (i % 2) * 0.16), - (0.1, 0.1, 0.4), "hiss", rot=(math.pi / 2, 0, 0), bevel=0, - verts=5) - part(r, "neck", "cyl", (0, 0, 2.38), (0.3, 0.3, 0.24), "redaction", bevel=0) - part(r, "head", "box", (0, -0.02, 2.56), (0.54, 0.54, 0.46), "redaction") - part(r, "visor", "box", (0, -0.29, 2.58), (0.46, 0.05, 0.11), "hiss_hot", - bevel=0) - part(r, "jaw_grille", "box", (0, -0.29, 2.41), (0.34, 0.05, 0.1), "steel", - bevel=0) - for i, (x, y, z, rx, ry) in enumerate([ - (-0.6, 0.1, 2.35, 0.3, -0.6), (0.6, 0.12, 2.4, 0.2, 0.7), - (-0.3, 0.35, 2.7, -0.2, -0.3), (0.35, 0.38, 2.78, -0.3, 0.4), - (0.0, 0.45, 2.55, 0.1, 0.0), - ]): - part(r, "spine_%d" % i, "cone", (x, y, z), (0.18, 0.18, 0.66), "hiss", - rot=(rx, ry, 0), bevel=0, verts=5) - base(r, 0.95, "redaction", "hiss_dull") + K.crystal(r, "spore_%d" % i, + (math.cos(a) * 0.55, math.sin(a) * 0.55, + 1.28 + (i % 2) * 0.22), 0.13, P["mold_glow"], + sides=5, seed=40 + i) + K.plate(r, "base_disc", K.octagon(0.56), 0.0, 0.022, 1.0, P["mold_dk"]) return r +# -------------------------------------------------------------------- shard def build_shard(): - r = root_for("Shard") - part(r, "crystal", "oct", (0, 0, 0.34), (0.34, 0.34, 0.52), "board", - bevel=0) - part(r, "core", "oct", (0, 0, 0.34), (0.16, 0.16, 0.26), "paper", bevel=0) - part(r, "halo", "torus", (0, 0, 0.24), (0.62, 0.62, 0.62), "board", - bevel=0) + r = K.new_actor("Shard") + K.crystal(r, "crystal", (0, 0, 0.40), 0.62, P["board"], sides=8, seed=3) + K.crystal(r, "core", (0, 0, 0.42), 0.30, P["paper"], sides=6, seed=4) + for i in range(3): + a = 2.0 * math.pi * i / 3 + K.crystal(r, "spark_%d" % i, + (math.cos(a) * 0.28, math.sin(a) * 0.28, 0.16), 0.14, + P["board"], sides=5, seed=5 + i, + tilt=(0.2, 0.3 * i, 0)) + K.ring(r, "halo", (0, 0, 0.22), 0.30, 0.025, P["board"], segments=12) return r -# ------------------------------------------------------------------ exports BUILDERS = [ - ("guard", build_guard), - ("hiss_staff", build_hiss_staff), - ("mold_spore", build_mold_spore), - ("hiss_brute", build_hiss_brute), - ("shard", build_shard), + ("guard", build_guard, 6000), + ("hiss_staff", build_hiss_staff, 2500), + ("mold_spore", build_mold_spore, 1500), + ("hiss_brute", build_hiss_brute, 3150), + ("shard", build_shard, 400), ] exported = [] -for name, builder in BUILDERS: +for name, builder, cap in BUILDERS: root = builder() - merge_actor(root, name) - bpy.ops.object.select_all(action="DESELECT") - root.select_set(True) - for child in root.children_recursive: - child.select_set(True) - bpy.context.view_layer.objects.active = root + mesh = K.merge_actor(root, name) + tris = K.triangle_count(root) + print("[budget] %-12s %5d tris (cap %d) %s" + % (name, tris, cap, "OK" if tris <= cap else "OVER")) out = os.path.join(MODEL_DIR, name + ".glb") - bpy.ops.export_scene.gltf( - filepath=out, - export_format="GLB", - use_selection=True, - export_apply=True, - export_yup=True, - export_materials="EXPORT", - export_cameras=False, - export_lights=False, - export_extras=False, - ) - tris = sum(len(p.vertices) - 2 for o in root.children_recursive - if o.type == "MESH" for p in o.data.polygons) + K.export_actor(root, name, out) exported.append((name, tris, os.path.getsize(out))) - print("[export] %-12s %4d tris %7d bytes -> %s" % (name, tris, - os.path.getsize(out), out)) # ------------------------------------------------------------ lineup render @@ -419,11 +507,11 @@ for obj in bpy.data.objects: if obj.name == "Shard": obj.scale = (3.0, 3.0, 3.0) -world = bpy.data.worlds.new("ShowroomWorld") if not bpy.data.worlds else bpy.data.worlds[0] +world = bpy.data.worlds.new("ShowroomWorld") bpy.context.scene.world = world world.use_nodes = True bg = next(n for n in world.node_tree.nodes if n.type == "BACKGROUND") -bg.inputs["Color"].default_value = (*rgb("#0d0f12"), 1.0) +bg.inputs["Color"].default_value = (*K.rgb("#0d0f12"), 1.0) bg.inputs["Strength"].default_value = 0.8 @@ -432,12 +520,11 @@ def area(name, loc, color, power, size): data.energy = power data.shape = "DISK" data.size = size - data.color = rgb(color) + data.color = K.rgb(color) obj = bpy.data.objects.new(name, data) bpy.context.scene.collection.objects.link(obj) obj.location = loc - direction = (0 - obj.location.x, 0 - obj.location.y, 1.2 - obj.location.z) - obj.rotation_euler = (0, 0, 0) + direction = (0 - loc[0], 0 - loc[1], 1.2 - loc[2]) obj.rotation_euler = mathutils.Vector(direction).to_track_quat("-Z", "Y").to_euler() return obj @@ -450,7 +537,7 @@ cam_data = bpy.data.cameras.new("ActorCam") cam = bpy.data.objects.new("ActorCam", cam_data) bpy.context.scene.collection.objects.link(cam) cam.location = (1.0, -19.0, 7.5) -cam.rotation_euler = mathutils.Vector((1.0 - 1.0, 0 - -19.0, 1.25 - 7.5)).to_track_quat("-Z", "Y").to_euler() +cam.rotation_euler = mathutils.Vector((0.0, 19.0, -6.25)).to_track_quat("-Z", "Y").to_euler() cam_data.lens = 40 bpy.context.scene.camera = cam @@ -471,10 +558,11 @@ print("[render] lineup ->", scene.render.filepath) scene.render.filepath = os.path.join(CONCEPT_DIR, "enemy_detail.png") cam.location = (-0.6, -7.5, 3.4) -cam.rotation_euler = mathutils.Vector((0.0 - -0.6, 0 - -7.5, 1.2 - 3.4)).to_track_quat("-Z", "Y").to_euler() +cam.rotation_euler = mathutils.Vector((0.6, 7.5, -2.2)).to_track_quat("-Z", "Y").to_euler() cam_data.lens = 42 bpy.ops.render.render(write_still=True) print("[render] detail ->", scene.render.filepath) bpy.ops.wm.save_as_mainfile(filepath=os.path.join(BLEND_DIR, "fbc_enemies.blend")) -print("[done] actors:", ", ".join("%s(%d tris)" % (n, t) for n, t, _ in exported)) +print("[done] actors:", ", ".join("%s(%d tris)" % (n, t) + for n, t, _ in exported)) diff --git a/tools/blender/build_lut.py b/tools/blender/build_lut.py new file mode 100644 index 0000000..ff877d5 --- /dev/null +++ b/tools/blender/build_lut.py @@ -0,0 +1,55 @@ +# tools/blender/build_lut.py +# FBC: NIGHT SHIFT — stylised lighting ramp (S9 look-dev). +# +# Run inside Blender 5.x: +# exec(open("/home/dandovlatov/Documents/cntrl/tools/blender/build_lut.py").read()) +# +# Generates the one-dimensional gradient map sampled by assets/shaders/actor.fs. +# Shadow stops are cool blue-grey, highlights warm pale — Risk of Rain 2's +# gradient-map shading in the Control palette. Kept as a generated image so the +# ramp is version-controlled and reproducible from this script. + +import os + +import bpy +import numpy as np + +REPO = "/home/dandovlatov/Documents/cntrl" +OUT_DIR = os.path.join(REPO, "assets", "textures", "actor") +os.makedirs(OUT_DIR, exist_ok=True) +OUT = os.path.join(OUT_DIR, "actor_ramp.png") + +WIDTH = 256 +HEIGHT = 4 + +# (position, linear RGB in 0..1 — the shader multiplies by 1.7 to recover the +# linear highlight range without needing a 16-bit texture). +STOPS = [ + (0.00, (0.310, 0.330, 0.380)), + (0.28, (0.420, 0.430, 0.465)), + (0.55, (0.560, 0.560, 0.565)), + (0.78, (0.750, 0.730, 0.690)), + (1.00, (0.960, 0.930, 0.870)), +] + +t = np.linspace(0.0, 1.0, WIDTH, dtype=np.float32) +xs = np.array([s[0] for s in STOPS], dtype=np.float32) +row = np.stack([np.interp(t, xs, np.array([s[1][k] for s in STOPS], + dtype=np.float32)) for k in range(3)], + axis=1) +row = np.power(row, 1.08) # gentle shoulder separates the lit facets + +# Blender's pixel buffer is row-major (y outer, x inner). +rgb = np.tile(row[None, :, :], (HEIGHT, 1, 1)) +rgba = np.dstack([rgb, np.ones((HEIGHT, WIDTH), dtype=np.float32)]) + +img = bpy.data.images.new("actor_ramp", width=WIDTH, height=HEIGHT, alpha=True) +try: + img.colorspace_settings.name = "Non-Color" +except Exception: + pass +img.pixels.foreach_set(np.asarray(rgba, dtype=np.float32).ravel()) +img.filepath_raw = OUT +img.file_format = "PNG" +img.save() +print("[lut] wrote %s (%dx%d)" % (OUT, WIDTH, HEIGHT)) diff --git a/tools/blender/build_props.py b/tools/blender/build_props.py new file mode 100644 index 0000000..3bdaf90 --- /dev/null +++ b/tools/blender/build_props.py @@ -0,0 +1,329 @@ +# tools/blender/build_props.py +# FBC: NIGHT SHIFT — props / Objects of Power kit (S11). +# +# Run inside Blender 5.x: +# exec(open("/home/dandovlatov/Documents/cntrl/tools/blender/build_props.py").read()) +# +# Sculpted, ~1k-triangle set pieces for the Oldest House arena: the Hotline, +# Benicoff TV, Service Weapon pedestal, Rubber Duck, filing cabinet, supply +# crate and a Hiss-corrupted floating slab. Each exports as one GLB with one +# merged mesh / material, using the same painted-vertex path as the actors. + +import math +import os +import sys + +import bpy +from mathutils import Euler, Vector + +REPO = "/home/dandovlatov/Documents/cntrl" +MODEL_DIR = os.path.join(REPO, "assets", "models", "props") +BLEND_DIR = os.path.join(REPO, "assets", "blender") +CONCEPT_DIR = os.path.join(REPO, "docs", "concept") +for d in (MODEL_DIR, BLEND_DIR, CONCEPT_DIR): + os.makedirs(d, exist_ok=True) + +sys.path.insert(0, os.path.join(REPO, "tools", "blender")) +import importlib +import actor_kit as K +importlib.reload(K) + +K.clear_scene() +P = K.PALETTE +P.update({"plastic": "#2a2d33", "screen": "#10151c", "duck": "#f2c230", + "brass": "#b89348", "glass": "#9fc4cf"}) + + +def place(obj, rot=(0.0, 0.0, 0.0), offset=(0.0, 0.0, 0.0)): + """Rotate/translate a finished painted part about the prop origin.""" + mat = Euler(rot).to_matrix() + shift = Vector(offset) + for v in obj.data.vertices: + v.co = shift + mat @ v.co + obj.data.update() + return obj + + +# ------------------------------------------------------------------- hotline +def build_hotline(): + r = K.new_actor("Hotline") + K.loft(r, "table_top", [ + {"z": 0.84, "r": (0.78, 0.55), "n": 14}, + {"z": 0.89, "r": (0.79, 0.56), "n": 14, "fold": (0.015, 6)}, + {"z": 0.94, "r": (0.80, 0.57), "n": 14}, + ], P["plastic"]) + for sx in (-1, 1): + for sy in (-1, 1): + K.tube(r, "leg_%d_%d" % (sx, sy), + [(sx * 0.55, sy * 0.36, 0.02), + (sx * 0.58, sy * 0.38, 0.84)], [0.055, 0.045], + P["steel_dk"], sides=6) + K.plate(r, "drawer", K.octagon(0.40, 0.18), 0.70, 0.83, 0.94, + P["redaction"], shift=(0, -0.42)) + K.tube(r, "drawer_pull", [(-0.14, -0.52, 0.76), (0.14, -0.52, 0.76)], + [0.02, 0.02], P["brass"], sides=6) + K.blob(r, "phone_base", (0, 0, 1.04), (0.30, 0.22, 0.09), + P["hiss"], subdiv=3, seed=1, ao=0.05) + K.tube(r, "handset", + [(-0.30, -0.02, 1.19), (-0.16, -0.14, 1.22), + (0.16, -0.14, 1.22), (0.30, -0.02, 1.19)], + [0.055, 0.05, 0.05, 0.055], P["hiss"], sides=10) + K.ring(r, "dial", (0, -0.10, 1.135), 0.11, 0.018, P["redaction"], + segments=10) + for i in range(10): + a = 2.0 * math.pi * i / 10 + K.crystal(r, "dial_hole_%d" % i, + (math.cos(a) * 0.10, -0.10 + math.sin(a) * 0.10, 1.14), + 0.022, P["redaction"], sides=4, seed=10 + i) + K.crystal(r, "indicator", (0.20, -0.16, 1.13), 0.045, + P["hiss_hot"], sides=5, seed=3) + K.tube(r, "cord", + [(0.30, -0.02, 1.19), (0.40, -0.22, 1.06), + (0.24, -0.40, 0.98), (0.05, -0.32, 1.04)], + [0.014, 0.012, 0.012, 0.012], P["redaction"], sides=5) + return r + + +# ------------------------------------------------------------------------ tv +def build_tv(): + r = K.new_actor("BenicoffTV") + K.loft(r, "stand", [ + {"z": 0.02, "r": (0.72, 0.50), "n": 10}, + {"z": 0.52, "r": (0.68, 0.47), "n": 10}, + {"z": 0.58, "r": (0.74, 0.52), "n": 10}, + ], P["plastic"], ao=0.10) + K.loft(r, "body", [ + {"z": 0.58, "r": (0.62, 0.40), "n": 14}, + {"z": 0.85, "r": (0.65, 0.42), "n": 14}, + {"z": 1.05, "r": (0.66, 0.43), "n": 14}, + {"z": 1.36, "r": (0.66, 0.43), "n": 14}, + {"z": 1.70, "r": (0.66, 0.43), "n": 14}, + {"z": 1.84, "r": (0.58, 0.38), "n": 14}, + ], P["plastic"], ao=0.06) + screen = K.plate(r, "screen", K.octagon(0.50, 0.36), 0.0, 0.015, 1.0, + P["screen"], ao=0.0) + place(screen, rot=(math.pi / 2, 0, 0), offset=(0, -0.445, 1.34)) + bezel = K.ring(r, "bezel", (0, 0, 0), 0.50, 0.025, + P["steel_dk"], segments=16) + place(bezel, rot=(math.pi / 2, 0, 0), offset=(0, -0.45, 1.34)) + K.tube(r, "antenna_l", + [(0.20, 0.10, 1.84), (0.42, 0.12, 2.30)], + [0.016, 0.009], P["steel"], sides=5) + K.tube(r, "antenna_r", + [(-0.20, 0.10, 1.84), (-0.44, 0.14, 2.24)], + [0.016, 0.009], P["steel"], sides=5) + for i, sx in enumerate((-1, 1)): + K.crystal(r, "knob_%d" % i, (sx * 0.46, -0.44, 0.78), 0.055, + P["steel"], sides=6, seed=20 + i, + tilt=(math.pi / 2, 0, 0)) + K.plate(r, "vent", K.octagon(0.30, 0.10), 0.0, 0.012, 1.0, + P["redaction"], shift=(0, 0, 1.845)) + return r + + +# ------------------------------------------------------------------ pedestal +def build_pedestal(): + r = K.new_actor("Pedestal") + K.loft(r, "plinth", [ + {"z": 0.0, "r": (0.62, 0.62), "n": 14}, + {"z": 0.10, "r": (0.66, 0.66), "n": 14}, + {"z": 0.48, "r": (0.58, 0.58), "n": 14, "fold": (0.015, 5)}, + {"z": 0.92, "r": (0.54, 0.54), "n": 14, "fold": (0.02, 5)}, + {"z": 1.02, "r": (0.60, 0.60), "n": 14}, + ], P["concrete"], ao=0.14) + K.plate(r, "top", K.octagon(0.52, 0.52), 1.02, 1.08, 1.0, P["redaction"]) + K.tube(r, "weapon_body", + [(0.0, -0.10, 1.26), (0.0, -0.36, 1.30), (0.0, -0.62, 1.34)], + [0.09, 0.075, 0.06], P["plastic"], sides=8) + grip = K.plate(r, "grip", K.octagon(0.07, 0.11), 0.0, 0.20, 0.88, + P["steel_dk"]) + place(grip, rot=(math.pi / 2, 0, 0), offset=(0, -0.06, 1.06)) + K.crystal(r, "muzzle", (0, -0.64, 1.34), 0.10, P["steel"], sides=6, + seed=5, tilt=(math.pi / 2, 0, 0)) + K.crystal(r, "inlay", (0, -0.34, 1.40), 0.07, P["paper"], sides=5, + seed=6) + K.ring(r, "base_glow", (0, 0, 0.12), 0.60, 0.022, P["paper"], + segments=16) + return r + + +# ---------------------------------------------------------------------- duck +def build_duck(): + r = K.new_actor("Duck") + K.loft(r, "plinth", [ + {"z": 0.0, "r": (0.42, 0.42), "n": 10}, + {"z": 0.08, "r": (0.46, 0.46), "n": 10}, + {"z": 0.76, "r": (0.40, 0.40), "n": 10}, + {"z": 0.82, "r": (0.44, 0.44), "n": 10}, + ], P["concrete"], ao=0.14) + K.blob(r, "body", (0, 0, 1.00), (0.26, 0.22, 0.19), P["duck"], + subdiv=3, seed=2, ao=0.04) + K.blob(r, "head", (0, -0.14, 1.22), (0.15, 0.15, 0.15), P["duck"], + subdiv=3, seed=3, ao=0.04) + K.crystal(r, "beak", (0, -0.29, 1.19), 0.12, P["hiss"], sides=6, + seed=4, tilt=(math.pi / 2, 0, 0)) + for side in (-1, 1): + K.blob(r, "eye_%d" % side, (side * 0.075, -0.25, 1.26), + (0.018, 0.018, 0.018), P["redaction"], subdiv=1, + seed=10 + side) + K.tube(r, "tail", [(0, 0.20, 1.04), (0, 0.32, 1.14)], + [0.08, 0.025], P["duck"], sides=6) + # Glass case as a slim brass frame (alpha isn't part of the vertex palette). + for sx in (-1, 1): + for sy in (-1, 1): + K.tube(r, "frame_%d_%d" % (sx, sy), + [(sx * 0.33, sy * 0.33, 0.84), + (sx * 0.33, sy * 0.33, 1.48)], [0.014, 0.014], + P["brass"], sides=5) + K.tube(r, "frame_top", + [(-0.33, -0.33, 1.48), (0.33, -0.33, 1.48), + (0.33, 0.33, 1.48), (-0.33, 0.33, 1.48), (-0.33, -0.33, 1.48)], + [0.014] * 5, P["brass"], sides=5) + return r + + +# ------------------------------------------------------------------- cabinet +def build_cabinet(): + r = K.new_actor("Cabinet") + K.loft(r, "body", [ + {"z": 0.0, "r": (0.48, 0.36), "n": 14}, + {"z": 0.84, "r": (0.48, 0.36), "n": 14}, + {"z": 1.68, "r": (0.48, 0.36), "n": 14}, + {"z": 1.76, "r": (0.52, 0.40), "n": 14}, + ], P["redaction"], ao=0.10) + for i in range(4): + z = 0.28 + i * 0.40 + K.plate(r, "drawer_%d" % i, K.octagon(0.40, 0.30), 0.0, 0.018, + 1.0, P["plastic"], shift=(0, 0, z)) + K.tube(r, "handle_%d" % i, + [(-0.18, -0.375, z + 0.10), (0.18, -0.375, z + 0.10)], + [0.022, 0.022], P["steel"], sides=6) + K.plate(r, "label_%d" % i, K.octagon(0.11, 0.025), 0.0, 0.006, + 1.0, P["paper"], shift=(0, 0, z + 0.02)) + for side in (-1, 1): + K.tube(r, "edge_%d" % side, + [(side * 0.46, -0.34, 0.04), (side * 0.46, -0.34, 1.72)], + [0.018, 0.018], P["steel_dk"], sides=5) + return r + + +# --------------------------------------------------------------------- crate +def build_crate(): + r = K.new_actor("Crate") + K.loft(r, "body", [ + {"z": 0.0, "r": (0.52, 0.42), "n": 14, "fold": (0.02, 5)}, + {"z": 0.36, "r": (0.53, 0.43), "n": 14, "fold": (0.025, 5)}, + {"z": 0.72, "r": (0.54, 0.44), "n": 14, "fold": (0.025, 5)}, + {"z": 0.78, "r": (0.56, 0.46), "n": 14}, + ], P["tan"], ao=0.14) + K.plate(r, "lid", K.octagon(0.56, 0.46), 0.78, 0.86, 0.98, + P["navy_dk"]) + for sx in (-1, 1): + for sy in (-1, 1): + K.tube(r, "brace_%d_%d" % (sx, sy), + [(sx * 0.46, sy * 0.36, 0.02), + (sx * 0.46, sy * 0.36, 0.76)], [0.03, 0.03], + P["steel_dk"], sides=5) + K.plate(r, "stencil", K.octagon(0.20, 0.10), 0.0, 0.008, 1.0, + P["redaction"], shift=(0, -0.46, 0.42)) + K.ring(r, "seal", (0, 0, 0.87), 0.24, 0.018, P["hiss_dull"], + segments=10) + return r + + +# -------------------------------------------------------------------- debris +def build_debris(): + r = K.new_actor("Debris") + K.blob(r, "slab", (0, 0, 0.42), (0.92, 0.70, 0.30), P["concrete"], + subdiv=3, warp=0.34, seed=7, smooth=False, ao=0.12) + K.plate(r, "rebar_plate", K.octagon(0.34, 0.22), 0.68, 0.72, 0.9, + P["steel_dk"], shift=(0.14, 0.0)) + for i, (x, y, z, tilt) in enumerate([ + (-0.40, -0.14, 0.66, (0.3, -0.2, 0.4)), + (0.30, 0.22, 0.70, (-0.4, 0.3, -0.2)), + (0.46, -0.26, 0.60, (0.2, 0.4, 0.3)), + (-0.12, 0.34, 0.62, (-0.3, -0.3, 0.1)), + (0.08, -0.36, 0.64, (0.1, 0.2, -0.4)), + ]): + K.crystal(r, "growth_%d" % i, (x, y, z), 0.30, P["hiss"], + sides=5, seed=30 + i, tilt=tilt) + for i in range(3): + K.tube(r, "crack_%d" % i, + [(-0.5 + i * 0.45, -0.4, 0.58), + (-0.3 + i * 0.45, -0.1, 0.68), + (-0.1 + i * 0.45, 0.2, 0.62)], + [0.018, 0.02, 0.014], P["hiss_hot"], sides=5) + return r + + +BUILDERS = [ + ("hotline", build_hotline, 1200), + ("tv", build_tv, 1200), + ("pedestal", build_pedestal, 1000), + ("duck", build_duck, 1000), + ("cabinet", build_cabinet, 1200), + ("crate", build_crate, 1000), + ("debris", build_debris, 1000), +] + +exported = [] +for name, builder, cap in BUILDERS: + root = builder() + K.merge_actor(root, name) + tris = K.triangle_count(root) + print("[budget] %-10s %5d tris (cap %d) %s" + % (name, tris, cap, "OK" if tris <= cap else "OVER")) + out = os.path.join(MODEL_DIR, name + ".glb") + K.export_actor(root, name, out) + exported.append((name, tris, os.path.getsize(out))) + +SLOTS = {"Hotline": -7.5, "BenicoffTV": -4.5, "Pedestal": -1.5, + "Duck": 1.5, "Cabinet": 4.5, "Crate": 7.5, "Debris": 10.5} +for obj in bpy.data.objects: + if obj.name in SLOTS: + obj.location.x = SLOTS[obj.name] + +world = bpy.data.worlds.new("PropWorld") +bpy.context.scene.world = world +world.use_nodes = True +bg = next(n for n in world.node_tree.nodes if n.type == "BACKGROUND") +bg.inputs["Color"].default_value = (*K.rgb("#0d0f12"), 1.0) +bg.inputs["Strength"].default_value = 0.9 + +import mathutils +for name, loc, power, col in ( + ("Key", (-2, -8, 9), 2200, "#eef2ff"), + ("HissFill", (8, -1, 5), 1100, "#ff3b46"), + ("Rim", (0, 7, 6), 900, "#4ec9b0"), +): + data = bpy.data.lights.new(name, "AREA") + data.energy = power + data.shape = "DISK" + data.size = 8 + data.color = K.rgb(col) + obj = bpy.data.objects.new(name, data) + bpy.context.scene.collection.objects.link(obj) + obj.location = loc + obj.rotation_euler = (mathutils.Vector((0, 0, 1)) - + mathutils.Vector(loc)).to_track_quat("-Z", "Y").to_euler() + +cam_data = bpy.data.cameras.new("PropCam") +cam = bpy.data.objects.new("PropCam", cam_data) +bpy.context.scene.collection.objects.link(cam) +cam.location = (1.0, -20.0, 9.0) +cam.rotation_euler = (mathutils.Vector((0, 0, 0.95)) - + cam.location).to_track_quat("-Z", "Y").to_euler() +cam_data.lens = 42 +scene = bpy.context.scene +scene.camera = cam +engines = [i.identifier for i in bpy.types.RenderSettings.bl_rna.properties["engine"].enum_items] +scene.render.engine = "BLENDER_EEVEE_NEXT" if "BLENDER_EEVEE_NEXT" in engines else engines[0] +scene.render.resolution_x = 1200 +scene.render.resolution_y = 520 +scene.render.image_settings.file_format = "PNG" +scene.render.filepath = os.path.join(CONCEPT_DIR, "props_lineup.png") +bpy.ops.render.render(write_still=True) + +bpy.ops.wm.save_as_mainfile(filepath=os.path.join(BLEND_DIR, "fbc_props.blend")) +print("[done] props:", ", ".join("%s(%d tris)" % (n, t) + for n, t, _ in exported))