# Final beauty renders (textured, original materials): full front/40deg/back, chest, hip. # blender --background --python 09_beauty.py -- import bpy, sys, math, os from mathutils import Vector, Euler argv = sys.argv[sys.argv.index("--") + 1:] BLEND, OUT = argv[0], argv[1] os.makedirs(OUT, exist_ok=True) bpy.ops.wm.open_mainfile(filepath=BLEND) for o in list(bpy.data.objects): if o.type in ('LIGHT', 'CAMERA'): bpy.data.objects.remove(o, do_unlink=True) sc = bpy.context.scene sc.render.engine = 'BLENDER_EEVEE' sc.render.resolution_x = sc.render.resolution_y = 1200 wd = bpy.data.worlds.new("w") wd.use_nodes = True wd.node_tree.nodes["Background"].inputs[0].default_value = (0.22, 0.22, 0.24, 1) sc.world = wd def sun(rot, e): ld = bpy.data.lights.new("s", 'SUN') ld.energy = e ld.use_shadow = False lo = bpy.data.objects.new("s", ld) lo.rotation_euler = rot bpy.context.collection.objects.link(lo) sun(Euler((math.radians(55), 0, math.radians(-35))), 2.2) sun(Euler((math.radians(120), 0, math.radians(150))), 1.0) sun(Euler((math.radians(85), 0, math.radians(35))), 0.8) cam = bpy.data.cameras.new("c") cam.lens = 70 cob = bpy.data.objects.new("c", cam) bpy.context.collection.objects.link(cob) sc.camera = cob views = [ ("full_front", Vector((0.0, -2.05, 0.50)), Euler((math.radians(90), 0, 0))), ("full_40", Vector((-1.35, -1.55, 0.50)), Euler((math.radians(90), 0, math.radians(-41)))), ("full_back", Vector((0.0, 2.05, 0.50)), Euler((math.radians(90), 0, math.radians(180)))), ("chest", Vector((0.0, -0.85, 0.70)), Euler((math.radians(90), 0, 0))), ("hip", Vector((0.0, -0.85, 0.46)), Euler((math.radians(90), 0, 0))), ] for name, loc, rot in views: cob.location = loc cob.rotation_euler = rot sc.render.filepath = os.path.join(OUT, f"{name}.png") bpy.ops.render.render(write_still=True) print(f"rendered {name}", flush=True) print("BEAUTY_DONE")