import bpy,math
from mathutils import Vector
R='/root/fal-author/le-mans-prototype-v1/'
bpy.ops.wm.open_mainfile(filepath=R+'source.blend')
o=bpy.data.objects['Body'];bpy.ops.object.select_all(action='DESELECT');o.select_set(True);bpy.context.view_layer.objects.active=o
bpy.ops.mesh.customdata_custom_splitnormals_clear();bpy.ops.object.shade_smooth_by_angle(angle=math.radians(25),keep_sharp_edges=False)
m=o.modifiers.new('Final weighted normals','WEIGHTED_NORMAL');m.keep_sharp=True;m.weight=50;bpy.ops.object.modifier_apply(modifier=m.name)
s=bpy.context.scene;s.cycles.samples=20;s.render.resolution_x=1280;s.render.resolution_y=720
p=bpy.context.preferences.addons['cycles'].preferences;p.compute_device_type='OPTIX';p.get_devices()
for d in p.devices:d.use=d.type!='CPU'
s.render.filepath=R+'weighted-hero.png';bpy.ops.render.render(write_still=True)
c=s.camera;c.location=(4.9,7.1,2.7);c.rotation_euler=(Vector((0,0,.48))-c.location).to_track_quat('-Z','Y').to_euler();s.render.filepath=R+'weighted-rear.png';bpy.ops.render.render(write_still=True)
