diff --git a/.gitignore b/.gitignore index 6654b8d..c5e7705 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ build/ compile_commands.json +__pycache__/ +*.blend1 diff --git a/README.md b/README.md index 764f779..7b9a795 100644 --- a/README.md +++ b/README.md @@ -47,6 +47,8 @@ raylib 6.2 is fetched automatically by CMake (FetchContent). Needs a C++23 compi - `docs/ART_DIRECTION.md` — the 3D-env + 2D-sprite diorama look, UI, audio - `docs/TECHNICAL.md` — stack, architecture, module map - `docs/ROADMAP.md` — milestones M0–M6 and current status +- `docs/concept/` — rendered Blender concept frames (visual target for M5) +- `tools/blender/` — procedural Blender scene builder + render scripts ## IP note diff --git a/assets/blender/fbc_night_shift_diorama.blend b/assets/blender/fbc_night_shift_diorama.blend new file mode 100644 index 0000000..583d3fd Binary files /dev/null and b/assets/blender/fbc_night_shift_diorama.blend differ diff --git a/assets/sprites/glow.png b/assets/sprites/glow.png new file mode 100644 index 0000000..80febd3 Binary files /dev/null and b/assets/sprites/glow.png differ diff --git a/assets/sprites/guard.png b/assets/sprites/guard.png new file mode 100644 index 0000000..029dd10 Binary files /dev/null and b/assets/sprites/guard.png differ diff --git a/assets/sprites/hiss_brute.png b/assets/sprites/hiss_brute.png new file mode 100644 index 0000000..c947e42 Binary files /dev/null and b/assets/sprites/hiss_brute.png differ diff --git a/assets/sprites/hiss_staff.png b/assets/sprites/hiss_staff.png new file mode 100644 index 0000000..fcef5ce Binary files /dev/null and b/assets/sprites/hiss_staff.png differ diff --git a/assets/sprites/mold_spore.png b/assets/sprites/mold_spore.png new file mode 100644 index 0000000..cf97b91 Binary files /dev/null and b/assets/sprites/mold_spore.png differ diff --git a/assets/sprites/shard.png b/assets/sprites/shard.png new file mode 100644 index 0000000..bb714d0 Binary files /dev/null and b/assets/sprites/shard.png differ diff --git a/docs/ART_DIRECTION.md b/docs/ART_DIRECTION.md index 21f4e90..f967b5d 100644 --- a/docs/ART_DIRECTION.md +++ b/docs/ART_DIRECTION.md @@ -75,3 +75,28 @@ 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 standees minimum, GLTF later + +## Concept scene (Blender) — visual target for M5 + +A full visual pass of the look now lives in Blender (built procedurally, no +external assets): + +- `assets/blender/fbc_night_shift_diorama.blend` — the diorama: polished + concrete floor, red carpet runners with brass stanchions, brutalist pillars / + pilasters / beams with recessed fluorescent strips, redacted FBC signage, + threshold door with red Hiss glow + hazard stripes, floating Hiss-corrupted + slabs, the Board's yellow monolith, volumetric haze. +- `assets/sprites/{guard,hiss_staff,hiss_brute,mold_spore,shard,glow}.png` — + 256px photo-standee art (two-tone ID-badge silhouettes) used as billboards in + the scene and directly loadable by raylib at M5. +- `docs/concept/*.png` — rendered frames: `hero_oldest_house` (long-lens + diorama), `hero_game_camera` (exact in-game fovy 45° view), and + `detail_guard_standees`. +- `tools/blender/build_scene.py` rebuilds the scene from scratch (run inside + Blender: `exec(open("/home/dandovlatov/Documents/cntrl/tools/blender/build_scene.py").read())`); + `tools/blender/render_shots.py` re-renders the concept frames. + +The scene mirrors the sim's world: 52m arena, pillar ring at ±15/±18.5, camera +pitch/lens matched to `render/presenter.cpp`. Palette exactly as above; the +flickering red strips and floating slabs are the corruption channel, the yellow +monolith is the Board. diff --git a/docs/concept/detail_guard_standees.png b/docs/concept/detail_guard_standees.png new file mode 100644 index 0000000..214c29d Binary files /dev/null and b/docs/concept/detail_guard_standees.png differ diff --git a/docs/concept/hero_game_camera.png b/docs/concept/hero_game_camera.png new file mode 100644 index 0000000..a37300e Binary files /dev/null and b/docs/concept/hero_game_camera.png differ diff --git a/docs/concept/hero_oldest_house.png b/docs/concept/hero_oldest_house.png new file mode 100644 index 0000000..a062321 Binary files /dev/null and b/docs/concept/hero_oldest_house.png differ diff --git a/tools/blender/build_scene.py b/tools/blender/build_scene.py new file mode 100644 index 0000000..03ead96 --- /dev/null +++ b/tools/blender/build_scene.py @@ -0,0 +1,834 @@ +# tools/blender/build_scene.py +# FBC: NIGHT SHIFT — brutalist diorama scene builder (docs/ART_DIRECTION.md). +# +# Run inside Blender (Blender 4.2+ / 5.x): +# exec(open("/home/dandovlatov/Documents/cntrl/tools/blender/build_scene.py").read()) +# +# Builds: polished-concrete Oldest House sector with red carpets, brutalist kit, +# fluorescent strips, redacted signage, threshold door, floating Hiss geometry, +# Board monolith, volumetric haze, and 2D photo-standee sprites (guard + enemies) +# drawn procedurally and saved to assets/sprites/. Does NOT render; see +# render_shots.py for the camera captures. +import math +import os + +import bpy +import numpy as np +from mathutils import Vector + +REPO = "/home/dandovlatov/Documents/cntrl" +SPRITE_DIR = os.path.join(REPO, "assets", "sprites") +BLEND_DIR = os.path.join(REPO, "assets", "blender") +os.makedirs(SPRITE_DIR, exist_ok=True) +os.makedirs(BLEND_DIR, exist_ok=True) + +print("[build] numpy", np.__version__, "| blender", bpy.app.version_string) + + +# --------------------------------------------------------------- scene reset +def wipe_scene(): + for obj in list(bpy.data.objects): + bpy.data.objects.remove(obj, do_unlink=True) + for coll in list(bpy.data.collections): + bpy.data.collections.remove(coll) + for mat in list(bpy.data.materials): + bpy.data.materials.remove(mat) + for mesh in list(bpy.data.meshes): + bpy.data.meshes.remove(mesh) + for curve in list(bpy.data.curves): + bpy.data.curves.remove(curve) + for cam in list(bpy.data.cameras): + bpy.data.cameras.remove(cam) + for light in list(bpy.data.lights): + bpy.data.lights.remove(light) + for img in list(bpy.data.images): + if img.users == 0 or img.name.startswith("sprite_"): + bpy.data.images.remove(img) + for world in list(bpy.data.worlds): + bpy.data.worlds.remove(world) + + +# ----------------------------------------------------------------- utilities +def link(obj, coll_name="Scene"): + coll = bpy.data.collections.get(coll_name) + if coll is None: + coll = bpy.data.collections.new(coll_name) + bpy.context.scene.collection.children.link(coll) + coll.objects.link(obj) + return obj + + +def new_mat(name): + mat = bpy.data.materials.new(name) + mat.use_nodes = True + return mat + + +def bsdf_of(mat): + return mat.node_tree.nodes.get("Principled BSDF") + + +def set_in(node, name, value): + sock = node.inputs.get(name) + if sock is not None: + sock.default_value = value + return True + return False + + +def principled(name, color, rough=0.5, metal=0.0, emit=None, emit_str=0.0, alpha=1.0): + mat = new_mat(name) + b = bsdf_of(mat) + set_in(b, "Base Color", (*color, 1.0)) + set_in(b, "Roughness", rough) + set_in(b, "Metallic", metal) + set_in(b, "Alpha", alpha) + if emit is not None: + set_in(b, "Emission Color", (*emit, 1.0)) + set_in(b, "Emission Strength", emit_str) + if alpha < 1.0: + try: + mat.surface_render_method = "BLENDED" + except Exception: + try: + mat.blend_method = "BLEND" + except Exception: + pass + try: + mat.show_transparent_back = False + except Exception: + pass + return mat + + +def add_noise_bump(mat, scale=6.0, strength=0.15, detail=6.0): + nt = mat.node_tree + b = bsdf_of(mat) + noise = nt.nodes.new("ShaderNodeTexNoise") + noise.location = (-520, -220) + set_in(noise, "Scale", scale) + set_in(noise, "Detail", detail) + bump = nt.nodes.new("ShaderNodeBump") + bump.location = (-260, -220) + set_in(bump, "Strength", strength) + nt.links.new(noise.outputs["Fac"], bump.inputs["Height"]) + if b.inputs.get("Normal") is not None: + nt.links.new(bump.outputs["Normal"], b.inputs["Normal"]) + +# ------------------------------------------------------------- mesh factories +def _finish_mesh(name, verts, faces, uvs=None, coll="Scene"): + mesh = bpy.data.meshes.new(name) + mesh.from_pydata(verts, [], faces) + mesh.validate() + if uvs is not None: + uv_layer = mesh.uv_layers.new(name="UVMap") + for poly in mesh.polygons: + for loop_index in poly.loop_indices: + vi = mesh.loops[loop_index].vertex_index + uv_layer.data[loop_index].uv = uvs[vi] + mesh.update() + obj = bpy.data.objects.new(name, mesh) + return link(obj, coll) + + +def make_box(name, cx, cy, cz, sx, sy, sz, mat, coll="ENV"): + hx, hy, hz = sx / 2.0, sy / 2.0, sz / 2.0 + verts = [(cx + dx * hx, cy + dy * hy, cz + dz * hz) + for dz in (-1, 1) for dy in (-1, 1) for dx in (-1, 1)] + faces = [(0, 2, 3, 1), (4, 5, 7, 6), (0, 1, 5, 4), + (2, 6, 7, 3), (0, 4, 6, 2), (1, 3, 7, 5)] + obj = _finish_mesh(name, verts, faces, coll=coll) + obj.data.materials.append(mat) + return obj + + +def make_box_obj(name, size, loc, rot, mat, coll="ENV"): + """Unit box at origin; transform via object (for rotated Hiss slabs etc.).""" + hx, hy, hz = size[0] / 2.0, size[1] / 2.0, size[2] / 2.0 + verts = [(dx * hx, dy * hy, dz * hz) + for dz in (-1, 1) for dy in (-1, 1) for dx in (-1, 1)] + faces = [(0, 2, 3, 1), (4, 5, 7, 6), (0, 1, 5, 4), + (2, 6, 7, 3), (0, 4, 6, 2), (1, 3, 7, 5)] + obj = _finish_mesh(name, verts, faces, coll=coll) + obj.location = loc + obj.rotation_euler = rot + obj.data.materials.append(mat) + return obj + + +def make_quad(name, cx, cy, cz, w, h, yaw, mat, coll="STANDEES"): + """Vertical camera-facing quad: width along its right vector, height on Z.""" + hw, hh = w / 2.0, h / 2.0 + rx, ry = math.cos(yaw), math.sin(yaw) + verts = [(cx - rx * hw, cy - ry * hw, cz - hh), + (cx + rx * hw, cy + ry * hw, cz - hh), + (cx + rx * hw, cy + ry * hw, cz + hh), + (cx - rx * hw, cy - ry * hw, cz + hh)] + uvs = [(0.0, 0.0), (1.0, 0.0), (1.0, 1.0), (0.0, 1.0)] + obj = _finish_mesh(name, verts, [(0, 1, 2, 3)], uvs=uvs, coll=coll) + obj.data.materials.append(mat) + return obj + + +def make_cyl(name, cx, cy, z0, z1, r, mat, segs=16, coll="ENV"): + verts = [] + for z in (z0, z1): + for i in range(segs): + a = 2.0 * math.pi * i / segs + verts.append((cx + r * math.cos(a), cy + r * math.sin(a), z)) + faces = [] + for i in range(segs): + j = (i + 1) % segs + faces.append((i, j, segs + j, segs + i)) + faces.append(tuple(range(segs - 1, -1, -1))) # bottom (-Z) + faces.append(tuple(range(segs, 2 * segs))) # top (+Z) + obj = _finish_mesh(name, verts, faces, coll=coll) + obj.data.materials.append(mat) + return obj + + +def make_text(name, body, loc, rot, size, mat, extrude=0.012, align="CENTER", + coll="ENV"): + curve = bpy.data.curves.new(name, type="FONT") + curve.body = body + curve.size = size + curve.extrude = extrude + curve.align_x = align + obj = bpy.data.objects.new(name, curve) + link(obj, coll) + obj.location = loc + obj.rotation_euler = rot + obj.data.materials.append(mat) + return obj + + +def add_light(name, ltype, loc, rot, energy, color, size=None, radius=None, + coll="LIGHTS"): + data = bpy.data.lights.new(name, type=ltype) + data.energy = energy + data.color = color + if ltype == "AREA" and size is not None: + data.size = size + if radius is not None: + try: + data.shadow_soft_size = radius + except Exception: + pass + obj = bpy.data.objects.new(name, data) + link(obj, coll) + obj.location = loc + obj.rotation_euler = rot + return obj + + +def add_camera(name, loc, target, lens=45.0, coll="CAMERAS"): + cam = bpy.data.cameras.new(name) + cam.lens = lens + try: + cam.sensor_fit = "VERTICAL" + cam.sensor_height = 24.0 + except Exception: + pass + obj = bpy.data.objects.new(name, cam) + link(obj, coll) + obj.location = loc + direction = Vector(target) - Vector(loc) + obj.rotation_euler = direction.to_track_quat("-Z", "Y").to_euler() + return obj + +# ---------------------------------------------------- procedural 2D sprites +# Photo-standee art: high-contrast two-tone FBC ID-badge silhouettes +# (docs/ART_DIRECTION.md). Drawn at 512px, box-downsampled to 256 for AA. +class Canvas: + def __init__(self, w=512, h=512): + self.w, self.h = w, h + ys, xs = np.mgrid[0:h, 0:w] + self.xs = xs.astype(np.float32) + self.ys = ys.astype(np.float32) + self.col = np.zeros((h, w, 3), np.float32) + self.a = np.zeros((h, w), np.float32) + + def paint(self, mask, color, alpha=1.0): + c = np.asarray(color, np.float32) + a = np.full(mask.shape, alpha, np.float32) * mask + self.col = self.col * (1.0 - a[..., None]) + c * a[..., None] + self.a = self.a * (1.0 - a) + a + + def rect(self, x0, y0, x1, y1, color, alpha=1.0): + m = (self.xs >= x0) & (self.xs <= x1) & (self.ys >= y0) & (self.ys <= y1) + self.paint(m, color, alpha) + + def ellipse(self, cx, cy, rx, ry, color, alpha=1.0): + m = ((self.xs - cx) / rx) ** 2 + ((self.ys - cy) / ry) ** 2 <= 1.0 + self.paint(m, color, alpha) + + def capsule(self, x0, y0, x1, y1, r, color, alpha=1.0): + px, py = self.xs - x0, self.ys - y0 + dx, dy = x1 - x0, y1 - y0 + l2 = max(dx * dx + dy * dy, 1e-6) + t = np.clip((px * dx + py * dy) / l2, 0.0, 1.0) + d2 = (px - t * dx) ** 2 + (py - t * dy) ** 2 + self.paint(d2 <= r * r, color, alpha) + + def diamond(self, cx, cy, rx, ry, color, alpha=1.0): + m = (np.abs(self.xs - cx) / rx + np.abs(self.ys - cy) / ry) <= 1.0 + self.paint(m, color, alpha) + + def to_rgba(self, size=256): + big = np.dstack([self.col, self.a[..., None]]) + f = self.w // size + small = big.reshape(size, f, size, f, 4).mean(axis=(1, 3)) + return np.clip(small, 0.0, 1.0).astype(np.float32) + + +def new_image(name, canvas, size=256): + rgba = canvas.to_rgba(size) + img = bpy.data.images.new("sprite_" + name, size, size, alpha=True) + img.pixels.foreach_set(rgba.ravel()) + img.filepath_raw = os.path.join(SPRITE_DIR, name + ".png") + img.file_format = "PNG" + img.save() + return img + + +PAPER = (0.91, 0.895, 0.845) +INK = (0.065, 0.065, 0.07) +RED = (0.757, 0.07, 0.12) +RED_DK = (0.42, 0.035, 0.06) +RED_HOT = (0.85, 0.16, 0.18) +BLUE = (0.16, 0.21, 0.28) +BLUE_DK = (0.09, 0.115, 0.15) +GREEN = (0.42, 0.68, 0.32) +GREEN_DK = (0.17, 0.32, 0.14) +YELLOW = (0.96, 0.77, 0.09) +GOLD = (0.85, 0.66, 0.25) + + +def badge_card(c, tint=(0.0, 0.0, 0.0), tint_a=0.0): + """Paper ID-badge card + redaction furniture.""" + paper = tuple(PAPER[i] * (1 - tint_a) + tint[i] * tint_a for i in range(3)) + c.rect(56, 24, 456, 488, INK) # border + c.rect(68, 36, 444, 476, paper) # card face + c.rect(68, 36, 444, 78, RED) # bottom stripe + c.rect(68, 84, 444, 92, INK, 0.85) + for i in range(6): # barcode + c.rect(340 + i * 14, 420, 346 + i * 14, 462, INK, 0.9) + c.rect(92, 420, 300, 438, INK, 0.8) # redaction bar + c.rect(92, 396, 232, 410, INK, 0.65) + +def draw_guard(): + c = Canvas() + badge_card(c) + c.rect(212, 196, 300, 322, BLUE) # torso (uniform) + c.capsule(218, 312, 294, 312, 20, BLUE) # shoulders + c.capsule(216, 300, 196, 214, 15, BLUE_DK) # arms + c.capsule(296, 300, 316, 214, 15, BLUE_DK) + c.capsule(232, 200, 224, 112, 19, INK) # legs + c.capsule(280, 200, 288, 112, 19, INK) + c.rect(202, 92, 248, 118, INK) # boots + c.rect(264, 92, 310, 118, INK) + c.ellipse(256, 352, 25, 29, INK) # head + c.rect(228, 370, 284, 392, BLUE_DK) # cap + c.capsule(216, 372, 296, 372, 8, BLUE_DK) # brim + c.rect(290, 262, 312, 292, GOLD) # badge + c.rect(292, 264, 310, 272, INK, 0.6) + c.capsule(302, 286, 314, 262, 6, RED) # armband + c.rect(228, 214, 284, 226, INK, 0.8) # belt + return new_image("guard", c) + + +def draw_hiss_staff(): + c = Canvas() + badge_card(c, RED_HOT, 0.12) + c.rect(216, 182, 296, 330, RED) # coat + c.rect(200, 182, 312, 246, RED) # coat flare + c.capsule(222, 318, 166, 392, 13, RED_DK) # arms raised (chanting) + c.capsule(290, 318, 346, 392, 13, RED_DK) + c.ellipse(164, 398, 14, 14, RED_DK) # hands + c.ellipse(348, 398, 14, 14, RED_DK) + c.capsule(234, 190, 228, 112, 17, INK) # legs + c.capsule(278, 190, 286, 112, 17, INK) + c.ellipse(256, 356, 23, 27, RED_DK) # head + c.rect(246, 340, 266, 350, INK) # chanting mouth + for dx in (-16, 0, 16): # resonance crown + c.capsule(256 + dx, 380, 256 + dx * 1.8, 414, 5, RED_HOT, 0.9) + c.capsule(214, 288, 298, 288, 7, RED_HOT, 0.8) # chest band + return new_image("hiss_staff", c) + +def draw_hiss_brute(): + c = Canvas() + badge_card(c, RED_DK, 0.18) + c.ellipse(256, 296, 92, 52, RED_DK) # massive shoulders + c.rect(190, 168, 322, 300, RED_DK) # torso + c.rect(222, 196, 290, 262, INK, 0.85) # chest core + c.capsule(188, 286, 148, 142, 27, INK) # arms to floor + c.capsule(324, 286, 364, 142, 27, INK) + c.capsule(224, 176, 216, 108, 26, RED_DK) # legs + c.capsule(288, 176, 296, 108, 26, RED_DK) + c.ellipse(256, 356, 21, 23, INK) # small head + c.rect(240, 360, 272, 372, RED_HOT, 0.7) # visor glow + c.capsule(166, 300, 346, 300, 8, RED_HOT, 0.6) # rim band + return new_image("hiss_brute", c) + + +def draw_mold_spore(): + c = Canvas() + badge_card(c, GREEN_DK, 0.12) + c.capsule(256, 190, 256, 118, 17, GREEN_DK) # stem + c.ellipse(256, 258, 108, 86, GREEN) # lumpy body + c.ellipse(196, 312, 58, 48, GREEN) + c.ellipse(316, 306, 54, 46, GREEN) + c.ellipse(232, 232, 34, 28, GREEN_DK, 0.8) # blotches + c.ellipse(292, 258, 30, 24, GREEN_DK, 0.8) + c.ellipse(256, 300, 24, 20, GREEN_DK, 0.7) + for cx, cy, r in ((214, 386, 13), (288, 398, 10), (256, 418, 11)): + c.ellipse(cx, cy, r, r, GREEN) # floating spores + c.ellipse(256, 268, 22, 18, (0.75, 0.86, 0.55), 0.9) # highlight + return new_image("mold_spore", c) + + +def draw_shard(): + c = Canvas() + c.diamond(256, 256, 150, 200, YELLOW, 0.22) # glow + c.diamond(256, 256, 112, 152, YELLOW) # body + c.diamond(256, 256, 56, 78, (1.0, 0.97, 0.8)) # core + c.capsule(256, 430, 256, 470, 6, GOLD, 0.8) # sparkle tick + return new_image("shard", c) + + +def draw_glow(): + c = Canvas() + d = np.sqrt((c.xs - 256) ** 2 + (c.ys - 256) ** 2) / 256.0 + c.col[:] = np.asarray((1.0, 0.95, 0.78), np.float32) + c.a = np.clip(1.0 - d, 0.0, 1.0) ** 2.2 + return new_image("glow", c) + + +def sprite_mat(name, img, emit=0.55): + mat = new_mat("sprite_mat_" + name) + nt = mat.node_tree + b = bsdf_of(mat) + tex = nt.nodes.new("ShaderNodeTexImage") + tex.image = img + tex.location = (-520, 120) + nt.links.new(tex.outputs["Color"], b.inputs["Base Color"]) + if b.inputs.get("Emission Color") is not None: + nt.links.new(tex.outputs["Color"], b.inputs["Emission Color"]) + set_in(b, "Emission Strength", emit) + if b.inputs.get("Alpha") is not None: + nt.links.new(tex.outputs["Alpha"], b.inputs["Alpha"]) + try: + mat.surface_render_method = "BLENDED" + except Exception: + try: + mat.blend_method = "BLEND" + except Exception: + pass + try: + mat.show_transparent_back = False + except Exception: + pass + return mat + +# ------------------------------------------------------------- scene build +def build_materials(): + m = {} + m["concrete"] = principled("concrete", (0.168, 0.168, 0.184), rough=0.42) + add_noise_bump(m["concrete"], scale=9.0, strength=0.18) + # Polished concrete floor: dark, glossy, subtle mottling. + floor = principled("concrete_polished", (0.145, 0.145, 0.16), rough=0.16) + nt = floor.node_tree + b = bsdf_of(floor) + noise = nt.nodes.new("ShaderNodeTexNoise") + noise.location = (-720, 160) + set_in(noise, "Scale", 2.2) + set_in(noise, "Detail", 8.0) + ramp = nt.nodes.new("ShaderNodeValToRGB") + ramp.location = (-520, 160) + ramp.color_ramp.elements[0].position = 0.32 + ramp.color_ramp.elements[0].color = (0.115, 0.115, 0.128, 1.0) + ramp.color_ramp.elements[1].position = 0.72 + ramp.color_ramp.elements[1].color = (0.185, 0.185, 0.2, 1.0) + nt.links.new(noise.outputs["Fac"], ramp.inputs["Fac"]) + nt.links.new(ramp.outputs["Color"], b.inputs["Base Color"]) + add_noise_bump(floor, scale=40.0, strength=0.05, detail=10.0) + m["floor"] = floor + # Red carpet: signal red, fabric-ish. + carpet = principled("carpet_red", (0.42, 0.012, 0.03), rough=0.72) + add_noise_bump(carpet, scale=90.0, strength=0.32, detail=12.0) + set_in(bsdf_of(carpet), "Sheen Weight", 0.2) + m["carpet"] = carpet + m["carpet_border"] = principled("carpet_border", (0.22, 0.006, 0.016), rough=0.68) + m["paper"] = principled("paper_sign", (0.83, 0.8, 0.72), rough=0.55) + m["ink"] = principled("redaction_ink", (0.02, 0.02, 0.022), rough=0.5) + m["door_dark"] = principled("door_dark", (0.055, 0.055, 0.062), rough=0.35, metal=0.55) + m["hissshine"] = principled("hiss_glow", (0.5, 0.02, 0.035), rough=0.4, + emit=(1.0, 0.045, 0.06), emit_str=4.5) + m["board"] = principled("board_yellow", (0.7, 0.55, 0.05), rough=0.35, + emit=(1.0, 0.72, 0.12), emit_str=3.2) + m["strip"] = principled("fluor_strip", (0.9, 0.88, 0.8), rough=0.3, + emit=(1.0, 0.93, 0.78), emit_str=16.0) + m["strip_red"] = principled("fluor_strip_red", (0.7, 0.1, 0.1), rough=0.3, + emit=(1.0, 0.12, 0.1), emit_str=12.0) + m["exit_green"] = principled("exit_green", (0.05, 0.4, 0.12), rough=0.3, + emit=(0.15, 1.0, 0.35), emit_str=8.0) + m["brass"] = principled("brass", (0.72, 0.55, 0.22), rough=0.28, metal=1.0) + m["rope"] = principled("rope_red", (0.42, 0.02, 0.05), rough=0.6) + m["paint_line"] = principled("paint_line", (0.62, 0.6, 0.55), rough=0.5) + m["hazard_y"] = principled("hazard_yellow", (0.78, 0.6, 0.05), rough=0.55) + m["blob"] = principled("blob_shadow", (0.0, 0.0, 0.0), rough=0.9, alpha=0.42) + m["base"] = principled("standee_base", (0.1, 0.1, 0.11), rough=0.45) + vol = new_mat("haze_volume") + nt = vol.node_tree + for node in list(nt.nodes): + nt.nodes.remove(node) + pv = nt.nodes.new("ShaderNodeVolumePrincipled") + out = nt.nodes.new("ShaderNodeOutputMaterial") + set_in(pv, "Density", 0.0035) + set_in(pv, "Anisotropy", 0.55) + set_in(pv, "Color", (0.55, 0.62, 0.85, 1.0)) + nt.links.new(pv.outputs["Volume"], out.inputs["Volume"]) + m["volume"] = vol + return m + + +def build_floor(m): + make_box("Floor_Slab", 0, 0, -0.5, 60, 60, 1.0, m["floor"]) + # Painted walkway lines (diorama stage feel). + for x in (-12, 12): + make_box("Line_Y_%d" % x, x, 0, 0.012, 0.18, 44, 0.024, m["paint_line"]) + for y in (-12, 12): + make_box("Line_X_%d" % y, 0, y, 0.012, 44, 0.18, 0.024, m["paint_line"]) + # Red carpet: main runner (door -> arena) + cross runner. + make_box("Carpet_Main", 0, 6, 0.03, 7.0, 30.0, 0.06, m["carpet"]) + make_box("Carpet_Cross", 0, 12, 0.034, 36.0, 6.0, 0.068, m["carpet"]) + for x in (-3.28, 3.28): + make_box("Carpet_Border_%d" % x, x, 6, 0.033, 0.38, 30.0, 0.066, + m["carpet_border"]) + for x in (-3.62, 3.62): + make_box("Carpet_Edge_%d" % x, x, 6, 0.032, 0.12, 30.0, 0.064, + m["ink"]) + for y in (9.28, 14.72): + make_box("Carpet_BorderX_%d" % y, 0, y, 0.036, 36.0, 0.38, 0.072, + m["carpet_border"]) + +def build_walls(m): + t = 0.6 + h = 8.5 + # Far wall (+Y) and side walls; near side stays a low curb (game convention: + # nothing tall on the camera side). + make_box("Wall_Far", 0, 22 + t / 2, h / 2, 45.2, t, h, m["concrete"]) + make_box("Wall_Left", -22 - t / 2, 0, h / 2, t, 45.2, h, m["concrete"]) + make_box("Wall_Right", 22 + t / 2, 0, h / 2, t, 45.2, h, m["concrete"]) + make_box("Curb_Near", 0, -22 - t / 2, 0.6, 45.2, t, 1.2, m["concrete"]) + # Side-wall pilaster rhythm. + for x in (-21.8, 21.8): + for y in (-18, -11, -4, 3, 10, 17): + make_box("Pilaster_%d_%d" % (x, y), x, y, h / 2, 0.5, 1.2, h, + m["concrete"]) + # --- threshold door (the run's exit) -------------------------------- + make_box("Door_Frame", 0, 21.9, 3.1, 5.6, 0.34, 6.4, m["door_dark"]) + make_box("Door_Panel", 0, 21.68, 2.85, 4.6, 0.18, 5.7, m["concrete"]) + make_box("Door_Glow", 0, 21.56, 2.85, 3.7, 0.06, 5.1, m["hissshine"]) + make_box("Door_Lintel", 0, 21.75, 6.25, 6.4, 0.5, 0.5, m["door_dark"]) + # Hazard stripes on the floor before the door. + for i in range(10): + x0 = -2.31 + i * 0.462 + make_box("Hazard_%d" % i, x0, 20.45, 0.045, 0.23, 1.1, 0.055, + m["hazard_y"] if i % 2 == 0 else m["ink"]) + # --- redacted signage ------------------------------------------------ + make_box("Sign_Main_Panel", 0, 21.86, 7.15, 7.6, 0.14, 1.9, m["paper"]) + make_text("Sign_FBC", "FBC", (0, 21.76, 7.35), (math.pi / 2, 0, 0), 1.05, + m["ink"]) + make_box("Sign_Bar_1", -1.9, 21.74, 6.72, 2.6, 0.06, 0.28, m["ink"]) + make_box("Sign_Bar_2", 1.15, 21.74, 6.72, 2.9, 0.06, 0.28, m["ink"]) + make_box("Sign_Bar_3", 2.85, 21.74, 6.72, 1.1, 0.06, 0.28, m["ink"]) + make_text("Sign_Sub", "NIGHT SHIFT // SECTOR 07", (0, 21.76, 7.02), + (math.pi / 2, 0, 0), 0.34, m["ink"]) + # Wall posters with redaction bars (left/right of the door). + for x in (-13.5, 13.5): + make_box("Poster_%d" % x, x, 21.87, 4.6, 3.4, 0.12, 2.2, m["paper"]) + make_box("PosterBar1_%d" % x, x - 0.55, 21.79, 5.15, 1.9, 0.05, 0.3, + m["ink"]) + make_box("PosterBar2_%d" % x, x + 0.35, 21.79, 4.66, 1.5, 0.05, 0.3, + m["ink"]) + make_box("PosterBar3_%d" % x, x - 0.15, 21.79, 4.17, 2.3, 0.05, 0.3, + m["ink"]) + # EXIT signs (emissive green + text). + for x in (-10, 10): + make_box("ExitBox_%d" % x, x, 21.82, 6.35, 1.7, 0.12, 0.52, + m["exit_green"]) + make_text("ExitText_%d" % x, "EXIT", (x, 21.72, 6.22), + (math.pi / 2, 0, 0), 0.36, m["ink"]) + +def build_structure(m): + h = 8.5 + # Pillars (game layout spirit: ring of columns around the arena). + pillar_pos = [(15, 15), (-15, 15), (15, -15), (-15, -15), + (0, 18.5), (0, -18.5), (18.5, 0), (-18.5, 0)] + for i, (x, y) in enumerate(pillar_pos): + make_box("Pillar_%d" % i, x, y, h / 2, 2.4, 2.4, h, m["concrete"]) + make_box("PillarBase_%d" % i, x, y, 0.22, 2.9, 2.9, 0.44, m["door_dark"]) + make_box("PillarBand_%d" % i, x, y, 2.55, 2.46, 2.46, 0.5, m["hissshine"]) + make_box("PillarCap_%d" % i, x, y, h - 0.18, 2.9, 2.9, 0.36, + m["concrete"]) + # Ceiling beams + recessed fluorescent strips (open ceiling so the tactical + # camera sees the floor; beams cross the frame and reflect in the polish). + for y in (-6, 4, 14): + make_box("Beam_%d" % y, 0, y, 7.65, 45.2, 1.1, 0.8, m["concrete"]) + make_box("Strip_%d" % y, 0, y, 7.2, 38.0, 0.55, 0.12, m["strip"]) + for x in (-11, 11): + make_box("BeamX_%d" % x, x, 6, 7.65, 1.1, 33.0, 0.8, m["concrete"]) + # Red flickering strips near the door (corruption). + for x in (-7.5, 7.5): + make_box("StripRed_%d" % x, x, 17.8, 6.6, 0.5, 4.5, 0.12, m["strip_red"]) + # Wall-mounted strips on the far wall. + for x in (-17, -8.5, 8.5, 17): + make_box("WallStrip_%d" % x, x, 21.8, 6.9, 4.2, 0.15, 0.32, m["strip"]) + # Brass stanchions + red ropes along the carpet. + post_y = [-7.0, -1.8, 3.4, 8.6, 13.8, 19.0] + for side in (-4.35, 4.35): + for j, y in enumerate(post_y): + make_cyl("Post_%d_%d" % (side, y), side, y, 0.0, 1.02, 0.09, + m["brass"], segs=12) + make_cyl("PostBase_%d_%d" % (side, y), side, y, 0.0, 0.07, 0.3, + m["brass"], segs=12) + for j in range(len(post_y) - 1): + y0, y1 = post_y[j], post_y[j + 1] + # Sagging rope: 4 short segments forming a catenary dip. + zs = (0.95, 0.885, 0.845, 0.885, 0.95) + ys = [y0 + (y1 - y0) * k / 4.0 for k in range(5)] + for k in range(4): + dy = ys[k + 1] - ys[k] + dz = zs[k + 1] - zs[k] + make_box_obj("Rope_%d_%d_%d" % (side, j, k), + (0.07, math.hypot(dy, dz), 0.07), + (side, (ys[k] + ys[k + 1]) / 2.0, + (zs[k] + zs[k + 1]) / 2.0), + (math.atan2(dz, dy), 0.0, 0.0), m["rope"]) + # Floating Hiss-corrupted geometry (red slabs drifting through walls). + slabs = [ + ((14.5, 12.0, 5.4), (0.35, 0.5, 0.7), (2.6, 0.35, 1.8)), + ((-13.5, 8.5, 6.1), (0.6, -0.3, 0.45), (2.1, 0.3, 1.5)), + ((7.5, 18.0, 6.7), (0.2, 0.45, 1.1), (3.0, 0.4, 1.2)), + ((-9.0, -2.5, 6.8), (0.5, 0.2, 0.9), (1.8, 0.3, 1.1)), + ((18.0, -5.0, 4.3), (1.1, 0.3, 0.2), (1.6, 0.28, 1.6)), + ((-17.5, -12.0, 5.0), (0.4, 0.8, 0.3), (2.2, 0.32, 1.3)), + ] + for i, (loc, rot, size) in enumerate(slabs): + make_box_obj("HissSlab_%d" % i, size, loc, rot, m["hissshine"]) + # The Board's monolith: yellow light of the Board. + make_box("Monolith", -15, 12, 2.8, 2.4, 1.0, 5.6, m["door_dark"]) + make_box("MonolithGlow", -15, 11.42, 2.8, 0.3, 0.12, 4.6, m["board"]) + make_box("MonolithCap", -15, 12, 5.75, 2.9, 1.4, 0.35, m["concrete"]) + make_text("MonolithText", "THE BOARD", (-15, 11.3, 4.15), (math.pi / 2, 0, 0), + 0.32, m["board"]) + # Side-wall redacted signage (bars sit 3 cm proud of the panel, room side). + for x in (-21.85, 21.85): + make_box("SideSign_%d" % x, x, 6, 4.6, 0.12, 3.6, 1.9, m["paper"]) + for k, (dz, w) in enumerate(((0.55, 2.6), (0.0, 3.0), (-0.55, 2.2))): + make_box("SideSignBar_%d_%d" % (x, k), x - math.copysign(0.03, x), 6, + 4.6 + dz, 0.06, w, 0.28, m["ink"]) + +CAM_HERO = (0.0, -34.0, 30.0) # billboards face this azimuth + + +def facing_yaw(x, y): + """Yaw that turns a vertical billboard to face the hero camera.""" + return math.atan2(CAM_HERO[0] - x, -(CAM_HERO[1] - y)) + + +def build_sprites(): + return { + "guard": draw_guard(), + "hiss_staff": draw_hiss_staff(), + "hiss_brute": draw_hiss_brute(), + "mold_spore": draw_mold_spore(), + "shard": draw_shard(), + "glow": draw_glow(), + } + + +def standee(m, mats, name, key, x, y, h, base=True, shadow=True): + """Camera-facing photo standee: sprite quad + base + blob shadow.""" + w = h * 0.86 + yaw = facing_yaw(x, y) + cz = (0.1 if base else 0.0) + h * 0.47 + if shadow: + make_cyl("Blob_" + name, x, y, 0.015, 0.035, w * 0.62, m["blob"], segs=20, + coll="STANDEES") + if base: + make_box("Base_" + name, x, y, 0.05, w * 0.55, 0.24, 0.1, m["base"], + coll="STANDEES") + make_quad("Standee_" + name, x, y, cz, w, h, yaw, mats[key], coll="STANDEES") + + +def build_standees(m, imgs): + mats = {k: sprite_mat(k, img) for k, img in imgs.items()} + mats["glow"] = sprite_mat("glow", imgs["glow"], emit=22.0) + # The guard — hero of the diorama, on the carpet's edge. + standee(m, mats, "Guard", "guard", 0.0, 0.4, 2.35) + # Hiss Corrupted Staff: the chanting crowd closing in. + staff = [(-4.5, 2.5, 2.1), (4.2, 3.2, 2.0), (-2.5, -3.8, 2.15), + (3.0, -3.2, 2.05), (-7.5, 0.5, 2.1), (7.0, 1.2, 2.0)] + for i, (x, y, h) in enumerate(staff): + standee(m, mats, "Staff_%d" % i, "hiss_staff", x, y, h) + # Hiss Brute + Mold Spores. + standee(m, mats, "Brute", "hiss_brute", 9.5, 4.5, 3.3) + standee(m, mats, "Mold_0", "mold_spore", -9.0, -4.0, 1.5) + standee(m, mats, "Mold_1", "mold_spore", 10.5, -2.8, 1.45) + # XP shards hovering (Resonance Shards). + shards = [(-2.0, 1.2), (1.8, -1.5), (-5.0, -2.0), (5.5, -1.0), + (-1.0, 4.5), (3.0, 5.5), (-6.5, 3.0)] + for i, (x, y) in enumerate(shards): + yaw = facing_yaw(x, y) + make_quad("Shard_%d" % i, x, y, 0.75, 0.62, 0.72, yaw, mats["shard"], + coll="STANDEES") + # Service Weapon: Spin — projectiles in flight (glow billboards). + shots = [(2.2, 0.9, 1.35), (3.3, 1.5, 1.3), (4.3, 2.1, 1.28)] + for i, (x, y, z) in enumerate(shots): + yaw = facing_yaw(x, y) + make_quad("Shot_%d" % i, x, y, z, 0.85, 0.85, yaw, mats["glow"], + coll="STANDEES") + +def build_lights_and_cameras(m): + # Volumetric haze (light shafts + atmosphere). + make_box("Haze", 0, 0, 4.2, 44.0, 44.0, 8.4, m["volume"], coll="ATMOS") + # Key + fill. + add_light("Key_Area", "AREA", (0, 4, 14), (0, 0, 0), 2000, (1.0, 0.97, 0.9), + size=30) + add_light("Fill_Area", "AREA", (0, -24, 14), (math.radians(65), 0, 0), 550, + (0.85, 0.9, 1.0), size=22) + # Direct light under the fluorescent strips (guarantees the warm pools). + for y in (-6, 4, 14): + add_light("StripLight_%d" % y, "AREA", (0, y, 7.05), (0, 0, 0), 620, + (1.0, 0.93, 0.78), size=8) + # Hiss red pools + door glow + Board yellow. + add_light("Red_Main", "POINT", (3, 2, 2.2), (0, 0, 0), 500, (1.0, 0.12, 0.1), + radius=1.2) + add_light("Red_Far", "POINT", (-6, 4, 3.0), (0, 0, 0), 350, (1.0, 0.12, 0.1), + radius=1.5) + add_light("Red_Door", "POINT", (0, 20.0, 3.2), (0, 0, 0), 600, + (1.0, 0.08, 0.08), radius=1.5) + add_light("Board_Yellow", "POINT", (-15, 10.6, 3.2), (0, 0, 0), 600, + (1.0, 0.72, 0.2), radius=1.0) + # Warm kicker on the guard — the hero must read at a glance (readability + # first, docs/ART_DIRECTION.md). + add_light("Hero_Kicker", "POINT", (-2.2, -2.6, 3.4), (0, 0, 0), 220, + (1.0, 0.85, 0.62), radius=0.9) + # Cameras. + add_camera("Cam_Hero", CAM_HERO, (0, 1.5, 2.5), lens=45.0) + add_camera("Cam_Game", (0, -16, 20), (0, 1.0, 1.0), lens=29.0) # fovy 45 + add_camera("Cam_Detail", (6.5, -12.5, 7.5), (0, 1.7, 1.2), lens=36.0) + bpy.context.scene.camera = bpy.data.objects["Cam_Hero"] + + +def setup_world_and_render(): + sc = bpy.context.scene + world = bpy.data.worlds.new("OldestHouseNight") + world.use_nodes = True + bg = world.node_tree.nodes.get("Background") + if bg is not None: + bg.inputs["Color"].default_value = (0.012, 0.015, 0.022, 1.0) + bg.inputs["Strength"].default_value = 0.55 + sc.world = world + sc.render.engine = "BLENDER_EEVEE" + sc.render.resolution_x = 1920 + sc.render.resolution_y = 1080 + sc.render.resolution_percentage = 100 + sc.render.image_settings.file_format = "PNG" + sc.render.film_transparent = False + ee = sc.eevee + for attr, val in (("taa_render_samples", 128), + ("use_raytracing", True), + ("use_volumetric_shadows", True), + ("volumetric_samples", 96), + ("volumetric_end", 120.0)): + try: + setattr(ee, attr, val) + except Exception: + print("[render] skip eevee." + attr) + sc.view_settings.exposure = 0.25 + try: + sc.view_settings.view_transform = "AgX" + except Exception: + pass # minimal-OCIO builds only ship "Standard"; lighting compensates + for look in ("AgX - Punchy", "Punchy"): + try: + sc.view_settings.look = look + break + except Exception: + continue + print("[render] engine", sc.render.engine, "| view", + sc.view_settings.view_transform, "| look", sc.view_settings.look) + + +def setup_glare(sc): + """Best-effort compositor bloom for the fluorescent look. + + Blender 5.x: compositor is a node group on scene.compositing_node_group with + a Group Output (no CompositorNodeComposite). Blender 4.x: scene.node_tree. + The Glare node exposes its settings as input sockets in 5.x. + """ + nt = None + try: + sc.use_nodes = True + nt = sc.node_tree + except Exception: + pass + if nt is None: + try: + nt = bpy.data.node_groups.new("Compositing", "CompositorNodeTree") + sc.compositing_node_group = nt + except Exception as exc: + print("[glare] no compositor:", exc) + return + try: + for node in list(nt.nodes): + nt.nodes.remove(node) + rl = nt.nodes.new("CompositorNodeRLayers") + glare = nt.nodes.new("CompositorNodeGlare") + try: + glare.inputs["Type"].default_value = "Bloom" # 5.x menu socket + except Exception: + glare.glare_type = "BLOOM" # 4.x property + for sock, val in (("Threshold", 1.0), ("Strength", 0.55), ("Size", 0.6)): + try: + glare.inputs[sock].default_value = val + except Exception: + pass + try: # 5.x output + if "Image" not in [it.name for it in nt.interface.items_tree]: + nt.interface.new_socket("Image", in_out="OUTPUT", + socket_type="NodeSocketColor") + out = nt.nodes.new("NodeGroupOutput") + out_sock = out.inputs["Image"] + except Exception: # 4.x output + out = nt.nodes.new("CompositorNodeComposite") + out_sock = out.inputs["Image"] + nt.links.new(rl.outputs["Image"], glare.inputs["Image"]) + nt.links.new(glare.outputs["Image"], out_sock) + sc.render.use_compositing = True + print("[glare] bloom enabled") + except Exception as exc: + print("[glare] skipped:", exc) + + +def main(): + wipe_scene() + m = build_materials() + build_floor(m) + build_walls(m) + build_structure(m) + imgs = build_sprites() + build_standees(m, imgs) + build_lights_and_cameras(m) + setup_world_and_render() + setup_glare(bpy.context.scene) + blend_path = os.path.join(BLEND_DIR, "fbc_night_shift_diorama.blend") + bpy.ops.wm.save_as_mainfile(filepath=blend_path) + n = len(bpy.data.objects) + print("[build] DONE — objects:", n, "| blend:", blend_path) + + +main() diff --git a/tools/blender/render_shots.py b/tools/blender/render_shots.py new file mode 100644 index 0000000..d92bac6 --- /dev/null +++ b/tools/blender/render_shots.py @@ -0,0 +1,34 @@ +# tools/blender/render_shots.py +# Renders the FBC: NIGHT SHIFT concept cameras into docs/concept/. +# Run inside Blender after build_scene.py: +# exec(open("/home/dandovlatov/Documents/cntrl/tools/blender/render_shots.py").read()) +import os +import time + +import bpy + +REPO = "/home/dandovlatov/Documents/cntrl" +OUT = os.path.join(REPO, "docs", "concept") +os.makedirs(OUT, exist_ok=True) + +SHOTS = [ + ("Cam_Hero", "hero_oldest_house.png"), + ("Cam_Game", "hero_game_camera.png"), + ("Cam_Detail", "detail_guard_standees.png"), +] + +sc = bpy.context.scene +t_start = time.time() +for cam_name, filename in SHOTS: + cam = bpy.data.objects.get(cam_name) + if cam is None: + print("[render] missing camera", cam_name) + continue + sc.camera = cam + sc.render.filepath = os.path.join(OUT, filename) + t0 = time.time() + bpy.ops.render.render(write_still=True) + print("[render] %s -> %s (%.0fs)" % (cam_name, filename, time.time() - t0)) + +sc.camera = bpy.data.objects.get("Cam_Hero", sc.camera) +print("[render] done in %.0fs" % (time.time() - t_start))