574 lines
25 KiB
Python
574 lines
25 KiB
Python
"""Editable Blender master of the Eblan Games phosphor ident."""
|
|
|
|
import argparse
|
|
import math
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
import bpy
|
|
import numpy as np
|
|
from mathutils import Matrix, Vector
|
|
from bpy_extras.object_utils import world_to_camera_view
|
|
|
|
HERE = Path(__file__).resolve().parent
|
|
sys.path.insert(0, str(HERE))
|
|
from build_cinematic_v4 import area, cube, cylinder, lathe, mat, noise_surface
|
|
from build_studio_v6 import film_camera
|
|
from build_studio_v7 import SOURCE, set_render
|
|
from workshop_props import lettering
|
|
from workshop_set_v7 import curled_cable
|
|
|
|
WORK = HERE.parents[1] / "build/cinematic-v8"
|
|
TAU = math.tau
|
|
|
|
|
|
def surface(name, nu, nv, coordinates, material, wrap=False):
|
|
pts = [coordinates(i / nu, j / nv) for j in range(nv + 1) for i in range(nu if wrap else nu + 1)]
|
|
stride = nu if wrap else nu + 1
|
|
faces = []
|
|
for j in range(nv):
|
|
for i in range(nu):
|
|
a = j * stride + i
|
|
b = j * stride + (i + 1) % stride
|
|
faces.append((a, b, b + stride, a + stride))
|
|
mesh = bpy.data.meshes.new(name)
|
|
mesh.from_pydata(pts, [], faces)
|
|
mesh.materials.append(material)
|
|
for poly in mesh.polygons:
|
|
poly.use_smooth = True
|
|
obj = bpy.data.objects.new(name, mesh)
|
|
bpy.context.scene.collection.objects.link(obj)
|
|
return obj
|
|
|
|
|
|
def desk_props():
|
|
pliers = bpy.data.objects["Scan / pliers"]
|
|
# The scan is a hierarchy with its own scanner axes. Lay its widest
|
|
# face on the desk and calibrate the actual jaw-to-grip span in metres.
|
|
bpy.context.view_layer.update()
|
|
parts = [o for o in (pliers, *pliers.children_recursive) if o.type == "MESH"]
|
|
pts = np.array([tuple(o.matrix_world @ v.co) for o in parts for v in o.data.vertices])
|
|
axes = np.linalg.eigh(np.cov(pts.T))[1][:, ::-1].T.copy()
|
|
if np.linalg.det(axes) < 0:
|
|
axes[2] *= -1
|
|
local = pts @ axes.T
|
|
scale = 0.18 / np.ptp(local[:, 0])
|
|
angle = -0.74
|
|
heading = np.array(
|
|
[[math.cos(angle), -math.sin(angle), 0], [math.sin(angle), math.cos(angle), 0], [0, 0, 1]]
|
|
)
|
|
transform = scale * heading @ axes
|
|
posed = pts @ transform.T
|
|
center = (posed.min(axis=0) + posed.max(axis=0)) / 2
|
|
affine = Matrix(transform.tolist()).to_4x4()
|
|
affine.translation = Vector((-0.384 - center[0], -0.201 - center[1], 0.78725 - posed[:, 2].min()))
|
|
pliers.matrix_world = affine @ pliers.matrix_world
|
|
for name in ("Heavy ceramic coffee mug", "Coffee surface", "Mug / smooth handmade loop"):
|
|
bpy.data.objects.remove(bpy.data.objects[name], do_unlink=True)
|
|
glaze = mat("Cup / speckled grey celadon", (0.29, 0.37, 0.32), 0, 0.23)
|
|
shader = glaze.node_tree.nodes["Principled BSDF"]
|
|
shader.inputs["Coat Weight"].default_value = 0.42
|
|
noise_surface(glaze, 320, 0.000045)
|
|
nodes = glaze.node_tree.nodes
|
|
speckle = nodes.new("ShaderNodeTexNoise")
|
|
speckle.inputs["Scale"].default_value = 195
|
|
palette = nodes.new("ShaderNodeValToRGB")
|
|
palette.color_ramp.elements[0].position = 0.28
|
|
palette.color_ramp.elements[0].color = (0.09, 0.095, 0.064, 1)
|
|
palette.color_ramp.elements[1].position = 0.42
|
|
palette.color_ramp.elements[1].color = (0.47, 0.55, 0.49, 1)
|
|
glaze.node_tree.links.new(speckle.outputs["Fac"], palette.inputs[0])
|
|
glaze.node_tree.links.new(palette.outputs[0], shader.inputs["Base Color"])
|
|
profile = [
|
|
(0.001, 0.0018),
|
|
(0.024, 0.0018),
|
|
(0.027, 0),
|
|
(0.030, 0),
|
|
(0.032, 0.002),
|
|
(0.033, 0.006),
|
|
(0.0355, 0.015),
|
|
(0.039, 0.061),
|
|
(0.041, 0.088),
|
|
(0.0411, 0.092),
|
|
(0.0405, 0.094),
|
|
(0.039, 0.095),
|
|
(0.0375, 0.0945),
|
|
(0.0368, 0.093),
|
|
(0.0366, 0.090),
|
|
(0.034, 0.061),
|
|
(0.028, 0.014),
|
|
(0.023, 0.009),
|
|
(0.001, 0.008),
|
|
]
|
|
cup = lathe("Cup / thrown ceramic", profile, glaze)
|
|
cup.location = (0.645, -0.236, 0.7875)
|
|
coffee = mat("Cup / cold black tea", (0.029, 0.010, 0.003), 0.08, 0.16)
|
|
cylinder("Cup / tea meniscus", (0.645, -0.236, 0.854), 0.0345, 0.0005, coffee, 128)
|
|
|
|
# Oval cross-sections blend from the broad glazed attachments to a finer grip.
|
|
def handle(u, v):
|
|
a = v * math.pi
|
|
r = 0.0057 + 0.0029 * abs(math.cos(a)) ** 4
|
|
return (
|
|
0.645 + 0.037 + 0.024 * math.sin(a) + r * math.sin(a) * math.cos(TAU * u),
|
|
-0.236 + r * 0.77 * math.sin(TAU * u),
|
|
0.7875 + 0.050 + 0.027 * math.cos(a) + r * math.cos(a) * math.cos(TAU * u),
|
|
)
|
|
|
|
surface("Cup / pulled ceramic handle", 32, 64, handle, glaze, True)
|
|
# The old coffee stain sits beside the narrower cup.
|
|
for name, radius in (("Old dried coffee ring", 0.033), ("Old dried coffee ring.001", 0.031)):
|
|
ring = bpy.data.objects[name]
|
|
ring.scale *= 2 * radius / ring.dimensions.x
|
|
ring.location.z = 0.78745
|
|
bpy.data.objects["Old dried coffee ring.001"].location.x -= 0.021
|
|
tape = mat("PC / aged ivory polymer", (0.45, 0.43, 0.33), 0, 0.59)
|
|
dark = mat("PC / drive shadow", (0.023, 0.023, 0.019), 0.13, 0.52)
|
|
for i, z in enumerate((1.048, 1.108, 1.158)):
|
|
cube("PC / fitted drive face", (0.9, 0.159, z), (0.159, 0.009, 0.034), tape, 0.0026)
|
|
cube("PC / disc drawer seam", (0.9, 0.1538, z + 0.002), (0.137, 0.0018, 0.003), dark, 0.0013)
|
|
cube("PC / small eject key", (0.961, 0.153, z - 0.009), (0.015, 0.0025, 0.0034), tape, 0.001)
|
|
for x in (0.811, 0.989):
|
|
cube("PC / fascia parting line", (x, 0.162, 0.996), (0.0016, 0.003, 0.38), dark, 0.0006)
|
|
lettering(
|
|
"PC / serial marking",
|
|
"17 | PERSONAL COMPUTER",
|
|
(0.875, 0.164, 1.008),
|
|
0.0048,
|
|
dark,
|
|
(math.pi / 2, 0, 0),
|
|
)
|
|
|
|
|
|
def jacket():
|
|
chair = bpy.data.objects["Chair / casually turned with jacket"]
|
|
chair.rotation_euler.z = 0.62
|
|
for obj in list(chair.children_recursive):
|
|
if obj.name.startswith("Jacket /"):
|
|
bpy.data.objects.remove(obj, do_unlink=True)
|
|
cotton = mat("Jacket / faded indigo twill", (0.058, 0.081, 0.103), 0, 0.88)
|
|
cotton.node_tree.nodes["Principled BSDF"].inputs["Sheen Weight"].default_value = 0.19
|
|
noise_surface(cotton, 440, 0.00023)
|
|
seam = mat("Jacket / double-needle topstitch", (0.19, 0.193, 0.161), 0, 0.80)
|
|
binding = mat("Jacket / ribbed hem", (0.033, 0.044, 0.054), 0, 0.95)
|
|
brass = mat("Jacket / oxidised snap", (0.33, 0.23, 0.12), 0.8, 0.39)
|
|
|
|
def panel(u, v):
|
|
x = (u - 0.5) * (0.46 + 0.035 * math.sin(v * math.pi))
|
|
fold = 0.007 * math.sin(u * TAU * 4.6 + 0.8 * math.sin(v * 5)) + 0.003 * math.cos(u * TAU * 7 - v * 3)
|
|
if v < 0.38:
|
|
q = v / 0.38
|
|
y = 0.146 + 0.010 * q - fold
|
|
z = 0.687 + 0.393 * q + 0.022 * (1 - q) ** 2 * math.cos(4.6 * u + 0.27)
|
|
elif v < 0.57:
|
|
a = (v - 0.38) / 0.19 * math.pi
|
|
y = 0.22 - 0.064 * math.cos(a)
|
|
z = 1.080 + 0.031 * math.sin(a)
|
|
else:
|
|
q = (v - 0.57) / 0.43
|
|
y = 0.284 + 0.037 * q + fold * math.sin(q * math.pi / 2)
|
|
z = 1.08 - 0.458 * q + q * 0.020 * math.sin(5 * u)
|
|
z += 0.0058 * math.sin(5 * u + 0.7) * math.sin(v * math.pi)
|
|
return (x, y, z)
|
|
|
|
torso = surface("Jacket / continuous yoke over upholstered crest", 64, 104, panel, cotton)
|
|
torso.parent = chair
|
|
thick = torso.modifiers.new("Bound cloth edges", "SOLIDIFY")
|
|
thick.thickness = 0.0024
|
|
|
|
def stitch(name, pts, r, material):
|
|
o = curled_cable(name, pts, r, material)
|
|
o.parent = chair
|
|
|
|
for v in (0.016, 0.026, 0.975, 0.989):
|
|
stitch("Jacket / hem seam", [panel(i / 32, v) for i in range(33)], 0.0008, seam)
|
|
for u in (0.13, 0.87):
|
|
stitch("Jacket / panel seam", [panel(u, j / 40) for j in range(41)], 0.00085, seam)
|
|
for sign in (-1, 1):
|
|
|
|
def sleeve(u, v):
|
|
a = TAU * u
|
|
# A rounded sleeve head overlaps the yoke above the backrest.
|
|
cap = min(1, math.sin(min(1, v / 0.15) * math.pi / 2) + 0.01)
|
|
radius = (0.036 - 0.009 * v + 0.004 * math.sin(TAU * 6 * v + 1.5 * math.cos(a))) * cap
|
|
shoulder = 1 - math.exp(-v * 9)
|
|
x = sign * (0.164 + 0.113 * shoulder + 0.013 * math.sin(math.pi * v)) + radius * math.cos(a)
|
|
y = 0.256 + 0.063 * shoulder - 0.10 * v * v + radius * 0.86 * math.sin(a) + sign * 0.012 * v
|
|
z = 1.108 - 0.417 * v + 0.006 * math.sin(3 * a) * math.sin(v * math.pi)
|
|
return (x, y, z)
|
|
|
|
arm = surface("Jacket / shaped sleeve", 48, 72, lambda u, v: sleeve(u, v * 0.91), cotton, True)
|
|
arm.parent = chair
|
|
cuff = surface("Jacket / turned cuff", 48, 10, lambda u, v: sleeve(u, 0.91 + 0.09 * v), binding, True)
|
|
cuff.parent = chair
|
|
cuff.modifiers.new("Cuff thickness", "SOLIDIFY").thickness = 0.0028
|
|
stitch("Jacket / sleeve seam", [sleeve(0.12, j / 25) for j in range(26)], 0.001, seam)
|
|
for sign in (-1, 1):
|
|
|
|
def front(u, v):
|
|
column = 0.5 + sign * (0.012 + 0.30 * v + 0.079 * u * (0.35 + 0.65 * v))
|
|
x, y, z = panel(column, 0.09 + 0.30 * v)
|
|
return (x, y - 0.003 - 0.007 * math.sin(math.pi * u), z)
|
|
|
|
lapel = surface("Jacket / folded front facing", 16, 40, front, cotton)
|
|
lapel.parent = chair
|
|
stitch("Jacket / facing edge", [front(0.97, i / 24) for i in range(25)], 0.0008, seam)
|
|
collar = surface(
|
|
"Jacket / folded collar",
|
|
52,
|
|
9,
|
|
lambda u, v: (
|
|
(u - 0.5) * 0.246,
|
|
0.287 + 0.018 * v + 0.012 * math.cos(u * TAU),
|
|
1.083 - 0.040 * v + 0.013 * math.cos(u * TAU),
|
|
),
|
|
binding,
|
|
)
|
|
collar.parent = chair
|
|
for v in (0.09, 0.18, 0.27):
|
|
x, y, z = panel(0.505, v)
|
|
button = cylinder("Jacket / aged snap", (x, y - 0.001, z), 0.004, 0.002, brass)
|
|
button.rotation_euler.x = math.pi / 2
|
|
button.parent = chair
|
|
|
|
|
|
def tape_action():
|
|
scene = bpy.context.scene
|
|
old = scene.objects["Cassette / spilled magnetic tape"]
|
|
bpy.data.objects.remove(old, do_unlink=True)
|
|
base = Vector((-2.25, -1.435, 0.825))
|
|
ferrite = mat("Tape / polished ferric oxide", (0.155, 0.054, 0.015), 0.68, 0.235)
|
|
|
|
splice = mat("Tape / oxide splice leader", (0.65, 0.092, 0.027), 0.22, 0.37)
|
|
shell = bpy.data.materials["Cassette / smoky moulded shell"]
|
|
oxide = bpy.data.materials["Cassette / magnetic oxide"]
|
|
silver = bpy.data.materials["Cassette / nickel plated screw"]
|
|
ivory = bpy.data.materials["Cassette / nylon reels"]
|
|
for sign, outer in ((-1, 0.0205), (1, 0.014)):
|
|
for i in range(1, 14):
|
|
r = 0.0084 + (outer - 0.0084) * i / 14
|
|
ring = lathe("Cassette / wound oxide edge", [(r, 0.01199), (r + 0.000115, 0.01207)], oxide)
|
|
ring.location = base + Vector((sign * 0.023, 0.006, 0))
|
|
guide = cylinder(
|
|
"Cassette / tape guide", base + Vector((sign * 0.043, -0.017, 0.0126)), 0.0033, 0.005, ivory, 64
|
|
)
|
|
cylinder("Cassette / guide axle", guide.location + Vector((0, 0, 0.0026)), 0.0011, 0.0006, silver, 32)
|
|
cube(
|
|
"Cassette / moulded sidewall",
|
|
base + Vector((sign * 0.051, 0, 0.012)),
|
|
(0.002, 0.059, 0.004),
|
|
shell,
|
|
0.0007,
|
|
)
|
|
cube(
|
|
"Cassette / label rule",
|
|
base + Vector((0, -0.0135, 0.01165)),
|
|
(0.091, 0.00045, 0.00012),
|
|
splice,
|
|
0.00006,
|
|
)
|
|
lettering("Cassette / capacity", "A / C - 60", base + Vector((0.007, 0.027, 0.0103)), 0.0033, ivory)
|
|
for i in range(15):
|
|
cube(
|
|
"Cassette / moulded index",
|
|
base + Vector((-0.020 + i * 0.0028, 0.0225, 0.01015)),
|
|
(0.0004, 0.002 if i % 5 == 0 else 0.001, 0.0003),
|
|
ivory,
|
|
0.00007,
|
|
)
|
|
edge = area("Cassette / cool strip reflection", (-2.16, -1.32, 1.09), base, 0.78, (0.64, 0.83, 1), 0.16)
|
|
edge.data.size_y = 0.018
|
|
edge.visible_glossy = True
|
|
edge.data.specular_factor = 1
|
|
|
|
# Both tape guides are fixed. The take-up reel pulls the right strand
|
|
# in first. Beyond the cassette lip the bottom edge rests on the wood.
|
|
def ribbon(tension):
|
|
u = np.linspace(0, 1, 401)
|
|
bow = np.sin(math.pi * u)
|
|
x = -0.0463 * np.cos(math.pi * u) + 0.014 * tension * bow**2
|
|
depth = 0.081 * (1 - (0.52 + 0.34 * u) * tension)
|
|
y = -0.038 - depth * bow
|
|
x = np.r_[-0.0463, x, 0.0463]
|
|
y = np.r_[-0.017, y, -0.017]
|
|
fall = np.clip((-y - 0.037) / 0.019, 0, 1)
|
|
fall *= fall * (3 - 2 * fall)
|
|
z = 0.0142 * (1 - fall) + 0.00056 * fall
|
|
path = np.column_stack((x, y, z))
|
|
dist = np.r_[0, np.cumsum(np.linalg.norm(np.diff(path, axis=0), axis=1))]
|
|
# The splice is a piece of the tape: its distance from the braked
|
|
# supply side stays fixed as progressively more tape enters the reel.
|
|
lengths = np.r_[np.linspace(0, 0.109, 117), np.linspace(0.109, dist[-1], 85)[1:]]
|
|
centers = np.stack([np.interp(lengths, dist, path[:, i]) for i in range(3)], axis=1)
|
|
tangent = np.gradient(centers, axis=0)
|
|
tangent /= np.linalg.norm(tangent, axis=1)[:, None]
|
|
side = np.column_stack((tangent[:, 1], -tangent[:, 0], np.zeros(len(tangent))))
|
|
side /= np.linalg.norm(side, axis=1)[:, None]
|
|
upright = np.cross(side, tangent)
|
|
lean = 0.18 * np.sin(math.pi * lengths / dist[-1])
|
|
across = upright * np.cos(lean[:, None]) + side * np.sin(lean[:, None])
|
|
grid = (
|
|
np.array(base) + centers[None, :, :] + np.linspace(-0.001905, 0.001905, 5)[:, None, None] * across
|
|
)
|
|
return grid, dist[-1]
|
|
|
|
start, _ = ribbon(0)
|
|
band = surface(
|
|
"Cassette / loose tape on the bench",
|
|
200,
|
|
4,
|
|
lambda u, v: start[round(v * 4), round(u * 200)],
|
|
ferrite,
|
|
)
|
|
band.data.materials.append(splice)
|
|
for poly in band.data.polygons:
|
|
if 115 <= poly.index % 200 <= 119:
|
|
poly.material_index = 1
|
|
band.modifiers.new("Polyester backing", "SOLIDIFY").thickness = 0.000025
|
|
# Sample one continuous, eased pull. The spindle angle is measured from
|
|
# the same centreline as the visible strip, including between shape poses.
|
|
basis = band.shape_key_add(name="Slack on wood")
|
|
keys = band.data.shape_keys
|
|
keys.use_relative = False
|
|
basis.interpolation = "KEY_LINEAR"
|
|
turns = []
|
|
initial_length = np.linalg.norm(np.diff(start[2], axis=0), axis=1).sum()
|
|
for frame in range(49, 122):
|
|
phase = (frame - 49) / 72
|
|
grid, _ = ribbon(phase**2 * (3 - 2 * phase))
|
|
key = basis if frame == 49 else band.shape_key_add(name=f"Tape at frame {frame}")
|
|
key.interpolation = "KEY_LINEAR"
|
|
key.data.foreach_set("co", grid.astype(np.float32).ravel())
|
|
keys.eval_time = key.frame
|
|
keys.keyframe_insert("eval_time", frame=frame)
|
|
length = np.linalg.norm(np.diff(grid[2], axis=0), axis=1).sum()
|
|
turns.append((frame, (initial_length - length) / 0.014))
|
|
# The loose corner catches the draught a few frames before the tape.
|
|
paper = scene.objects["Bench / marked signal dropout"]
|
|
rest = paper.shape_key_add(name="On the bench")
|
|
corner = paper.shape_key_add(name="Free corner lifts in draught")
|
|
xs = [v.co.x for v in rest.data]
|
|
ys = [v.co.y for v in rest.data]
|
|
left, bottom = min(xs), min(ys)
|
|
width, height = max(xs) - left, max(ys) - bottom
|
|
for source, key in zip(rest.data, corner.data):
|
|
u = (source.co.x - left) / width
|
|
v = (source.co.y - bottom) / height
|
|
bend = u**2.5 * v**2
|
|
key.co.z += 0.022 * bend
|
|
key.co.x -= 0.006 * bend
|
|
for f, value in ((1, 0), (48, 0), (57, 0.62), (64, 0.32), (77, 1), (89, 0.18), (97, 0.33), (115, 0)):
|
|
corner.value = value
|
|
corner.keyframe_insert("value", frame=f)
|
|
teeth = [o for o in scene.objects if o.name.startswith("Cassette / spindle tooth")]
|
|
for x in (-0.023, 0.023):
|
|
hub = bpy.data.objects.new("Cassette / motor spindle", None)
|
|
scene.collection.objects.link(hub)
|
|
hub.location = base + Vector((x, 0.006, 0))
|
|
scene.view_layers[0].update()
|
|
for cog in teeth:
|
|
if abs(cog.location.x - hub.location.x) < 0.01:
|
|
matrix = cog.matrix_world.copy()
|
|
cog.parent = hub
|
|
cog.matrix_world = matrix
|
|
for f, a in turns:
|
|
hub.rotation_euler.z = a if x > 0 else 0
|
|
hub.keyframe_insert("rotation_euler", frame=f)
|
|
for o in scene.objects:
|
|
if o.name.startswith("Workbench / light across tape"):
|
|
o.data.energy = 3.1
|
|
|
|
|
|
def sequence(material, filepath, start, count):
|
|
shader = material.node_tree.nodes.get("Principled BSDF")
|
|
tex = next((n for n in material.node_tree.nodes if n.type == "TEX_IMAGE"), None)
|
|
if tex is None:
|
|
tex = material.node_tree.nodes.new("ShaderNodeTexImage")
|
|
tex.image = bpy.data.images.load(str(filepath), check_existing=True)
|
|
tex.image.source = "SEQUENCE"
|
|
tex.image.filepath = "//" + filepath.parent.name + "/" + filepath.name
|
|
tex.image_user.frame_start = start
|
|
tex.image_user.frame_duration = count
|
|
tex.image_user.use_auto_refresh = True
|
|
material.node_tree.links.new(tex.outputs["Color"], shader.inputs["Emission Color"])
|
|
return shader
|
|
|
|
|
|
def cinematography():
|
|
scene = bpy.context.scene
|
|
for m in list(scene.timeline_markers):
|
|
if m.frame in (1, 50, 223):
|
|
cam = m.camera
|
|
scene.timeline_markers.remove(m)
|
|
bpy.data.objects.remove(cam, do_unlink=True)
|
|
film_camera(
|
|
"01 / Through the door",
|
|
[
|
|
(1, (0.35, -5.82, 1.38), (0.18, -3.71, 1.47), -1, 34),
|
|
(18, (0.56, -4.58, 1.43), (0.47, -3.57, 1.38), -1, 31),
|
|
(34, (0.78, -3.57, 1.46), (-0.35, -0.28, 1.20), -2, 26),
|
|
(49, (0.25, -2.71, 1.48), (-0.56, -0.65, 1.08), 0, 24),
|
|
],
|
|
7,
|
|
)
|
|
film_camera(
|
|
"02 / Ferric oxide and red splice",
|
|
[
|
|
(50, (-2.16, -1.68, 0.995), (-2.25, -1.48, 0.846), -5, 50),
|
|
(65, (-2.21, -1.647, 0.989), (-2.25, -1.506, 0.838), -3, 48),
|
|
(82, (-2.295, -1.685, 0.986), (-2.249, -1.513, 0.836), 0, 48),
|
|
(98, (-2.335, -1.68, 0.977), (-2.25, -1.503, 0.837), 3, 48),
|
|
(121, (-2.37, -1.74, 1.022), (-2.25, -1.44, 0.842), 2, 48),
|
|
],
|
|
18,
|
|
)
|
|
# Cut on the ratchet tick. The take-up reel turns in the same part of
|
|
# the frame as the aluminium end of the rolling can in the next shot.
|
|
reel_camera = film_camera(
|
|
"02B / Take-up spindle",
|
|
[
|
|
(104, (-2.269, -1.504, 0.921), (-2.237, -1.438, 0.838), -29, 68),
|
|
(112, (-2.256, -1.510, 0.906), (-2.239, -1.437, 0.839), -47, 66),
|
|
(121, (-2.246, -1.516, 0.897), (-2.238, -1.439, 0.840), -56, 48),
|
|
],
|
|
12,
|
|
)
|
|
reel_camera.data.clip_start = 0.012
|
|
reel_center = Vector((-2.227, -1.429, 0.840))
|
|
for frame, u, v in ((104, 0.54, 0.53), (112, 0.61, 0.50), (121, 0.685, 0.48)):
|
|
scene.frame_set(frame)
|
|
point = world_to_camera_view(scene, reel_camera, reel_center)
|
|
width = point.z * reel_camera.data.sensor_width / reel_camera.data.lens
|
|
offset = Vector(((point.x - u) * width, (point.y - v) * width * 9 / 16, 0))
|
|
reel_camera.location += reel_camera.rotation_quaternion @ offset
|
|
reel_camera.keyframe_insert("location", frame=frame)
|
|
# Move from the latch to the full bank before the first paddle rises.
|
|
old = next(m for m in scene.timeline_markers if m.frame == 173)
|
|
old_camera = old.camera
|
|
scene.timeline_markers.remove(old)
|
|
bpy.data.objects.remove(old_camera, do_unlink=True)
|
|
film_camera(
|
|
"05 / Release and five spring flags",
|
|
[
|
|
(173, (12.195, -0.234, 0.146), (12.083, -0.052, 0.047), -4, 53),
|
|
(185, (12.086, -0.317, 0.16), (12.01, -0.008, 0.076), -2, 43),
|
|
(199, (12.028, -0.351, 0.154), (12, 0.001, 0.088), 0, 40),
|
|
(232, (11.995, -0.339, 0.143), (11.997, -0.002, 0.090), 0, 40),
|
|
(254, (11.994, -0.331, 0.140), (11.997, -0.002, 0.090), 0, 40),
|
|
],
|
|
8,
|
|
)
|
|
for i, letter in enumerate("EBLAN"):
|
|
hinge = scene.objects["Flag / hinge " + letter]
|
|
hinge.animation_data_clear()
|
|
release = 185 + 9 * i
|
|
for f, angle in (
|
|
(1, 0),
|
|
(release, 0),
|
|
(release + 6, 19),
|
|
(release + 15, 78),
|
|
(release + 19, 94),
|
|
(release + 23, 86),
|
|
(release + 27, 88),
|
|
):
|
|
hinge.rotation_euler.x = math.radians(angle)
|
|
hinge.keyframe_insert("rotation_euler", frame=f)
|
|
film_camera(
|
|
"06 / Cold glass",
|
|
[
|
|
(255, (0.065, -1.16, 1.13), (-0.09, -0.115, 1.085), 0, 46),
|
|
(278, (0.025, -0.91, 1.117), (-0.09, -0.115, 1.084), 0, 48),
|
|
(309, (-0.06, -0.69, 1.098), (-0.09, -0.115, 1.084), 0, 52),
|
|
(332, (-0.089, -0.61, 1.087), (-0.09, -0.115, 1.084), 0, 52),
|
|
],
|
|
6.3,
|
|
)
|
|
screen = scene.objects.get("Green screen / reflected on keys")
|
|
if screen:
|
|
screen.data.animation_data_clear()
|
|
for f, v in ((1, 0), (263, 0), (267, 1.1), (275, 3.3), (293, 0.8), (321, 5), (384, 5)):
|
|
screen.data.energy = v
|
|
screen.data.keyframe_insert("energy", frame=f)
|
|
material = bpy.data.materials["Original terminal / real curved phosphor glass"]
|
|
shader = sequence(material, SOURCE / "screen-v8/screen_0001.png", 1, 384)
|
|
shader.inputs["Emission Strength"].default_value = 2.2
|
|
# Orthographic final plate in the editable scene, using a pure emission
|
|
# surface so it is independent of the workshop lighting.
|
|
bpy.ops.mesh.primitive_plane_add(size=2, location=(25, 0, 10))
|
|
plane = bpy.context.object
|
|
plane.name = "Master / studio signature"
|
|
plane.scale = (1, 0.5625, 1)
|
|
mark = bpy.data.materials.new("Master / output phosphor")
|
|
mark.use_nodes = True
|
|
mark.node_tree.nodes.clear()
|
|
out = mark.node_tree.nodes.new("ShaderNodeOutputMaterial")
|
|
em = mark.node_tree.nodes.new("ShaderNodeEmission")
|
|
tex = mark.node_tree.nodes.new("ShaderNodeTexImage")
|
|
tex.image = bpy.data.images.load(str(SOURCE / "signature-v8/signature_0333.png"))
|
|
tex.image.source = "SEQUENCE"
|
|
tex.image.filepath = "//signature-v8/signature_0333.png"
|
|
tex.image_user.frame_offset = 332
|
|
tex.image_user.frame_duration = 52
|
|
tex.image_user.frame_start = 333
|
|
tex.image_user.use_auto_refresh = True
|
|
mark.node_tree.links.new(tex.outputs["Color"], em.inputs["Color"])
|
|
mark.node_tree.links.new(em.outputs[0], out.inputs["Surface"])
|
|
plane.data.materials.append(mark)
|
|
cam_data = bpy.data.cameras.new("Clean studio signature")
|
|
cam_data.type = "ORTHO"
|
|
cam_data.ortho_scale = 2
|
|
cam = bpy.data.objects.new("07 / Studio master", cam_data)
|
|
scene.collection.objects.link(cam)
|
|
for frame, zoom, y in ((333, 1.54, 0.140), (345, 1.56, 0.133), (361, 2, 0)):
|
|
cam.location = (25, y, 11)
|
|
cam.keyframe_insert("location", frame=frame)
|
|
cam_data.ortho_scale = zoom
|
|
cam_data.keyframe_insert("ortho_scale", frame=frame)
|
|
scene.timeline_markers.new(cam.name, frame=333).camera = cam
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("--build", action="store_true")
|
|
parser.add_argument("--proof", type=int, nargs="+")
|
|
parser.add_argument("--animation", action="store_true")
|
|
parser.add_argument("--start", type=int, default=1)
|
|
parser.add_argument("--end", type=int, default=384)
|
|
args = parser.parse_args(sys.argv[sys.argv.index("--") + 1 :] if "--" in sys.argv else [])
|
|
if not 1 <= args.start <= args.end <= 384:
|
|
parser.error("render range must be within frames 1 through 384")
|
|
path = SOURCE / "eblan-workshop-v8.blend"
|
|
bpy.ops.wm.open_mainfile(filepath=str(SOURCE / "eblan-workshop-v7.blend" if args.build else path))
|
|
scene = bpy.context.scene
|
|
if args.build:
|
|
desk_props()
|
|
jacket()
|
|
tape_action()
|
|
cinematography()
|
|
set_render(scene)
|
|
scene.frame_end = 384
|
|
scene.cycles.samples = 72
|
|
scene.cycles.adaptive_min_samples = 20
|
|
scene.render.filepath = "//../../../build/cinematic-v8/frames/frame_"
|
|
WORK.mkdir(parents=True, exist_ok=True)
|
|
if args.build:
|
|
scene.frame_set(82)
|
|
bpy.context.preferences.filepaths.save_version = 0
|
|
bpy.ops.wm.save_as_mainfile(filepath=str(path))
|
|
if args.proof:
|
|
scene.cycles.samples = 28
|
|
scene.render.resolution_percentage = 65
|
|
for f in args.proof:
|
|
scene.frame_set(f)
|
|
scene.render.filepath = str(WORK / f"proof-{f:04}.png")
|
|
bpy.ops.render.render(write_still=True)
|
|
if args.animation:
|
|
(WORK / "frames").mkdir(exist_ok=True)
|
|
scene.frame_start = args.start
|
|
scene.frame_end = args.end
|
|
scene.render.filepath = str(WORK / "frames/frame_")
|
|
bpy.ops.render.render(animation=True)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|