cntrl/tools/blender/build_ambient.py
dandovlatov a205f37028 Added a rare ambient Hiss riser that floats up and dissolves
A dark, upward-tilted figure now appears occasionally around Floor 01, climbs a few metres with a red Hiss wake and dissolves into the haze. There is deliberately no roof mesh: the tactical camera sits above the room, so a ceiling would hide the play area. The riser is presentation-only - no collision, health, XP, director card or steering - and its fixed anchors never follow the player.

- Added ascended.glb (1,474 tris, one merged mesh and material, jacket with trouser legs and boots) and the reproducible tools/blender/build_ambient.py generator
- Registered ActorModel::Ascended with rig, Hiss tint, height, name mapping and a dark humanoid fallback
- Authored wall-side anchors in map space, validated against cooked walls; one active early, up to three as corruption climbs, visible only ~5 s of a 34-62 s cycle
- Added the rise, red ground bloom, haze veil and fade directly in the presenter, plus --ascension-test to stage one mid-rise in the plaza for screenshot QA
- README updated; build clean and 17/17 tests pass with staged and normal-play captures reviewed
2026-11-25 07:05:51 +04:00

191 lines
8.1 KiB
Python

# tools/blender/build_ambient.py
# FBC: NIGHT SHIFT — ambient Hiss riser (the figure being pulled "up the roof").
#
# Run inside Blender 5.x:
# exec(open("/home/dandovlatov/Documents/cntrl/tools/blender/build_ambient.py").read())
#
# Exports a single merged, vertex-painted GLB with feet at the origin and the
# face looking -Y (glTF Y-up turns that into +Z in the game). The figure is
# presentation-only: it never enters the enemy simulation.
import math
import os
import sys
import bpy
import mathutils
REPO = "/home/dandovlatov/Documents/cntrl"
MODEL_DIR = os.path.join(REPO, "assets", "models")
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({"rot": "#4a1018", "rot_dk": "#200a10", "rot_vein": "#a81a22",
"ink": "#15161b"})
def build_ascended():
"""A dark, upward-tilted figure with limp arms and red tether filaments."""
r = K.new_actor("Ascended")
# Jacket: ends at the hip, so the trouser legs stay legible from above.
K.loft(r, "jacket", [
{"z": 0.90, "r": (0.29, 0.20), "n": 14, "fold": (0.03, 5)},
{"z": 1.02, "r": (0.30, 0.205), "n": 14, "fold": (0.04, 5)},
{"z": 1.18, "r": (0.31, 0.215), "n": 14, "fold": (0.04, 6)},
{"z": 1.34, "r": (0.32, 0.22), "n": 14, "fold": (0.03, 5)},
{"z": 1.46, "r": (0.31, 0.21), "n": 14},
], P["navy_dk"], ao=0.14)
K.loft(r, "belt", [
{"z": 0.88, "r": (0.29, 0.205), "n": 12},
{"z": 0.94, "r": (0.30, 0.21), "n": 12},
], P["redaction"], ao=0.06)
K.plate(r, "jacket_front", K.octagon(0.27, 0.19), 0.98, 1.44, 0.94,
P["navy"], shift=(0, -0.015), ao=0.10)
# Two separate trouser legs, slightly slack and offset as if weightless.
for side in (-1, 1):
K.loft(r, "pants_%d" % side, [
{"z": 0.94, "r": (0.155, 0.16), "n": 12, "c": (side * 0.15, 0)},
{"z": 0.76, "r": (0.15, 0.155), "n": 12, "c": (side * 0.16, -0.005)},
{"z": 0.58, "r": (0.14, 0.145), "n": 12, "c": (side * 0.17, -0.01)},
{"z": 0.40, "r": (0.125, 0.13), "n": 12, "c": (side * 0.18, -0.015)},
{"z": 0.22, "r": (0.11, 0.115), "n": 12, "c": (side * 0.185, -0.02)},
{"z": 0.12, "r": (0.10, 0.105), "n": 12, "c": (side * 0.19, -0.02)},
], P["navy"], ao=0.12)
K.plate(r, "knee_%d" % side, K.octagon(0.13, 0.12), 0.42, 0.52, 0.92,
P["navy_dk"], shift=(side * 0.175, -0.11), ao=0.06)
K.loft(r, "boot_%d" % side, [
{"z": 0.0, "r": (0.125, 0.185), "n": 10, "c": (side * 0.19, -0.075)},
{"z": 0.10, "r": (0.115, 0.16), "n": 10, "c": (side * 0.19, -0.045)},
{"z": 0.20, "r": (0.105, 0.12), "n": 10, "c": (side * 0.19, -0.015)},
], P["redaction"], ao=0.06)
# Neck, head and face; the head tips back so the gaze follows the rise.
# A pale mask keeps the figure human when seen from the tactical camera.
K.tube(r, "neck", [(0, 0.01, 1.48), (0, 0.0, 1.62)], [0.09, 0.095],
P["ink"], sides=9)
head = K.blob(r, "head", (0, -0.01, 1.74), (0.195, 0.175, 0.215),
P["skin"], subdiv=2, seed=11, ao=0.04)
head.rotation_euler.x = -0.24 # chin lifts toward the ceiling
hood = K.blob(r, "hood", (0, 0.045, 1.82), (0.205, 0.19, 0.115),
P["redaction"], subdiv=2, seed=12, warp=0.10)
hood.rotation_euler.x = -0.24
for side in (-1, 1):
K.crystal(r, "eye_%d" % side, (side * 0.072, -0.168, 1.76), 0.05,
P["hiss_hot"], sides=5, seed=20 + side,
tilt=(math.pi / 2, 0, 0))
K.plate(r, "jaw", K.octagon(0.11, 0.07), 1.55, 1.63, 0.86,
P["redaction"], shift=(0, -0.06), ao=0.06)
# Broad shoulders and limp arms: the cross-shaped silhouette is what reads
# when the tactical camera looks down at the figure.
for side in (-1, 1):
K.blob(r, "shoulder_%d" % side, (side * 0.34, 0.01, 1.42),
(0.17, 0.17, 0.15), P["navy_dk"], subdiv=1, seed=30 + side)
K.tube(r, "arm_%d" % side,
[(side * 0.37, 0.01, 1.42), (side * 0.46, 0.07, 1.14),
(side * 0.50, 0.11, 0.84)], [0.10, 0.078, 0.055],
P["redaction"], sides=7)
K.blob(r, "hand_%d" % side, (side * 0.51, 0.12, 0.79),
(0.075, 0.08, 0.095), P["skin"], subdiv=1, seed=40 + side)
for f in range(4):
x = side * (0.47 + f * 0.034)
K.tube(r, "finger_%d_%d" % (side, f),
[(x, 0.13, 0.77), (x + side * 0.01, 0.15, 0.67),
(x + side * 0.02, 0.17, 0.59)],
[0.018, 0.014, 0.008], P["skin"], sides=5)
# Black-red rot crawling over the back and collar — no spikes above the
# head: the rise is communicated by motion and haze, not by antennae.
for i, (pos, size, tilt, hot) in enumerate([
((-0.22, 0.17, 1.39), 0.13, (0.3, -0.2, 0.5), False),
((0.21, 0.18, 1.33), 0.12, (-0.2, 0.3, -0.4), True),
((0.0, 0.21, 1.50), 0.11, (0.1, -0.3, 0.1), False),
((-0.31, 0.08, 1.43), 0.10, (0.4, 0.2, 0.6), False),
]):
K.crystal(r, "rot_%d" % i, pos, size,
P["hiss"] if hot else P["rot"], sides=5, seed=50 + i,
tilt=tilt)
for i, pts in enumerate([
[(-0.13, 0.24, 1.40), (-0.19, 0.28, 1.54), (-0.24, 0.30, 1.66)],
[(0.14, 0.24, 1.36), (0.20, 0.29, 1.50), (0.25, 0.31, 1.62)],
[(0.0, 0.03, 1.54), (0.01, 0.08, 1.66), (0.03, 0.12, 1.78)],
]):
K.tube(r, "vein_%d" % i, pts, [0.015] * len(pts), P["rot_vein"],
sides=5)
return r
root = build_ascended()
mesh = K.merge_actor(root, "ascended")
tris = K.triangle_count(root)
print("[budget] ascended %d tris (cap 2200) %s"
% (tris, "OK" if tris <= 2200 else "OVER"))
assert tris <= 2200, "ascended over triangle budget"
out = os.path.join(MODEL_DIR, "ascended.glb")
K.export_actor(root, "ascended", out)
print("[export] %s (%d bytes)" % (out, os.path.getsize(out)))
# Small showroom so the silhouette can be judged at tactical and close range.
world = bpy.data.worlds.new("AmbientWorld")
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("#100a0d"), 1.0)
bg.inputs["Strength"].default_value = 0.9
def area(name, loc, color, power, size):
data = bpy.data.lights.new(name, "AREA")
data.energy = power
data.shape = "DISK"
data.size = size
data.color = K.rgb(color)
obj = bpy.data.objects.new(name, data)
bpy.context.scene.collection.objects.link(obj)
obj.location = loc
direction = (0.0 - loc[0], 0.0 - loc[1], 1.3 - loc[2])
obj.rotation_euler = mathutils.Vector(direction).to_track_quat("-Z", "Y").to_euler()
return obj
area("Key", (-3, -7, 9), "#dce6ff", 2600, 7)
area("HissFill", (5, -2, 4), "#ff3b46", 1800, 6)
area("Rim", (0, 6, 6), "#a81a22", 1500, 6)
cam_data = bpy.data.cameras.new("AscendedCam")
cam = bpy.data.objects.new("AscendedCam", cam_data)
bpy.context.scene.collection.objects.link(cam)
cam.location = (1.4, -6.5, 3.4)
cam.rotation_euler = mathutils.Vector((0.0, 6.5, -1.9)).to_track_quat("-Z", "Y").to_euler()
cam_data.lens = 42
bpy.context.scene.camera = cam
scene = bpy.context.scene
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 = 640
scene.render.resolution_y = 800
scene.render.resolution_percentage = 100
scene.render.image_settings.file_format = "PNG"
scene.render.filepath = os.path.join(CONCEPT_DIR, "ascended.png")
try:
scene.eevee.taa_render_samples = 48
except Exception:
pass
bpy.ops.render.render(write_still=True)
print("[render] %s" % scene.render.filepath)
bpy.ops.wm.save_as_mainfile(filepath=os.path.join(BLEND_DIR, "fbc_ambient.blend"))
print("[done] ascended")