"""Append the approved model as an isolated, editable chromatic paint edition. Run in Blender with __file__ set to this script. Open projects are never saved. """ import bpy from pathlib import Path root_path = Path(__file__).resolve().parents[3] source = root_path / 'assets/blender/expressway/nightdrive-expressway.blend' with bpy.data.libraries.load(str(source), link=False) as (available, loaded): loaded.scenes = ['Midnight Expressway'] scene = loaded.scenes[0] scene.name = 'Chromatic Nightdrive' bpy.context.window.scene = scene materials = {m.name.split('.')[0]: m for o in scene.objects if o.type in {'MESH','CURVE'} for m in o.data.materials} # Linear RGB: candy-rose enamel, violet shoulders, champagne machining, # sapphire glass and dark plum mechanical recesses. Geometry stays approved. for name, color, metallic, roughness in [ ('M_Body_Gunmetal', (0.46, 0.023, 0.145, 1), 0.68, 0.24), ('M_Body_Haunch', (0.36, 0.035, 0.38, 1), 0.72, 0.22), ('M_Lower_Graphite', (0.029, 0.01, 0.047, 1), 0.57, 0.36), ('M_Wheel', (0.60, 0.40, 0.25, 1), 0.90, 0.23), ('M_Glass_Smoke', (0.013, 0.024, 0.082, 1), 0.38, 0.14), ]: material = materials[name] bsdf = material.node_tree.nodes.get('Principled BSDF') bsdf.inputs['Base Color'].default_value = color material.diffuse_color = color bsdf.inputs['Metallic'].default_value = metallic bsdf.inputs['Roughness'].default_value = roughness if 'Body' in name: bsdf.inputs['Coat Weight'].default_value = 0.58 bsdf.inputs['Coat Roughness'].default_value = 0.16 bsdf.inputs['Emission Color'].default_value = (0.035, 0.002, 0.015, 1) bsdf.inputs['Emission Strength'].default_value = 0.16 for obj in scene.objects: if obj.type == 'LIGHT' and obj.name.startswith('LOOKDEV'): if 'Key' in obj.name: obj.data.color = (0.42, 0.70, 1.0) if 'Rim' in obj.name: obj.data.color = (1.0, 0.12, 0.48) if 'Top' in obj.name: obj.data.color = (1.0, 0.73, 0.65) scene.world = scene.world.copy() if scene.world else None if scene.world: scene.world.color = (0.045, 0.018, 0.07) output = root_path / 'assets/blender/chromatic/nightdrive-chromatic.blend' bpy.data.libraries.write(str(output), {scene}, fake_user=True, compress=True) print('AUTHORED', scene.name, len(scene.objects), 'objects', output)