diff options
author | Vilem Duha <vilem.duha@gmail.com> | 2021-07-10 12:43:40 +0300 |
---|---|---|
committer | Vilem Duha <vilem.duha@gmail.com> | 2021-07-12 21:46:00 +0300 |
commit | 7a63ecf80573cd59ab64b51a7c680421efcc656a (patch) | |
tree | 7f6b5828516a3d645ae9ef722e07c5ed2e11a4e5 /blenderkit/autothumb_material_bg.py | |
parent | 69f875e1171ae83b6737fc988411afd14c8c4282 (diff) |
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
Diffstat (limited to 'blenderkit/autothumb_material_bg.py')
-rw-r--r-- | blenderkit/autothumb_material_bg.py | 17 |
1 files changed, 13 insertions, 4 deletions
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') |