diff options
author | Kalle-Samuli Riihikoski <haikalle@gmail.com> | 2019-03-07 02:18:31 +0300 |
---|---|---|
committer | Kalle-Samuli Riihikoski <haikalle@gmail.com> | 2019-03-07 02:19:07 +0300 |
commit | 92c66013256f8de3effd0be3f77f156abfdf20f1 (patch) | |
tree | 8715dbc91733c19a2af60dfbf5408df555102152 /io_coat3D/tex.py | |
parent | 5c8de035999e2972bf611bf3765deaa9eb5720c8 (diff) |
Fixed 3D-Coat -> Blender workflow
Diffstat (limited to 'io_coat3D/tex.py')
-rw-r--r-- | io_coat3D/tex.py | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/io_coat3D/tex.py b/io_coat3D/tex.py index 5b70c0b4..1d029d21 100644 --- a/io_coat3D/tex.py +++ b/io_coat3D/tex.py @@ -250,10 +250,10 @@ def readtexturefolder(objekti, mat_list, texturelist, is_new, udim_textures): #r objekti.coat3D.applink_3b_path = line export_file.close() coat3D.remove_path = True - createnodes(index_mat, texcoat, create_group_node, tile_list, objekti) + createnodes(index_mat, texcoat, create_group_node, tile_list, objekti, ind, is_new) -def createnodes(active_mat,texcoat, create_group_node, tile_list, objekti): # Cretes new nodes and link textures into them +def createnodes(active_mat,texcoat, create_group_node, tile_list, objekti, ind, is_new): # Cretes new nodes and link textures into them bring_color = True # Meaning of these is to check if we can only update textures or do we need to create new nodes bring_metalness = True bring_roughness = True @@ -371,26 +371,31 @@ def createnodes(active_mat,texcoat, create_group_node, tile_list, objekti): # Cr if(out_mat.inputs['Surface'].is_linked == True): if(bring_color == True and texcoat['color'] != []): - CreateTextureLine(data['color'], act_material, main_mat, texcoat, coat3D, notegroup, main_material, applink_tree, out_mat, coatMat, tile_list, objekti) + CreateTextureLine(data['color'], act_material, main_mat, texcoat, coat3D, notegroup, + main_material, applink_tree, out_mat, coatMat, tile_list, objekti, ind, is_new) if(bring_metalness == True and texcoat['metalness'] != []): - CreateTextureLine(data['metalness'], act_material, main_mat, texcoat, coat3D, notegroup, main_material, applink_tree, out_mat, coatMat, tile_list, objekti) + CreateTextureLine(data['metalness'], act_material, main_mat, texcoat, coat3D, notegroup, + main_material, applink_tree, out_mat, coatMat, tile_list, objekti, ind, is_new) if(bring_roughness == True and texcoat['rough'] != []): - CreateTextureLine(data['rough'], act_material, main_mat, texcoat, coat3D, notegroup, main_material, applink_tree, out_mat, coatMat,tile_list, objekti) + CreateTextureLine(data['rough'], act_material, main_mat, texcoat, coat3D, notegroup, + main_material, applink_tree, out_mat, coatMat,tile_list, objekti, ind, is_new) if(bring_normal == True and texcoat['nmap'] != []): - CreateTextureLine(data['nmap'], act_material, main_mat, texcoat, coat3D, notegroup, main_material, applink_tree, out_mat, coatMat, tile_list, objekti) + CreateTextureLine(data['nmap'], act_material, main_mat, texcoat, coat3D, notegroup, + main_material, applink_tree, out_mat, coatMat, tile_list, objekti, ind, is_new) if (bring_emissive == True and texcoat['emissive'] != []): - CreateTextureLine(data['emissive'], act_material, main_mat, texcoat, coat3D, notegroup, main_material, applink_tree, out_mat, coatMat, tile_list, objekti) + CreateTextureLine(data['emissive'], act_material, main_mat, texcoat, coat3D, notegroup, + main_material, applink_tree, out_mat, coatMat, tile_list, objekti, ind, is_new) if (bring_displacement == True and texcoat['displacement'] != []): - CreateTextureLine(data['displacement'], act_material, main_mat, texcoat, coat3D, notegroup, main_material, - applink_tree, out_mat, coatMat, tile_list, objekti) + CreateTextureLine(data['displacement'], act_material, main_mat, texcoat, coat3D, notegroup, + main_material, applink_tree, out_mat, coatMat, tile_list, objekti, ind, is_new) -def CreateTextureLine(type, act_material, main_mat, texcoat, coat3D, notegroup, main_material, applink_tree, out_mat, coatMat, tile_list, objekti): +def CreateTextureLine(type, act_material, main_mat, texcoat, coat3D, notegroup, main_material, applink_tree, out_mat, coatMat, tile_list, objekti, ind, is_new): if(tile_list): texture_name = coatMat.name + '_' + type['name'] @@ -430,7 +435,10 @@ def CreateTextureLine(type, act_material, main_mat, texcoat, coat3D, notegroup, tex_uv_node = texture_tree.nodes.new('ShaderNodeUVMap') tex_uv_node.location = uv_loc - tex_uv_node.uv_map = objekti.data.uv_layers[0].name + if(is_new): + tex_uv_node.uv_map = objekti.data.uv_layers[ind].name + else: + tex_uv_node.uv_map = objekti.data.uv_layers[0].name map_node = texture_tree.nodes.new('ShaderNodeMapping') map_node.location = map_loc @@ -492,7 +500,10 @@ def CreateTextureLine(type, act_material, main_mat, texcoat, coat3D, notegroup, else: node = act_material.nodes.new('ShaderNodeTexImage') uv_node = act_material.nodes.new('ShaderNodeUVMap') - uv_node.uv_map = objekti.data.uv_layers[0].name + if (is_new): + uv_node.uv_map = objekti.data.uv_layers[ind].name + else: + uv_node.uv_map = objekti.data.uv_layers[0].name act_material.links.new(uv_node.outputs[0], node.inputs[0]) uv_node.use_custom_color = True uv_node.color = (type['node_color'][0], type['node_color'][1], type['node_color'][2]) |