"""GRASS CUTTER crew remaster, stage 4: ArtSource/Blender/remaster/crew/Crew_Review.blend. All ten remastered characters in a row (collection "Remastered", appended from the per-character .blends), each with its name on the floor; the game's current models, imported from Assets/Art/Models with their current maps, stand right behind each one in "Originals" (hidden: switch its eye on to compare). Soft studio light, a floor, a camera on the line-up, and every 3D view in Material Preview with the scene's lights. Run: blender -b --factory-startup --python crew_review.py --python-exit-code 1 """ import sys, os, math HERE = os.path.dirname(os.path.abspath(__file__)) BASE = os.path.normpath(os.path.join(HERE, "..")) ROOT = os.path.normpath(os.path.join(BASE, "..", "..", "..", "..")) import bpy from mathutils import Vector, Quaternion ORDER = ("hank", "otis", "lin", "rustam", "marcus", "gus", "wade", "kenji", "boss", "assistant") DIRECTOR = ("boss", "assistant") GAME_TEX = os.path.join(ROOT, "Assets", "Art", "Textures") STEP = 0.9 # metres between characters BEHIND = 1.1 # the original stands this far behind its remaster def sm_name(n): return ("SM_Dir_" if n in DIRECTOR else "SM_Crew_") + n.capitalize() def title(n): return {"boss": "The Director", "assistant": "Assistant"}.get(n, n.capitalize()) def mat_flat(name, rgb, emit=False): m = bpy.data.materials.get(name) or bpy.data.materials.new(name) m.use_nodes = True nt = m.node_tree b = nt.nodes.get("Principled BSDF") b.inputs["Base Color"].default_value = (*rgb, 1) b.inputs["Roughness"].default_value = 0.9 if emit: b.inputs["Emission Color"].default_value = (*rgb, 1) b.inputs["Emission Strength"].default_value = 1.0 return m def text(body, at, size, col, mat): cu = bpy.data.curves.new("Label_" + body, "FONT") cu.body = body cu.size = size cu.align_x = "CENTER" cu.extrude = 0.002 o = bpy.data.objects.new("Label_" + body, cu) col.objects.link(o) o.location = at o.rotation_euler = (math.radians(90), 0, 0) # standing up, facing the camera o.data.materials.append(mat) return o def soften(mats): for m in mats: if not m or not m.node_tree: continue b = next((n for n in m.node_tree.nodes if n.type == "BSDF_PRINCIPLED"), None) if b: b.inputs["Roughness"].default_value = 0.75 if "Specular IOR Level" in b.inputs: b.inputs["Specular IOR Level"].default_value = 0.25 def append_remaster(n, col): path = os.path.join(BASE, sm_name(n) + ".blend") with bpy.data.libraries.load(path, link=False) as (src, dst): dst.objects = list(src.objects) keep = [] for o in dst.objects: if o is None: continue drop = (o.type in ("LIGHT", "CAMERA", "FONT") or o.name.endswith("_Old") or o.name.startswith("lbl")) if drop: bpy.data.objects.remove(o) continue col.objects.link(o) keep.append(o) rig = next(o for o in keep if o.type == "ARMATURE") for o in keep: o.name = o.name.split(".")[0] + "_" + n.capitalize() return rig, keep def import_original(n, col): before = set(bpy.data.objects) bpy.ops.import_scene.fbx(filepath=os.path.join(ROOT, "Assets", "Art", "Models", sm_name(n) + ".fbx")) new = [o for o in bpy.data.objects if o not in before] for o in new: for c in list(o.users_collection): c.objects.unlink(o) col.objects.link(o) o.name = o.name.split(".")[0] + "_" + n.capitalize() + "_Orig" for o in new: if o.type == "MESH": for m in o.data.materials: if m and m.node_tree: for nd in m.node_tree.nodes: if nd.type == "TEX_IMAGE" and nd.image: p = os.path.join(GAME_TEX, os.path.basename(nd.image.filepath)) if os.path.exists(p): nd.image.filepath = p nd.image.reload() soften(o.data.materials) return next(o for o in new if o.type == "ARMATURE"), new def main(): bpy.ops.wm.read_factory_settings(use_empty=False) for o in list(bpy.data.objects): bpy.data.objects.remove(o) sc = bpy.context.scene sc.name = "Crew Review" rem = bpy.data.collections.new("Remastered") org = bpy.data.collections.new("Originals") lab = bpy.data.collections.new("Labels") stg = bpy.data.collections.new("Stage") for c in (rem, org, lab, stg): sc.collection.children.link(c) ink = mat_flat("M_LabelInk", (0.03, 0.035, 0.05)) ink2 = mat_flat("M_LabelInkOrig", (0.35, 0.12, 0.08)) x0 = -STEP * (len(ORDER) - 1) / 2 for i, n in enumerate(ORDER): x = x0 + i * STEP c = bpy.data.collections.new(sm_name(n)) rem.children.link(c) rig, objs = append_remaster(n, c) rig.location = (x, 0, 0) co = bpy.data.collections.new(sm_name(n) + "_Original") org.children.link(co) rig_o, objs_o = import_original(n, co) rig_o.location = (x, BEHIND, 0) t = text(title(n), (x, -0.6, 0.015), 0.09, lab, ink) t2 = text(title(n) + " (game now)", (x, BEHIND - 0.6, 0.015), 0.06, org, ink2) print(" placed", n, flush=True) # the stage: a floor, soft light bpy.ops.mesh.primitive_circle_add(vertices=96, radius=STEP * len(ORDER) * 0.75, fill_type="NGON", location=(0, 0.4, 0)) floor = bpy.context.active_object floor.name = "Floor" floor.scale.y = 0.45 for c in list(floor.users_collection): c.objects.unlink(floor) stg.objects.link(floor) floor.data.materials.append(mat_flat("M_Floor", (0.3, 0.34, 0.33))) w = bpy.data.worlds.new("Studio") sc.world = w w.use_nodes = True w.node_tree.nodes["Background"].inputs[0].default_value = (0.62, 0.68, 0.74, 1) w.node_tree.nodes["Background"].inputs[1].default_value = 0.9 for nm, kind, en, rot, ang in (("Key", "SUN", 2.6, (52, 8, -38), 18), ("Rim", "SUN", 1.3, (35, 0, 160), 10)): ld = bpy.data.lights.new(nm, kind) ld.energy = en ld.angle = math.radians(ang) lo = bpy.data.objects.new(nm, ld) stg.objects.link(lo) lo.rotation_euler = [math.radians(a) for a in rot] ld = bpy.data.lights.new("Fill", "AREA") ld.energy = 450 ld.size = 6 ld.shape = "RECTANGLE" ld.size_y = 2 lo = bpy.data.objects.new("Fill", ld) stg.objects.link(lo) lo.location = (-1.5, -5, 2.5) lo.rotation_euler = (Vector((0, 0, 0.6)) - lo.location).to_track_quat("-Z", "Y").to_euler() # the camera on the line-up cd = bpy.data.cameras.new("ReviewCam") cd.lens = 38 cam = bpy.data.objects.new("ReviewCam", cd) stg.objects.link(cam) cam.location = (0, -11.2, 1.55) cam.rotation_euler = (Vector((0, 0, 0.62)) - cam.location).to_track_quat("-Z", "Y").to_euler() sc.camera = cam sc.render.engine = "BLENDER_EEVEE" sc.render.resolution_x, sc.render.resolution_y = 2400, 900 sc.view_settings.view_transform = "Standard" # Originals hidden by default (eye off), not rendered vl = bpy.context.view_layer vl.layer_collection.children["Originals"].hide_viewport = True org.hide_render = True # every 3D view: Material Preview with the scene's lights, looking at the line-up for scr in bpy.data.screens: for area in scr.areas: if area.type != "VIEW_3D": continue for sp in area.spaces: if sp.type != "VIEW_3D": continue sp.shading.type = "MATERIAL" sp.shading.use_scene_lights = True sp.shading.use_scene_world = True sp.overlay.show_relationship_lines = False sp.overlay.show_bones = False r3 = sp.region_3d r3.view_perspective = "PERSP" r3.view_location = (0, 0, 0.62) r3.view_rotation = cam.rotation_euler.to_quaternion() r3.view_distance = (cam.location - Vector((0, 0, 0.62))).length out = os.path.join(BASE, "Crew_Review.blend") bpy.ops.wm.save_as_mainfile(filepath=out, check_existing=False) bpy.ops.file.make_paths_relative() bpy.ops.wm.save_mainfile() # a still of the line-up, and one with the originals shown behind sc.render.filepath = os.path.join(BASE, "previews", "Crew_Review.png") bpy.ops.render.render(write_still=True) print("saved", out, flush=True) if __name__ == "__main__": main()