From 2edd24a4e6c5b77ddca88cbddaa581edf0d89e8b Mon Sep 17 00:00:00 2001 From: florianfelix Date: Fri, 29 Sep 2017 17:11:31 +0200 Subject: Fix T51503 Added support for Cycles image textures --- io_online_sketchfab/pack_for_export.py | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) (limited to 'io_online_sketchfab') diff --git a/io_online_sketchfab/pack_for_export.py b/io_online_sketchfab/pack_for_export.py index 16d38cca..e9fbde72 100644 --- a/io_online_sketchfab/pack_for_export.py +++ b/io_online_sketchfab/pack_for_export.py @@ -61,17 +61,31 @@ def prepare_assets(export_settings): for ob in bpy.data.objects: if ob.type == 'MESH': + for mat_slot in ob.material_slots: - if not mat_slot.material: - continue - for tex_slot in mat_slot.material.texture_slots: - if not tex_slot: + #CYCLES RENDER + if bpy.context.scene.render.engine == 'CYCLES': + if not mat_slot.material: + continue + if not mat_slot.material.node_tree: continue - tex = tex_slot.texture - if tex.type == 'IMAGE': - image = tex.image - if image is not None: - images.add(image) + imgnodes = [n for n in mat_slot.material.node_tree.nodes if n.type == 'TEX_IMAGE'] + for node in imgnodes: + if node.image is not None: + images.add(node.image) + #BLENDER RENDER + else: + if not mat_slot.material: + continue + for tex_slot in mat_slot.material.texture_slots: + if not tex_slot: + continue + tex = tex_slot.texture + if tex.type == 'IMAGE': + image = tex.image + if image is not None: + images.add(image) + if ((export_settings['models'] == 'SELECTION' and ob.type == 'MESH') or (export_settings['lamps'] == 'SELECTION' and ob.type == 'LAMP')): -- cgit v1.2.3