"""Render the v010 study views from a saved v010 model. blender --background MODEL.blend --python render_views.py -- --out DIR [--percent 60] [--samples 48] [--only NAME] Cycles/Metal on macOS. Captions and FAST proxies are excluded; DETAIL renders. """ import argparse import bpy import sys from pathlib import Path from mathutils import Vector p = argparse.ArgumentParser() p.add_argument('--out', required=True) p.add_argument('--percent', type=int, default=60) p.add_argument('--samples', type=int, default=48) p.add_argument('--only') a = p.parse_args(sys.argv[sys.argv.index('--') + 1:]) out = Path(a.out).resolve() out.mkdir(parents=True, exist_ok=True) s = bpy.context.scene detail = bpy.data.collections['DETAIL - full geometry for renders'] fast = bpy.data.collections['00 FAST TOUR - lightweight viewport'] detail.hide_viewport = False fast.hide_viewport = True for ob in bpy.data.collections['22 PLAY - guided camera tour'].objects: if ob.type == 'FONT': ob.hide_render = True s.render.engine = 'CYCLES' s.render.resolution_x, s.render.resolution_y = 2560, 1440 s.render.resolution_percentage = a.percent s.cycles.samples = a.samples s.cycles.use_denoising = True prefs = bpy.context.preferences.addons['cycles'].preferences prefs.compute_device_type = 'METAL' prefs.get_devices() for d in prefs.devices: d.use = d.type == 'METAL' s.cycles.device = 'GPU' # name: (location, target, lens or None for ortho, ortho_scale) views = { 'v010-pattern-overview': ((-6, 64, 50), (-1, 2, 0), None, 62), 'v010-common-room-alcoves': ((-5.3, 2.75, 2.65), (3.4, -3.6, 2.2), 18, None), 'v010-study-alcove': ((3.3, -0.35, 2.45), (3.4, -4.2, 1.75), 21, None), 'v010-verandah-link': ((-1.5, 13.5, 3.0), (-6.2, 2.6, 2.6), 22, None), 'v010-window-seat-alcove': ((2.6, -.6, 2.35), (-7.0, 1.6, 1.9), 22, None), 'v010-childrens-realm': ((-17.0, 11.2, 4.4), (-12.0, 2.4, 2.0), 22, None), 'v010-elder-cottage': ((3.2, 18.6, 3.4), (13.0, 11.8, 1.0), 26, None), 'v010-entrance-arbour': ((3.6, -14.5, 2.4), (6.0, -7.9, 1.7), 28, None), } for name, (loc, target, lens, ortho) in views.items(): if a.only and a.only != name: continue data = bpy.data.cameras.new(name) cam = bpy.data.objects.new(name, data) s.collection.objects.link(cam) cam.location = loc cam.rotation_euler = (Vector(target) - Vector(loc)).to_track_quat('-Z', 'Y').to_euler() data.clip_end = 1000 if lens is None: data.type = 'ORTHO' data.ortho_scale = ortho else: data.lens = lens s.camera = cam s.render.filepath = str(out / (name + '.png')) bpy.ops.render.render(write_still=True) print('RENDERED', s.render.filepath, flush=True)