# 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 random 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"]) def add_bevel(obj, width=0.028, segments=2): """Chamfer hard edges so they catch light (S0 realism pass).""" try: mod = obj.modifiers.new("Bevel", "BEVEL") mod.width = width mod.segments = segments mod.limit_method = "ANGLE" except Exception as exc: print("[bevel] skipped on", obj.name, exc) # ------------------------------------------------------------- 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) if min(sx, sy, sz) > 0.09: # thin decals can't take a chamfer add_bevel(obj) 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) if min(size) > 0.09: add_bevel(obj) 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_quad_flat(name, cx, cy, z, w, h, yaw, mat, coll="FX"): """Horizontal quad in the XY plane (light spills, decals).""" hw, hh = w / 2.0, h / 2.0 rx, ry = math.cos(yaw), math.sin(yaw) sx, sy = -ry, rx # in-plane perpendicular verts = [(cx - rx * hw - sx * hh, cy - ry * hw - sy * hh, z), (cx + rx * hw - sx * hh, cy + ry * hw - sy * hh, z), (cx + rx * hw + sx * hh, cy + ry * hw + sy * hh, z), (cx - rx * hw + sx * hh, cy - ry * hw + sy * hh, z)] 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) # Gloss variation: sealed concrete reflects unevenly. gloss = nt.nodes.new("ShaderNodeValToRGB") gloss.location = (-520, -40) gloss.color_ramp.elements[0].position = 0.3 gloss.color_ramp.elements[0].color = (0.07, 0.07, 0.07, 1.0) gloss.color_ramp.elements[1].position = 0.8 gloss.color_ramp.elements[1].color = (0.32, 0.32, 0.32, 1.0) nt.links.new(noise.outputs["Fac"], gloss.inputs["Fac"]) nt.links.new(gloss.outputs["Color"], b.inputs["Roughness"]) 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) # --- S0/S1 additions ------------------------------------------------- m["flicker"] = principled("fluor_dead", (0.16, 0.16, 0.17), rough=0.4, emit=(0.5, 0.5, 0.55), emit_str=0.25) m["teal"] = principled("polaris_teal", (0.1, 0.45, 0.4), rough=0.35, emit=(0.3, 0.79, 0.69), emit_str=4.0) m["glass"] = principled("glass_case", (0.75, 0.85, 0.9), rough=0.06, alpha=0.13) m["water"] = principled("puddle", (0.02, 0.025, 0.03), rough=0.05) m["screen"] = principled("screen_dark", (0.01, 0.012, 0.015), rough=0.18, emit=(0.12, 0.16, 0.2), emit_str=0.6) m["hotline"] = principled("hotline_red", (0.55, 0.03, 0.04), rough=0.3, emit=(1.0, 0.1, 0.08), emit_str=1.1) m["plastic"] = principled("plastic_dark", (0.07, 0.07, 0.08), rough=0.35) m["paper_scrap"] = principled("paper_scrap", (0.78, 0.75, 0.66), rough=0.7) m["duck"] = principled("duck_yellow", (0.85, 0.62, 0.05), rough=0.22) m["dust"] = principled("dust_mote", (0.9, 0.85, 0.7), rough=0.5, emit=(1.0, 0.92, 0.72), emit_str=2.2, alpha=0.55) 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"]) # Sector failing: the y=-6 strip is dead (art doc: lights fail one by one). make_box("Strip_%d" % y, 0, y, 7.2, 38.0, 0.55, 0.12, m["flicker"] if y == -6 else m["strip"]) for x in (-11, 11): make_box("BeamX_%d" % x, x, 6, 7.65, 1.1, 33.0, 0.8, m["concrete"]) # A fixture torn loose, hanging at an angle. make_box_obj("StripHanging", (0.55, 2.4, 0.12), (11, 9.2, 6.7), (0.32, 0.0, 0.18), m["flicker"]) # 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 (one dead). for i, x in enumerate((-17, -8.5, 8.5, 17)): make_box("WallStrip_%d" % x, x, 21.8, 6.9, 4.2, 0.15, 0.32, m["flicker"] if i == 1 else 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"]) # Polaris alcove — the teal of the safe (palette entry 4/4), left wall. make_box("PolarisRecess", -21.55, -6, 2.6, 1.1, 3.2, 5.2, m["door_dark"]) make_box("PolarisGlow", -20.95, -6, 2.6, 0.1, 2.3, 4.1, m["teal"]) make_box("PolarisLintel", -21.3, -6, 5.45, 1.6, 3.6, 0.35, m["concrete"]) 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 tinted_glow_mat(name, img, tint, emit_str): """Radial glow decal material (light spills), tinted per use.""" mat = new_mat(name) nt = mat.node_tree b = bsdf_of(mat) tex = nt.nodes.new("ShaderNodeTexImage") tex.image = img mult = nt.nodes.new("ShaderNodeVectorMath") mult.operation = "MULTIPLY" mult.inputs[1].default_value = tint nt.links.new(tex.outputs["Color"], mult.inputs[0]) if b.inputs.get("Emission Color") is not None: nt.links.new(mult.outputs["Vector"], b.inputs["Emission Color"]) set_in(b, "Emission Strength", emit_str) 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: pass try: mat.show_transparent_back = False except Exception: pass return mat def build_fx(m, imgs): """S0 atmosphere: light spills + dust motes.""" spill = tinted_glow_mat("spill_red", imgs["glow"], (1.0, 0.12, 0.1), 1.1) teal_spill = tinted_glow_mat("spill_teal", imgs["glow"], (0.3, 0.85, 0.72), 1.0) # Threshold-door spill: red washes out of the doorway onto the carpet. make_quad_flat("DoorSpill_A", 0, 18.4, 0.075, 9.0, 8.5, math.pi / 2, spill) make_quad_flat("DoorSpill_B", 0, 20.4, 0.08, 6.5, 5.0, math.pi / 2, spill) # Polaris alcove pool on the floor. make_quad_flat("PolarisSpill", -19.6, -6, 0.02, 5.5, 5.5, 0.0, teal_spill) # Dust motes: seeded emissive micro-voxels (deterministic per seed). rng = random.Random(7) for i in range(70): x = rng.uniform(-20.0, 20.0) y = rng.uniform(-18.0, 21.0) z = rng.uniform(0.4, 7.0) s = rng.uniform(0.02, 0.055) make_box("Dust_%d" % i, x, y, z, s, s, s, m["dust"], coll="FX") def build_props(m): """S1 identity props: Objects of Power + FBC furniture.""" # --- Hotline (the Board's phone) — left, near the far wall. make_box("HotlineTable", -13, 17.2, 0.42, 1.35, 0.95, 0.84, m["plastic"]) make_box("HotlineBase", -13, 17.2, 0.93, 0.55, 0.38, 0.16, m["hotline"]) make_box_obj("HotlineHandset", (0.5, 0.12, 0.12), (-13, 17.2, 1.08), (0.0, 0.0, 0.25), m["hotline"]) make_box("HotlineCord", -13, 17.05, 0.86, 0.06, 0.3, 0.06, m["ink"]) # --- Benicoff TV — right of the door. make_box("TVStand", 10, 17.4, 0.45, 2.5, 1.15, 0.9, m["plastic"]) make_box("TVBody", 10, 17.4, 1.72, 2.15, 0.85, 1.45, m["plastic"]) make_box("TVScreen", 10, 16.94, 1.72, 1.85, 0.06, 1.15, m["screen"]) make_box("TVAntenna", 10.6, 17.6, 2.72, 0.05, 0.05, 0.7, m["ink"]) # --- Service Weapon on its pedestal — left of the carpet cross. make_box("Pedestal", -7, 12, 0.58, 1.15, 1.15, 1.15, m["concrete"]) make_box("PedestalTop", -7, 12, 1.18, 0.85, 0.85, 0.07, m["ink"]) make_box_obj("ServiceWeapon_A", (0.62, 0.11, 0.11), (-7, 12, 1.38), (0.0, 0.0, 0.55), m["plastic"]) make_box_obj("ServiceWeapon_B", (0.42, 0.1, 0.1), (-6.83, 12.05, 1.32), (0.0, 0.55, -0.35), m["plastic"]) make_box("PedestalGlow", -7, 11.42, 0.9, 0.55, 0.04, 0.08, m["strip"]) # --- Rubber Duck under glass — right of the carpet cross. make_box("DuckPlinth", 7, 12, 0.45, 0.8, 0.8, 0.9, m["concrete"]) make_box("DuckBody", 7, 12, 1.06, 0.32, 0.24, 0.2, m["duck"]) make_box("DuckHead", 7, 11.92, 1.26, 0.16, 0.15, 0.15, m["duck"]) make_box("DuckBeak", 7, 11.82, 1.25, 0.07, 0.09, 0.05, m["hotline"]) make_box("DuckCase", 7, 12, 1.21, 0.58, 0.58, 0.62, m["glass"]) # --- Security desk — front-left, the guard's post. make_box("DeskTop", -12, -8, 0.92, 4.6, 1.7, 0.1, m["plastic"]) for dx in (-1.85, 1.85): make_box("DeskPed_%d" % dx, -12 + dx, -8, 0.44, 0.65, 1.5, 0.88, m["door_dark"]) make_box("MonitorStand", -12, -8.55, 1.13, 0.3, 0.28, 0.32, m["plastic"]) make_box("Monitor", -12, -8.6, 1.62, 1.25, 0.09, 0.78, m["plastic"]) make_box("MonitorScreen", -12, -8.54, 1.62, 1.08, 0.03, 0.62, m["screen"]) make_box("DeskLampStem", -13.7, -8.5, 1.18, 0.16, 0.16, 0.42, m["ink"]) make_box("DeskLampHead", -13.7, -8.42, 1.42, 0.3, 0.22, 0.1, m["strip"]) make_cyl("ChairPost", -13.6, -9.6, 0.0, 0.5, 0.07, m["plastic"], segs=10) make_box("ChairSeat", -13.6, -9.6, 0.55, 0.58, 0.58, 0.1, m["plastic"]) make_box("ChairBack", -13.6, -9.32, 0.95, 0.55, 0.09, 0.62, m["plastic"]) # --- Filing cabinets along the right wall (drawer seams + handles). for i, y in enumerate((0.2, 1.35, 2.5)): make_box("Cabinet_%d" % i, 20.7, y, 1.15, 1.05, 1.05, 2.3, m["door_dark"]) for k in range(4): make_box("CabinetSeam_%d_%d" % (i, k), 20.16, y, 0.5 + k * 0.52, 0.03, 0.92, 0.03, m["ink"]) make_box("CabinetHandle_%d_%d" % (i, k), 20.13, y, 0.62 + k * 0.52, 0.05, 0.3, 0.05, m["plastic"]) # --- Scattered redacted papers (seeded). rng = random.Random(11) n = 0 for cx, cy in ((-12, -8), (14, -2), (-16, 8), (6, 16)): for _ in range(6): x = cx + rng.uniform(-2.2, 2.2) y = cy + rng.uniform(-1.8, 1.8) make_box_obj("Paper_%d" % n, (0.34, 0.25, 0.012), (x, y, 0.012), (0.0, 0.0, rng.uniform(0.0, math.pi)), m["paper_scrap"]) n += 1 # --- Puddles: dark glossy discs for reflection interest. for i, (x, y, r) in enumerate(((-14, 2, 1.9), (12, -8, 2.4), (18, 8, 1.5))): make_cyl("Puddle_%d" % i, x, y, 0.02, 0.028, r, m["water"], segs=24) 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) # Polaris teal (the safe) + red wash pouring out of the threshold door. add_light("Polaris_Teal", "POINT", (-19.6, -6, 2.8), (0, 0, 0), 350, (0.35, 0.85, 0.75), radius=1.2) add_light("Door_Spill", "AREA", (0, 20.4, 2.4), (math.radians(-65), 0, 0), 550, (1.0, 0.1, 0.08), size=7) # 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", 96), ("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"]) tail = glare.outputs["Image"] # Chromatic aberration (subtle dispersion at the frame edges). try: dist = nt.nodes.new("CompositorNodeLensdist") for sock, val in (("Distortion", 0.02), ("Dispersion", 0.03)): try: dist.inputs[sock].default_value = val except Exception: pass nt.links.new(tail, dist.inputs["Image"]) tail = dist.outputs["Image"] print("[post] chromatic aberration on") except Exception as exc: print("[post] lensdist skipped:", exc) # Vignette: blurred ellipse mask multiplied over the frame. try: mask = nt.nodes.new("CompositorNodeEllipseMask") for sock, val in (("Value", 1.0), ("Position", (0.5, 0.5)), ("Size", (1.28, 1.06))): try: mask.inputs[sock].default_value = val except Exception: pass blur = nt.nodes.new("CompositorNodeBlur") try: blur.inputs["Size"].default_value = (220, 220) except Exception: pass nt.links.new(mask.outputs["Mask"], blur.inputs["Image"]) try: mix = nt.nodes.new("ShaderNodeMix") # unified Mix (5.x) mix.data_type = "RGBA" mix.blend_type = "MULTIPLY" mix.inputs[0].default_value = 0.42 a_sock, b_sock, r_sock = mix.inputs[6], mix.inputs[7], mix.outputs[2] except Exception: mix = nt.nodes.new("CompositorNodeMixRGB") # 4.x fallback mix.blend_type = "MULTIPLY" mix.inputs[0].default_value = 0.42 a_sock, b_sock, r_sock = mix.inputs[1], mix.inputs[2], mix.outputs[0] nt.links.new(tail, a_sock) nt.links.new(blur.outputs["Image"], b_sock) tail = r_sock print("[post] vignette on") except Exception as exc: print("[post] vignette skipped:", exc) nt.links.new(tail, out_sock) sc.render.use_compositing = True print("[glare] post chain wired") 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_fx(m, imgs) build_standees(m, imgs) build_props(m) 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()