1 # SPDX-FileCopyrightText: 2010-2022 Blender Foundation
3 # SPDX-License-Identifier: GPL-2.0-or-later
9 from io_coat3D
import updateimage
11 def find_index(objekti
):
14 for tex
in objekti
.active_material
.texture_slots
:
15 if(not(hasattr(tex
,'texture'))):
21 def RemoveFbxNodes(objekti
):
22 Node_Tree
= objekti
.active_material
.node_tree
23 for node
in Node_Tree
.nodes
:
24 if node
.type != 'OUTPUT_MATERIAL':
25 Node_Tree
.nodes
.remove(node
)
28 output
.location
= 340,400
29 Prin_mat
= Node_Tree
.nodes
.new(type="ShaderNodeBsdfPrincipled")
30 Prin_mat
.location
= 13, 375
32 Node_Tree
.links
.new(Prin_mat
.outputs
[0], output
.inputs
[0])
35 def updatetextures(objekti
): # Update 3DC textures
37 for index_mat
in objekti
.material_slots
:
39 for node
in index_mat
.material
.node_tree
.nodes
:
40 if (node
.type == 'TEX_IMAGE'):
41 if (node
.name
== '3DC_color' or node
.name
== '3DC_metalness' or node
.name
== '3DC_rough' or node
.name
== '3DC_nmap'
42 or node
.name
== '3DC_displacement' or node
.name
== '3DC_emissive' or node
.name
== '3DC_AO' or node
.name
== '3DC_alpha'):
48 for index_node_group
in bpy
.data
.node_groups
:
50 for node
in index_node_group
.nodes
:
51 if (node
.type == 'TEX_IMAGE'):
52 if (node
.name
== '3DC_color' or node
.name
== '3DC_metalness' or node
.name
== '3DC_rough' or node
.name
== '3DC_nmap'
53 or node
.name
== '3DC_displacement' or node
.name
== '3DC_emissive' or node
.name
== '3DC_AO' or node
.name
== '3DC_alpha'):
59 def testi(objekti
, texture_info
, index_mat_name
, uv_MODE_mat
, mat_index
):
60 if uv_MODE_mat
== 'UV':
62 uv_set_founded
= False
63 for uvset
in objekti
.data
.uv_layers
:
65 if(uvset
.name
== texture_info
):
71 for uv_poly
in objekti
.data
.uv_layers
[texture_info
].id_data
.polygons
:
72 if(mat_index
== uv_poly
.material_index
):
77 elif uv_MODE_mat
== 'MAT':
78 return (texture_info
== index_mat_name
)
80 def readtexturefolder(objekti
, mat_list
, texturelist
, is_new
, udim_textures
, udim_len
): #read textures from texture file
82 # Let's check are we UVSet or MATERIAL mode
84 for ind
, index_mat
in enumerate(objekti
.material_slots
):
90 texcoat
['metalness'] = []
92 texcoat
['emissive'] = []
93 texcoat
['emissive_power'] = []
94 texcoat
['displacement'] = []
97 create_group_node
= False
98 if(udim_textures
== False):
99 for slot_index
, texture_info
in enumerate(texturelist
):
102 for index
, layer
in enumerate(objekti
.data
.uv_layers
):
103 if(layer
.name
== texturelist
[slot_index
][0]):
108 if(testi(objekti
, texturelist
[slot_index
][0], index_mat
.name
, uv_MODE_mat
, ind
)) :
109 if (os
.path
.isfile(texture_info
[3])):
110 if texture_info
[2] == 'color' or texture_info
[2] == 'diffuse':
111 if(index_mat
.material
.coat3D_diffuse
):
113 texcoat
['color'].append(texture_info
[3])
116 os
.remove(texture_info
[3])
118 elif texture_info
[2] == 'metalness' or texture_info
[2] == 'specular' or texture_info
[2] == 'reflection':
119 if (index_mat
.material
.coat3D_metalness
):
120 texcoat
['metalness'].append(texture_info
[3])
123 os
.remove(texture_info
[3])
125 elif texture_info
[2] == 'rough' or texture_info
[2] == 'roughness':
126 if (index_mat
.material
.coat3D_roughness
):
127 texcoat
['rough'].append(texture_info
[3])
130 os
.remove(texture_info
[3])
132 elif texture_info
[2] == 'nmap' or texture_info
[2] == 'normalmap' or texture_info
[2] == 'normal_map' or texture_info
[2] == 'normal':
133 if (index_mat
.material
.coat3D_normal
):
134 texcoat
['nmap'].append(texture_info
[3])
137 os
.remove(texture_info
[3])
139 elif texture_info
[2] == 'emissive':
140 if (index_mat
.material
.coat3D_emissive
):
141 texcoat
['emissive'].append(texture_info
[3])
144 os
.remove(texture_info
[3])
146 elif texture_info
[2] == 'emissive_power':
147 if (index_mat
.material
.coat3D_emissive
):
148 texcoat
['emissive_power'].append(texture_info
[3])
151 os
.remove(texture_info
[3])
153 elif texture_info
[2] == 'ao':
154 if (index_mat
.material
.coat3D_ao
):
155 texcoat
['ao'].append(texture_info
[3])
158 os
.remove(texture_info
[3])
160 elif texture_info
[2].startswith('displacement'):
161 if (index_mat
.material
.coat3D_displacement
):
162 texcoat
['displacement'].append(texture_info
[3])
165 os
.remove(texture_info
[3])
167 elif texture_info
[2] == 'alpha' or texture_info
[2] == 'opacity':
168 if (index_mat
.material
.coat3D_alpha
):
169 texcoat
['alpha'].append(texture_info
[3])
172 os
.remove(texture_info
[3])
174 create_group_node
= True
178 for texture_info
in texturelist
:
179 if (os
.path
.isfile(texture_info
[3])):
180 if texture_info
[2] == 'color' or texture_info
[2] == 'diffuse':
181 if texcoat
['color'] == [] and texture_info
[1] == '1001':
182 texcoat
['color'].append(texture_info
[3])
184 elif texture_info
[2] == 'metalness' or texture_info
[2] == 'specular' or texture_info
[
186 if texcoat
['metalness'] == [] and texture_info
[1] == '1001':
187 texcoat
['metalness'].append(texture_info
[3])
189 elif texture_info
[2] == 'rough' or texture_info
[2] == 'roughness':
190 if texcoat
['rough'] == [] and texture_info
[1] == '1001':
191 texcoat
['rough'].append(texture_info
[3])
193 elif texture_info
[2] == 'nmap' or texture_info
[2] == 'normalmap' or texture_info
[
194 2] == 'normal_map' or texture_info
[2] == 'normal':
195 if texcoat
['nmap'] == [] and texture_info
[1] == '1001':
196 texcoat
['nmap'].append(texture_info
[3])
198 elif texture_info
[2] == 'emissive':
199 if texcoat
['emissive'] == [] and texture_info
[1] == '1001':
200 texcoat
['emissive'].append(texture_info
[3])
202 elif texture_info
[2] == 'emissive_power':
203 if texcoat
['emissive_power'] == [] and texture_info
[1] == '1001':
204 texcoat
['emissive_power'].append(texture_info
[3])
206 elif texture_info
[2] == 'ao':
207 if texcoat
['ao'] == [] and texture_info
[1] == '1001':
208 texcoat
['ao'].append(texture_info
[3])
210 elif texture_info
[2].startswith('displacement'):
211 if texcoat
['displacement'] == [] and texture_info
[1] == '1001':
212 texcoat
['displacement'].append(texture_info
[3])
214 if texture_info
[2] == 'alpha' or texture_info
[2] == 'opacity':
215 if texcoat
['alpha'] == [] and texture_info
[1] == '1001':
216 texcoat
['alpha'].append(texture_info
[3])
218 create_group_node
= True
221 coat3D
= bpy
.context
.scene
.coat3D
222 path3b_n
= coat3D
.exchangeFolder
223 path3b_n
+= ('%slast_saved_3b_file.txt' % (os
.sep
))
225 if (os
.path
.isfile(path3b_n
)):
226 export_file
= open(path3b_n
)
227 for line
in export_file
:
228 objekti
.coat3D
.applink_3b_path
= line
230 coat3D
.remove_path
= True
231 createnodes(index_mat
, texcoat
, create_group_node
, objekti
, ind
, is_new
, udim_textures
, udim_len
)
233 def createnodes(active_mat
,texcoat
, create_group_node
, objekti
, ind
, is_new
, udim_textures
, udim_len
): # Creates new nodes and link textures into them
234 bring_color
= True # Meaning of these is to check if we can only update textures or do we need to create new nodes
235 bring_metalness
= True
236 bring_roughness
= True
238 bring_displacement
= True
239 bring_emissive
= True
243 active_mat
.material
.show_transparent_back
= False # HACK FOR BLENDER BUG
245 coat3D
= bpy
.context
.scene
.coat3D
246 coatMat
= active_mat
.material
248 coatMat
.blend_method
= 'BLEND'
250 if(coatMat
.use_nodes
== False):
251 coatMat
.use_nodes
= True
252 act_material
= coatMat
.node_tree
253 main_material
= coatMat
.node_tree
254 applink_group_node
= False
256 # First go through all image nodes and let's check if it starts with 3DC and reload if needed
258 for node
in coatMat
.node_tree
.nodes
:
259 if (node
.type == 'OUTPUT_MATERIAL'):
263 for node
in act_material
.nodes
:
264 if(node
.name
== '3DC_Applink' and node
.type == 'GROUP'):
265 applink_group_node
= True
266 act_material
= node
.node_tree
271 for node
in act_material
.nodes
:
272 if (node
.type != 'GROUP'):
273 if (node
.type != 'GROUP_OUTPUT'):
274 if (node
.type == 'TEX_IMAGE'):
275 if (node
.name
== '3DC_color'):
277 updateimage
.update(texcoat
, 'color', node
, udim_textures
, udim_len
)
278 elif (node
.name
== '3DC_metalness'):
279 bring_metalness
= False
280 updateimage
.update(texcoat
, 'metalness', node
, udim_textures
, udim_len
)
281 elif (node
.name
== '3DC_rough'):
282 bring_roughness
= False
283 updateimage
.update(texcoat
, 'rough', node
, udim_textures
, udim_len
)
284 elif (node
.name
== '3DC_nmap'):
286 updateimage
.update(texcoat
, 'nmap', node
, udim_textures
, udim_len
)
287 elif (node
.name
== '3DC_displacement'):
288 bring_displacement
= False
289 updateimage
.update(texcoat
, 'displacement', node
, udim_textures
, udim_len
)
290 elif (node
.name
== '3DC_emissive'):
291 bring_emissive
= False
292 updateimage
.update(texcoat
, 'emissive', node
, udim_textures
, udim_len
)
293 elif (node
.name
== '3DC_AO'):
295 updateimage
.update(texcoat
, 'ao', node
, udim_textures
, udim_len
)
296 elif (node
.name
== '3DC_alpha'):
298 updateimage
.update(texcoat
, 'alpha', node
, udim_textures
, udim_len
)
301 elif (node
.type == 'GROUP' and node
.name
.startswith('3DC_')):
302 if (node
.name
== '3DC_color'):
304 elif (node
.name
== '3DC_metalness'):
305 bring_metalness
= False
306 elif (node
.name
== '3DC_rough'):
307 bring_roughness
= False
308 elif (node
.name
== '3DC_nmap'):
310 elif (node
.name
== '3DC_displacement'):
311 bring_displacement
= False
312 elif (node
.name
== '3DC_emissive'):
313 bring_emissive
= False
314 elif (node
.name
== '3DC_AO'):
316 elif (node
.name
== '3DC_alpha'):
319 #Let's start to build new node tree. Let's start linking with Material Output
321 if(create_group_node
):
322 if(applink_group_node
== False):
323 main_mat2
= out_mat
.inputs
['Surface'].links
[0].from_node
324 for input_ind
in main_mat2
.inputs
:
325 if(input_ind
.is_linked
):
326 main_mat3
= input_ind
.links
[0].from_node
327 if(main_mat3
.type == 'BSDF_PRINCIPLED'):
330 group_tree
= bpy
.data
.node_groups
.new( type="ShaderNodeTree", name
="3DC_Applink")
331 group_tree
.outputs
.new("NodeSocketColor", "Color")
332 group_tree
.outputs
.new("NodeSocketColor", "Metallic")
333 group_tree
.outputs
.new("NodeSocketColor", "Roughness")
334 group_tree
.outputs
.new("NodeSocketVector", "Normal map")
335 group_tree
.outputs
.new("NodeSocketColor", "Emissive")
336 group_tree
.outputs
.new("NodeSocketColor", "Displacement")
337 group_tree
.outputs
.new("NodeSocketColor", "Emissive Power")
338 group_tree
.outputs
.new("NodeSocketColor", "AO")
339 group_tree
.outputs
.new("NodeSocketColor", "Alpha")
340 applink_tree
= act_material
.nodes
.new('ShaderNodeGroup')
341 applink_tree
.name
= '3DC_Applink'
342 applink_tree
.node_tree
= group_tree
343 applink_tree
.location
= -400, -100
344 act_material
= group_tree
345 notegroup
= act_material
.nodes
.new('NodeGroupOutput')
346 notegroup
.location
= 220, -260
348 if(texcoat
['emissive'] != []):
349 from_output
= out_mat
.inputs
['Surface'].links
[0].from_node
350 if(from_output
.type == 'BSDF_PRINCIPLED'):
351 add_shader
= main_material
.nodes
.new('ShaderNodeAddShader')
352 emission_shader
= main_material
.nodes
.new('ShaderNodeEmission')
354 emission_shader
.name
= '3DC_Emission'
356 add_shader
.location
= 420, 110
357 emission_shader
.location
= 70, -330
358 out_mat
.location
= 670, 130
360 main_material
.links
.new(from_output
.outputs
[0], add_shader
.inputs
[0])
361 main_material
.links
.new(add_shader
.outputs
[0], out_mat
.inputs
[0])
362 main_material
.links
.new(emission_shader
.outputs
[0], add_shader
.inputs
[1])
363 main_mat
= from_output
365 main_mat
= out_mat
.inputs
['Surface'].links
[0].from_node
368 main_mat
= out_mat
.inputs
['Surface'].links
[0].from_node
370 for node
in coatMat
.node_tree
.nodes
:
371 if (node
.type == 'GROUP' and node
.name
=='3DC_Applink'):
372 for in_node
in node
.node_tree
.nodes
:
373 if(in_node
.type == 'GROUP_OUTPUT'):
380 # READ DATA.JSON FILE
381 platform
= os
.sys
.platform
383 if(platform
== 'darwin'):
384 json_address
= os
.path
.dirname(bpy
.app
.binary_path
) + os
.sep
+ str(bpy
.app
.version
[0]) + '.' + str(bpy
.app
.version
[1]) + os
.sep
+ 'scripts' + os
.sep
+ 'addons' + os
.sep
+ 'io_coat3D' + os
.sep
+ 'data.json'
385 json_address
= json_address
.replace('MacOS', 'Resources')
388 json_address
= os
.path
.dirname(bpy
.app
.binary_path
) + os
.sep
+ str(bpy
.app
.version
[0]) + '.' + str(bpy
.app
.version
[1]) + os
.sep
+ 'scripts' + os
.sep
+ 'addons' + os
.sep
+ 'io_coat3D' + os
.sep
+ 'data.json'
391 with
open(json_address
, encoding
='utf-8') as data_file
:
392 data
= json
.loads(data_file
.read())
394 if(out_mat
.inputs
['Surface'].is_linked
== True):
395 if(bring_color
== True and texcoat
['color'] != []):
396 CreateTextureLine(data
['color'], act_material
, main_mat
, texcoat
, coat3D
, notegroup
,
397 main_material
, applink_tree
, out_mat
, coatMat
, objekti
, ind
, is_new
, udim_textures
, udim_len
)
399 if(bring_metalness
== True and texcoat
['metalness'] != []):
400 CreateTextureLine(data
['metalness'], act_material
, main_mat
, texcoat
, coat3D
, notegroup
,
401 main_material
, applink_tree
, out_mat
, coatMat
, objekti
, ind
, is_new
, udim_textures
, udim_len
)
403 if(bring_roughness
== True and texcoat
['rough'] != []):
404 CreateTextureLine(data
['rough'], act_material
, main_mat
, texcoat
, coat3D
, notegroup
,
405 main_material
, applink_tree
, out_mat
, coatMat
, objekti
, ind
, is_new
, udim_textures
, udim_len
)
407 if(bring_normal
== True and texcoat
['nmap'] != []):
408 CreateTextureLine(data
['nmap'], act_material
, main_mat
, texcoat
, coat3D
, notegroup
,
409 main_material
, applink_tree
, out_mat
, coatMat
, objekti
, ind
, is_new
, udim_textures
, udim_len
)
411 if (bring_emissive
== True and texcoat
['emissive'] != []):
412 CreateTextureLine(data
['emissive'], act_material
, main_mat
, texcoat
, coat3D
, notegroup
,
413 main_material
, applink_tree
, out_mat
, coatMat
, objekti
, ind
, is_new
, udim_textures
, udim_len
)
415 if (bring_displacement
== True and texcoat
['displacement'] != []):
416 CreateTextureLine(data
['displacement'], act_material
, main_mat
, texcoat
, coat3D
, notegroup
,
417 main_material
, applink_tree
, out_mat
, coatMat
, objekti
, ind
, is_new
, udim_textures
, udim_len
)
418 if (bring_alpha
== True and texcoat
['alpha'] != []):
419 CreateTextureLine(data
['alpha'], act_material
, main_mat
, texcoat
, coat3D
, notegroup
,
420 main_material
, applink_tree
, out_mat
, coatMat
, objekti
, ind
, is_new
, udim_textures
, udim_len
)
423 def CreateTextureLine(type, act_material
, main_mat
, texcoat
, coat3D
, notegroup
, main_material
, applink_tree
, out_mat
, coatMat
, objekti
, ind
, is_new
, udim_textures
, udim_len
):
425 node
= act_material
.nodes
.new('ShaderNodeTexImage')
426 uv_node
= act_material
.nodes
.new('ShaderNodeUVMap')
428 uv_node
.uv_map
= objekti
.data
.uv_layers
[ind
].name
430 uv_node
.uv_map
= objekti
.data
.uv_layers
[0].name
431 act_material
.links
.new(uv_node
.outputs
[0], node
.inputs
[0])
432 uv_node
.use_custom_color
= True
433 uv_node
.color
= (type['node_color'][0], type['node_color'][1], type['node_color'][2])
435 node
.use_custom_color
= True
436 node
.color
= (type['node_color'][0],type['node_color'][1],type['node_color'][2])
439 if type['name'] == 'nmap':
440 normal_node
= act_material
.nodes
.new('ShaderNodeNormalMap')
441 normal_node
.use_custom_color
= True
442 normal_node
.color
= (type['node_color'][0], type['node_color'][1], type['node_color'][2])
444 node
.location
= -671, -510
445 uv_node
.location
= -750, -600
446 normal_node
.location
= -350, -350
447 normal_node
.name
= '3DC_normalnode'
449 elif type['name'] == 'displacement':
450 disp_node
= main_material
.nodes
.new('ShaderNodeDisplacement')
452 node
.location
= -630, -1160
453 disp_node
.location
= 90, -460
454 disp_node
.inputs
[2].default_value
= 0.1
455 disp_node
.name
= '3DC_dispnode'
457 node
.name
= '3DC_' + type['name']
458 node
.label
= type['name']
460 if (type['name'] != 'displacement'):
461 for input_index
in type['find_input']:
462 input_color
= main_mat
.inputs
.find(input_index
)
463 if(input_color
!= -1):
468 for image
in bpy
.data
.images
:
470 if(os
.path
.normpath(texcoat
[type['name']][0]) == os
.path
.normpath(image
.filepath
)):
476 node
.image
.source
= 'TILED'
477 for udim_index
in udim_len
:
478 if (udim_index
!= 1001):
479 node
.image
.tiles
.new(udim_index
)
487 node
.image
= bpy
.data
.images
.load(os
.path
.normpath(texcoat
[type['name']][0]))
490 node
.image
.source
= 'TILED'
492 for udim_index
in udim_len
:
493 if (udim_index
!= 1001):
494 node
.image
.tiles
.new(udim_index
)
497 if node
.image
and type['colorspace'] == 'noncolor':
498 node
.image
.colorspace_settings
.is_data
= True
500 if (coat3D
.createnodes
):
502 if(type['name'] == 'nmap'):
503 act_material
.links
.new(node
.outputs
[0], normal_node
.inputs
[1])
504 if(input_color
!= -1):
505 act_material
.links
.new(normal_node
.outputs
[0], main_mat
.inputs
[input_color
])
507 act_material
.links
.new(normal_node
.outputs
[0], notegroup
.inputs
[type['input']])
508 if (main_mat
.inputs
[input_color
].name
== 'Normal' and input_color
!= -1):
509 main_material
.links
.new(applink_tree
.outputs
[type['input']], main_mat
.inputs
[input_color
])
511 elif (type['name'] == 'displacement'):
513 rampnode
= act_material
.nodes
.new('ShaderNodeValToRGB')
514 rampnode
.name
= '3DC_ColorRamp'
515 rampnode
.use_custom_color
= True
516 rampnode
.color
= (type['node_color'][0], type['node_color'][1], type['node_color'][2])
517 rampnode
.location
= -270, -956
519 act_material
.links
.new(node
.outputs
[0], rampnode
.inputs
[0])
520 act_material
.links
.new(rampnode
.outputs
[0], notegroup
.inputs
[5])
522 main_material
.links
.new(applink_tree
.outputs
[5], disp_node
.inputs
[0])
523 main_material
.links
.new(disp_node
.outputs
[0], out_mat
.inputs
[2])
524 coatMat
.displacement_method
= 'BOTH'
527 if (texcoat
['alpha'] != []):
528 if (type['name'] == 'alpha'):
529 act_material
.links
.new(node
.outputs
[1], notegroup
.inputs
[8])
531 if (type['name'] == 'color'):
532 act_material
.links
.new(node
.outputs
[1], notegroup
.inputs
[8])
533 if(type['name'] != 'alpha'):
534 huenode
= createExtraNodes(act_material
, node
, type)
537 huenode
.location
= -100, -800
539 if(type['name'] != 'alpha'):
540 act_material
.links
.new(huenode
.outputs
[0], notegroup
.inputs
[type['input']])
541 if (main_mat
.type != 'MIX_SHADER' and input_color
!= -1):
542 main_material
.links
.new(applink_tree
.outputs
[type['input']], main_mat
.inputs
[input_color
])
543 if(type['name'] == 'color'): #Alpha connection into Principled shader
544 main_material
.links
.new(applink_tree
.outputs
['Alpha'], main_mat
.inputs
['Alpha'])
547 location
= main_mat
.location
548 #applink_tree.location = main_mat.location[0], main_mat.location[1] + 200
550 if(type['name'] == 'emissive'):
551 for material
in main_material
.nodes
:
552 if(material
.name
== '3DC_Emission'):
553 main_material
.links
.new(applink_tree
.outputs
[type['input']], material
.inputs
[0])
556 uv_node
.location
= node
.location
557 uv_node
.location
[0] -= 300
558 uv_node
.location
[1] -= 200
561 node
.location
= type['node_location'][0], type['node_location'][1]
562 if (tile_list
== []):
563 uv_node
.location
= node
.location
564 uv_node
.location
[0] -= 300
565 act_material
.links
.new(node
.outputs
[0], notegroup
.inputs
[type['input']])
566 if (input_color
!= -1):
567 main_material
.links
.new(applink_tree
.outputs
[type['input']], main_mat
.inputs
[input_color
])
570 def createExtraNodes(act_material
, node
, type):
572 curvenode
= act_material
.nodes
.new('ShaderNodeRGBCurve')
573 curvenode
.name
= '3DC_RGBCurve'
574 curvenode
.use_custom_color
= True
575 curvenode
.color
= (type['node_color'][0], type['node_color'][1], type['node_color'][2])
577 if(type['huenode'] == 'yes'):
578 huenode
= act_material
.nodes
.new('ShaderNodeHueSaturation')
579 huenode
.name
= '3DC_HueSaturation'
580 huenode
.use_custom_color
= True
581 huenode
.color
= (type['node_color'][0], type['node_color'][1], type['node_color'][2])
583 huenode
= act_material
.nodes
.new('ShaderNodeMath')
584 huenode
.name
= '3DC_HueSaturation'
585 huenode
.operation
= 'MULTIPLY'
586 huenode
.inputs
[1].default_value
= 1
587 huenode
.use_custom_color
= True
588 huenode
.color
= (type['node_color'][0], type['node_color'][1], type['node_color'][2])
591 if(type['rampnode'] == 'yes'):
592 rampnode
= act_material
.nodes
.new('ShaderNodeValToRGB')
593 rampnode
.name
= '3DC_ColorRamp'
594 rampnode
.use_custom_color
= True
595 rampnode
.color
= (type['node_color'][0], type['node_color'][1], type['node_color'][2])
597 if (type['rampnode'] == 'yes'):
598 act_material
.links
.new(node
.outputs
[0], curvenode
.inputs
[1])
599 act_material
.links
.new(curvenode
.outputs
[0], rampnode
.inputs
[0])
600 if(type['huenode'] == 'yes'):
601 act_material
.links
.new(rampnode
.outputs
[0], huenode
.inputs
[4])
603 act_material
.links
.new(rampnode
.outputs
[0], huenode
.inputs
[0])
605 act_material
.links
.new(node
.outputs
[0], curvenode
.inputs
[1])
606 if (type['huenode'] == 'yes'):
607 act_material
.links
.new(curvenode
.outputs
[0], huenode
.inputs
[4])
609 act_material
.links
.new(curvenode
.outputs
[0], huenode
.inputs
[0])
611 if type['name'] == 'metalness':
612 node
.location
= -1300, 119
613 curvenode
.location
= -1000, 113
614 rampnode
.location
= -670, 115
615 huenode
.location
= -345, 118
617 elif type['name'] == 'rough':
618 node
.location
= -1300, -276
619 curvenode
.location
= -1000, -245
620 rampnode
.location
= -670, -200
621 huenode
.location
= -340, -100
623 elif type['name'] == 'color':
624 node
.location
= -990, 530
625 curvenode
.location
= -660, 480
626 huenode
.location
= -337, 335
628 elif type['name'] == 'emissive':
629 node
.location
= -1200, -900
630 curvenode
.location
= -900, -900
631 huenode
.location
= -340, -700
633 elif type['name'] == 'alpha':
634 node
.location
= -1200, -1200
635 curvenode
.location
= -900, -1250
636 rampnode
.location
= -600, -1200
637 huenode
.location
= -300, -1200
641 def matlab(objekti
,mat_list
,texturelist
,is_new
):
643 # FBX Materials: remove all nodes and create principle node
646 RemoveFbxNodes(objekti
)
648 updatetextures(objekti
)
652 if(texturelist
!= []):
654 udim_textures
= False
658 if texturelist
[0][0].startswith('10') and len(texturelist
[0][0]) == 4:
662 udim_target
= texturelist
[0][2]
663 for texture
in texturelist
:
664 if texture
[2] == udim_target
:
665 udim_indexs
.append(int(texture
[0]))
667 udim_indexs
.sort() # sort tiles list -> 1001, 1002, 1003...
669 # Main loop for creating nodes
671 readtexturefolder(objekti
, mat_list
, texturelist
, is_new
, udim_textures
, udim_indexs
)