From 7a63ecf80573cd59ab64b51a7c680421efcc656a Mon Sep 17 00:00:00 2001 From: Vilem Duha Date: Sat, 10 Jul 2021 11:43:40 +0200 Subject: BlenderKit: Fix autothumb for materials - scale wasn't applied on the preview object This caused displacement to render incorrectly sized on scaled preview objects support more objects for drag-drop materials don't show ratings for private objects --- blenderkit/autothumb_material_bg.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'blenderkit/autothumb_material_bg.py') diff --git a/blenderkit/autothumb_material_bg.py b/blenderkit/autothumb_material_bg.py index b5d2651b..50e8aa4b 100644 --- a/blenderkit/autothumb_material_bg.py +++ b/blenderkit/autothumb_material_bg.py @@ -82,16 +82,23 @@ if __name__ == "__main__": bpy.data.materials["bg checker colorable"].node_tree.nodes['input_level'].outputs['Value'].default_value \ = data['thumbnail_background_lightness'] tscale = data["thumbnail_scale"] - bpy.context.view_layer.objects['scaler'].scale = (tscale, tscale, tscale) + scaler = bpy.context.view_layer.objects['scaler'] + scaler.scale = (tscale, tscale, tscale) + utils.activate(scaler) + bpy.ops.object.transform_apply(location=False, rotation=False, scale=True) + bpy.context.view_layer.update() for ob in bpy.context.visible_objects: if ob.name[:15] == 'MaterialPreview': + utils.activate(ob) + bpy.ops.object.transform_apply(location=False, rotation=False, scale=True) + ob.material_slots[0].material = mat ob.data.use_auto_texspace = False - ob.data.texspace_size.x = 1 / tscale - ob.data.texspace_size.y = 1 / tscale - ob.data.texspace_size.z = 1 / tscale + ob.data.texspace_size.x = 1 #/ tscale + ob.data.texspace_size.y = 1 #/ tscale + ob.data.texspace_size.z = 1 #/ tscale if data["adaptive_subdivision"] == True: ob.cycles.use_adaptive_subdivision = True @@ -130,6 +137,8 @@ if __name__ == "__main__": bpy.context.scene.render.filepath = data['thumbnail_path'] bg_blender.progress('rendering thumbnail') + # bpy.ops.wm.save_as_mainfile(filepath='C:/tmp/test.blend') + # fal render_thumbnails() if data.get('upload_after_render') and data.get('asset_data'): bg_blender.progress('uploading thumbnail') -- cgit v1.2.3