1 # SPDX-License-Identifier: GPL-2.0-or-later
7 from io_coat3D
import updateimage
9 def find_index(objekti
):
12 for tex
in objekti
.active_material
.texture_slots
:
13 if(not(hasattr(tex
,'texture'))):
19 def RemoveFbxNodes(objekti
):
20 Node_Tree
= objekti
.active_material
.node_tree
21 for node
in Node_Tree
.nodes
:
22 if node
.type != 'OUTPUT_MATERIAL':
23 Node_Tree
.nodes
.remove(node
)
26 output
.location
= 340,400
27 Prin_mat
= Node_Tree
.nodes
.new(type="ShaderNodeBsdfPrincipled")
28 Prin_mat
.location
= 13, 375
30 Node_Tree
.links
.new(Prin_mat
.outputs
[0], output
.inputs
[0])
33 def updatetextures(objekti
): # Update 3DC textures
35 for index_mat
in objekti
.material_slots
:
37 for node
in index_mat
.material
.node_tree
.nodes
:
38 if (node
.type == 'TEX_IMAGE'):
39 if (node
.name
== '3DC_color' or node
.name
== '3DC_metalness' or node
.name
== '3DC_rough' or node
.name
== '3DC_nmap'
40 or node
.name
== '3DC_displacement' or node
.name
== '3DC_emissive' or node
.name
== '3DC_AO' or node
.name
== '3DC_alpha'):
46 for index_node_group
in bpy
.data
.node_groups
:
48 for node
in index_node_group
.nodes
:
49 if (node
.type == 'TEX_IMAGE'):
50 if (node
.name
== '3DC_color' or node
.name
== '3DC_metalness' or node
.name
== '3DC_rough' or node
.name
== '3DC_nmap'
51 or node
.name
== '3DC_displacement' or node
.name
== '3DC_emissive' or node
.name
== '3DC_AO' or node
.name
== '3DC_alpha'):
57 def testi(objekti
, texture_info
, index_mat_name
, uv_MODE_mat
, mat_index
):
58 if uv_MODE_mat
== 'UV':
60 uv_set_founded
= False
61 for uvset
in objekti
.data
.uv_layers
:
63 if(uvset
.name
== texture_info
):
69 for uv_poly
in objekti
.data
.uv_layers
[texture_info
].id_data
.polygons
:
70 if(mat_index
== uv_poly
.material_index
):
75 elif uv_MODE_mat
== 'MAT':
76 return (texture_info
== index_mat_name
)
78 def readtexturefolder(objekti
, mat_list
, texturelist
, is_new
, udim_textures
, udim_len
): #read textures from texture file
80 # Let's check are we UVSet or MATERIAL modee
82 for ind
, index_mat
in enumerate(objekti
.material_slots
):
88 texcoat
['metalness'] = []
90 texcoat
['emissive'] = []
91 texcoat
['emissive_power'] = []
92 texcoat
['displacement'] = []
95 create_group_node
= False
96 if(udim_textures
== False):
97 for slot_index
, texture_info
in enumerate(texturelist
):
100 for index
, layer
in enumerate(objekti
.data
.uv_layers
):
101 if(layer
.name
== texturelist
[slot_index
][0]):
106 if(testi(objekti
, texturelist
[slot_index
][0], index_mat
.name
, uv_MODE_mat
, ind
)) :
107 if (os
.path
.isfile(texture_info
[3])):
108 if texture_info
[2] == 'color' or texture_info
[2] == 'diffuse':
109 if(index_mat
.material
.coat3D_diffuse
):
111 texcoat
['color'].append(texture_info
[3])
114 os
.remove(texture_info
[3])
116 elif texture_info
[2] == 'metalness' or texture_info
[2] == 'specular' or texture_info
[2] == 'reflection':
117 if (index_mat
.material
.coat3D_metalness
):
118 texcoat
['metalness'].append(texture_info
[3])
121 os
.remove(texture_info
[3])
123 elif texture_info
[2] == 'rough' or texture_info
[2] == 'roughness':
124 if (index_mat
.material
.coat3D_roughness
):
125 texcoat
['rough'].append(texture_info
[3])
128 os
.remove(texture_info
[3])
130 elif texture_info
[2] == 'nmap' or texture_info
[2] == 'normalmap' or texture_info
[2] == 'normal_map' or texture_info
[2] == 'normal':
131 if (index_mat
.material
.coat3D_normal
):
132 texcoat
['nmap'].append(texture_info
[3])
135 os
.remove(texture_info
[3])
137 elif texture_info
[2] == 'emissive':
138 if (index_mat
.material
.coat3D_emissive
):
139 texcoat
['emissive'].append(texture_info
[3])
142 os
.remove(texture_info
[3])
144 elif texture_info
[2] == 'emissive_power':
145 if (index_mat
.material
.coat3D_emissive
):
146 texcoat
['emissive_power'].append(texture_info
[3])
149 os
.remove(texture_info
[3])
151 elif texture_info
[2] == 'ao':
152 if (index_mat
.material
.coat3D_ao
):
153 texcoat
['ao'].append(texture_info
[3])
156 os
.remove(texture_info
[3])
158 elif texture_info
[2].startswith('displacement'):
159 if (index_mat
.material
.coat3D_displacement
):
160 texcoat
['displacement'].append(texture_info
[3])
163 os
.remove(texture_info
[3])
165 elif texture_info
[2] == 'alpha' or texture_info
[2] == 'opacity':
166 if (index_mat
.material
.coat3D_alpha
):
167 texcoat
['alpha'].append(texture_info
[3])
170 os
.remove(texture_info
[3])
172 create_group_node
= True
176 for texture_info
in texturelist
:
177 if (os
.path
.isfile(texture_info
[3])):
178 if texture_info
[2] == 'color' or texture_info
[2] == 'diffuse':
179 if texcoat
['color'] == [] and texture_info
[1] == '1001':
180 texcoat
['color'].append(texture_info
[3])
182 elif texture_info
[2] == 'metalness' or texture_info
[2] == 'specular' or texture_info
[
184 if texcoat
['metalness'] == [] and texture_info
[1] == '1001':
185 texcoat
['metalness'].append(texture_info
[3])
187 elif texture_info
[2] == 'rough' or texture_info
[2] == 'roughness':
188 if texcoat
['rough'] == [] and texture_info
[1] == '1001':
189 texcoat
['rough'].append(texture_info
[3])
191 elif texture_info
[2] == 'nmap' or texture_info
[2] == 'normalmap' or texture_info
[
192 2] == 'normal_map' or texture_info
[2] == 'normal':
193 if texcoat
['nmap'] == [] and texture_info
[1] == '1001':
194 texcoat
['nmap'].append(texture_info
[3])
196 elif texture_info
[2] == 'emissive':
197 if texcoat
['emissive'] == [] and texture_info
[1] == '1001':
198 texcoat
['emissive'].append(texture_info
[3])
200 elif texture_info
[2] == 'emissive_power':
201 if texcoat
['emissive_power'] == [] and texture_info
[1] == '1001':
202 texcoat
['emissive_power'].append(texture_info
[3])
204 elif texture_info
[2] == 'ao':
205 if texcoat
['ao'] == [] and texture_info
[1] == '1001':
206 texcoat
['ao'].append(texture_info
[3])
208 elif texture_info
[2].startswith('displacement'):
209 if texcoat
['displacement'] == [] and texture_info
[1] == '1001':
210 texcoat
['displacement'].append(texture_info
[3])
212 if texture_info
[2] == 'alpha' or texture_info
[2] == 'opacity':
213 if texcoat
['alpha'] == [] and texture_info
[1] == '1001':
214 texcoat
['alpha'].append(texture_info
[3])
216 create_group_node
= True
219 coat3D
= bpy
.context
.scene
.coat3D
220 path3b_n
= coat3D
.exchangeFolder
221 path3b_n
+= ('%slast_saved_3b_file.txt' % (os
.sep
))
223 if (os
.path
.isfile(path3b_n
)):
224 export_file
= open(path3b_n
)
225 for line
in export_file
:
226 objekti
.coat3D
.applink_3b_path
= line
228 coat3D
.remove_path
= True
229 createnodes(index_mat
, texcoat
, create_group_node
, objekti
, ind
, is_new
, udim_textures
, udim_len
)
231 def createnodes(active_mat
,texcoat
, create_group_node
, objekti
, ind
, is_new
, udim_textures
, udim_len
): # Creates new nodes and link textures into them
232 bring_color
= True # Meaning of these is to check if we can only update textures or do we need to create new nodes
233 bring_metalness
= True
234 bring_roughness
= True
236 bring_displacement
= True
237 bring_emissive
= True
241 active_mat
.material
.show_transparent_back
= False # HACK FOR BLENDER BUG
243 coat3D
= bpy
.context
.scene
.coat3D
244 coatMat
= active_mat
.material
246 coatMat
.blend_method
= 'BLEND'
248 if(coatMat
.use_nodes
== False):
249 coatMat
.use_nodes
= True
250 act_material
= coatMat
.node_tree
251 main_material
= coatMat
.node_tree
252 applink_group_node
= False
254 # First go through all image nodes and let's check if it starts with 3DC and reload if needed
256 for node
in coatMat
.node_tree
.nodes
:
257 if (node
.type == 'OUTPUT_MATERIAL'):
261 for node
in act_material
.nodes
:
262 if(node
.name
== '3DC_Applink' and node
.type == 'GROUP'):
263 applink_group_node
= True
264 act_material
= node
.node_tree
269 for node
in act_material
.nodes
:
270 if (node
.type != 'GROUP'):
271 if (node
.type != 'GROUP_OUTPUT'):
272 if (node
.type == 'TEX_IMAGE'):
273 if (node
.name
== '3DC_color'):
275 updateimage
.update(texcoat
, 'color', node
, udim_textures
, udim_len
)
276 elif (node
.name
== '3DC_metalness'):
277 bring_metalness
= False
278 updateimage
.update(texcoat
, 'metalness', node
, udim_textures
, udim_len
)
279 elif (node
.name
== '3DC_rough'):
280 bring_roughness
= False
281 updateimage
.update(texcoat
, 'rough', node
, udim_textures
, udim_len
)
282 elif (node
.name
== '3DC_nmap'):
284 updateimage
.update(texcoat
, 'nmap', node
, udim_textures
, udim_len
)
285 elif (node
.name
== '3DC_displacement'):
286 bring_displacement
= False
287 updateimage
.update(texcoat
, 'displacement', node
, udim_textures
, udim_len
)
288 elif (node
.name
== '3DC_emissive'):
289 bring_emissive
= False
290 updateimage
.update(texcoat
, 'emissive', node
, udim_textures
, udim_len
)
291 elif (node
.name
== '3DC_AO'):
293 updateimage
.update(texcoat
, 'ao', node
, udim_textures
, udim_len
)
294 elif (node
.name
== '3DC_alpha'):
296 updateimage
.update(texcoat
, 'alpha', node
, udim_textures
, udim_len
)
299 elif (node
.type == 'GROUP' and node
.name
.startswith('3DC_')):
300 if (node
.name
== '3DC_color'):
302 elif (node
.name
== '3DC_metalness'):
303 bring_metalness
= False
304 elif (node
.name
== '3DC_rough'):
305 bring_roughness
= False
306 elif (node
.name
== '3DC_nmap'):
308 elif (node
.name
== '3DC_displacement'):
309 bring_displacement
= False
310 elif (node
.name
== '3DC_emissive'):
311 bring_emissive
= False
312 elif (node
.name
== '3DC_AO'):
314 elif (node
.name
== '3DC_alpha'):
317 #Let's start to build new node tree. Let's start linking with Material Output
319 if(create_group_node
):
320 if(applink_group_node
== False):
321 main_mat2
= out_mat
.inputs
['Surface'].links
[0].from_node
322 for input_ind
in main_mat2
.inputs
:
323 if(input_ind
.is_linked
):
324 main_mat3
= input_ind
.links
[0].from_node
325 if(main_mat3
.type == 'BSDF_PRINCIPLED'):
328 group_tree
= bpy
.data
.node_groups
.new( type="ShaderNodeTree", name
="3DC_Applink")
329 group_tree
.outputs
.new("NodeSocketColor", "Color")
330 group_tree
.outputs
.new("NodeSocketColor", "Metallic")
331 group_tree
.outputs
.new("NodeSocketColor", "Roughness")
332 group_tree
.outputs
.new("NodeSocketVector", "Normal map")
333 group_tree
.outputs
.new("NodeSocketColor", "Emissive")
334 group_tree
.outputs
.new("NodeSocketColor", "Displacement")
335 group_tree
.outputs
.new("NodeSocketColor", "Emissive Power")
336 group_tree
.outputs
.new("NodeSocketColor", "AO")
337 group_tree
.outputs
.new("NodeSocketColor", "Alpha")
338 applink_tree
= act_material
.nodes
.new('ShaderNodeGroup')
339 applink_tree
.name
= '3DC_Applink'
340 applink_tree
.node_tree
= group_tree
341 applink_tree
.location
= -400, -100
342 act_material
= group_tree
343 notegroup
= act_material
.nodes
.new('NodeGroupOutput')
344 notegroup
.location
= 220, -260
346 if(texcoat
['emissive'] != []):
347 from_output
= out_mat
.inputs
['Surface'].links
[0].from_node
348 if(from_output
.type == 'BSDF_PRINCIPLED'):
349 add_shader
= main_material
.nodes
.new('ShaderNodeAddShader')
350 emission_shader
= main_material
.nodes
.new('ShaderNodeEmission')
352 emission_shader
.name
= '3DC_Emission'
354 add_shader
.location
= 420, 110
355 emission_shader
.location
= 70, -330
356 out_mat
.location
= 670, 130
358 main_material
.links
.new(from_output
.outputs
[0], add_shader
.inputs
[0])
359 main_material
.links
.new(add_shader
.outputs
[0], out_mat
.inputs
[0])
360 main_material
.links
.new(emission_shader
.outputs
[0], add_shader
.inputs
[1])
361 main_mat
= from_output
363 main_mat
= out_mat
.inputs
['Surface'].links
[0].from_node
366 main_mat
= out_mat
.inputs
['Surface'].links
[0].from_node
368 for node
in coatMat
.node_tree
.nodes
:
369 if (node
.type == 'GROUP' and node
.name
=='3DC_Applink'):
370 for in_node
in node
.node_tree
.nodes
:
371 if(in_node
.type == 'GROUP_OUTPUT'):
378 # READ DATA.JSON FILE
379 platform
= os
.sys
.platform
381 if(platform
== 'darwin'):
382 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'
383 json_address
= json_address
.replace('MacOS', 'Resources')
386 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'
389 with
open(json_address
, encoding
='utf-8') as data_file
:
390 data
= json
.loads(data_file
.read())
392 if(out_mat
.inputs
['Surface'].is_linked
== True):
393 if(bring_color
== True and texcoat
['color'] != []):
394 CreateTextureLine(data
['color'], act_material
, main_mat
, texcoat
, coat3D
, notegroup
,
395 main_material
, applink_tree
, out_mat
, coatMat
, objekti
, ind
, is_new
, udim_textures
, udim_len
)
397 if(bring_metalness
== True and texcoat
['metalness'] != []):
398 CreateTextureLine(data
['metalness'], act_material
, main_mat
, texcoat
, coat3D
, notegroup
,
399 main_material
, applink_tree
, out_mat
, coatMat
, objekti
, ind
, is_new
, udim_textures
, udim_len
)
401 if(bring_roughness
== True and texcoat
['rough'] != []):
402 CreateTextureLine(data
['rough'], act_material
, main_mat
, texcoat
, coat3D
, notegroup
,
403 main_material
, applink_tree
, out_mat
, coatMat
, objekti
, ind
, is_new
, udim_textures
, udim_len
)
405 if(bring_normal
== True and texcoat
['nmap'] != []):
406 CreateTextureLine(data
['nmap'], act_material
, main_mat
, texcoat
, coat3D
, notegroup
,
407 main_material
, applink_tree
, out_mat
, coatMat
, objekti
, ind
, is_new
, udim_textures
, udim_len
)
409 if (bring_emissive
== True and texcoat
['emissive'] != []):
410 CreateTextureLine(data
['emissive'], act_material
, main_mat
, texcoat
, coat3D
, notegroup
,
411 main_material
, applink_tree
, out_mat
, coatMat
, objekti
, ind
, is_new
, udim_textures
, udim_len
)
413 if (bring_displacement
== True and texcoat
['displacement'] != []):
414 CreateTextureLine(data
['displacement'], act_material
, main_mat
, texcoat
, coat3D
, notegroup
,
415 main_material
, applink_tree
, out_mat
, coatMat
, objekti
, ind
, is_new
, udim_textures
, udim_len
)
416 if (bring_alpha
== True and texcoat
['alpha'] != []):
417 CreateTextureLine(data
['alpha'], act_material
, main_mat
, texcoat
, coat3D
, notegroup
,
418 main_material
, applink_tree
, out_mat
, coatMat
, objekti
, ind
, is_new
, udim_textures
, udim_len
)
421 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
):
423 node
= act_material
.nodes
.new('ShaderNodeTexImage')
424 uv_node
= act_material
.nodes
.new('ShaderNodeUVMap')
426 uv_node
.uv_map
= objekti
.data
.uv_layers
[ind
].name
428 uv_node
.uv_map
= objekti
.data
.uv_layers
[0].name
429 act_material
.links
.new(uv_node
.outputs
[0], node
.inputs
[0])
430 uv_node
.use_custom_color
= True
431 uv_node
.color
= (type['node_color'][0], type['node_color'][1], type['node_color'][2])
433 node
.use_custom_color
= True
434 node
.color
= (type['node_color'][0],type['node_color'][1],type['node_color'][2])
437 if type['name'] == 'nmap':
438 normal_node
= act_material
.nodes
.new('ShaderNodeNormalMap')
439 normal_node
.use_custom_color
= True
440 normal_node
.color
= (type['node_color'][0], type['node_color'][1], type['node_color'][2])
442 node
.location
= -671, -510
443 uv_node
.location
= -750, -600
444 normal_node
.location
= -350, -350
445 normal_node
.name
= '3DC_normalnode'
447 elif type['name'] == 'displacement':
448 disp_node
= main_material
.nodes
.new('ShaderNodeDisplacement')
450 node
.location
= -630, -1160
451 disp_node
.location
= 90, -460
452 disp_node
.inputs
[2].default_value
= 0.1
453 disp_node
.name
= '3DC_dispnode'
455 node
.name
= '3DC_' + type['name']
456 node
.label
= type['name']
458 if (type['name'] != 'displacement'):
459 for input_index
in type['find_input']:
460 input_color
= main_mat
.inputs
.find(input_index
)
461 if(input_color
!= -1):
466 for image
in bpy
.data
.images
:
468 if(os
.path
.normpath(texcoat
[type['name']][0]) == os
.path
.normpath(image
.filepath
)):
474 node
.image
.source
= 'TILED'
475 for udim_index
in udim_len
:
476 if (udim_index
!= 1001):
477 node
.image
.tiles
.new(udim_index
)
485 node
.image
= bpy
.data
.images
.load(os
.path
.normpath(texcoat
[type['name']][0]))
488 node
.image
.source
= 'TILED'
490 for udim_index
in udim_len
:
491 if (udim_index
!= 1001):
492 node
.image
.tiles
.new(udim_index
)
495 if node
.image
and type['colorspace'] == 'noncolor':
496 node
.image
.colorspace_settings
.is_data
= True
498 if (coat3D
.createnodes
):
500 if(type['name'] == 'nmap'):
501 act_material
.links
.new(node
.outputs
[0], normal_node
.inputs
[1])
502 if(input_color
!= -1):
503 act_material
.links
.new(normal_node
.outputs
[0], main_mat
.inputs
[input_color
])
505 act_material
.links
.new(normal_node
.outputs
[0], notegroup
.inputs
[type['input']])
506 if (main_mat
.inputs
[input_color
].name
== 'Normal' and input_color
!= -1):
507 main_material
.links
.new(applink_tree
.outputs
[type['input']], main_mat
.inputs
[input_color
])
509 elif (type['name'] == 'displacement'):
511 rampnode
= act_material
.nodes
.new('ShaderNodeValToRGB')
512 rampnode
.name
= '3DC_ColorRamp'
513 rampnode
.use_custom_color
= True
514 rampnode
.color
= (type['node_color'][0], type['node_color'][1], type['node_color'][2])
515 rampnode
.location
= -270, -956
517 act_material
.links
.new(node
.outputs
[0], rampnode
.inputs
[0])
518 act_material
.links
.new(rampnode
.outputs
[0], notegroup
.inputs
[5])
520 main_material
.links
.new(applink_tree
.outputs
[5], disp_node
.inputs
[0])
521 main_material
.links
.new(disp_node
.outputs
[0], out_mat
.inputs
[2])
522 coatMat
.cycles
.displacement_method
= 'BOTH'
525 if (texcoat
['alpha'] != []):
526 if (type['name'] == 'alpha'):
527 act_material
.links
.new(node
.outputs
[1], notegroup
.inputs
[8])
529 if (type['name'] == 'color'):
530 act_material
.links
.new(node
.outputs
[1], notegroup
.inputs
[8])
531 if(type['name'] != 'alpha'):
532 huenode
= createExtraNodes(act_material
, node
, type)
535 huenode
.location
= -100, -800
537 if(type['name'] != 'alpha'):
538 act_material
.links
.new(huenode
.outputs
[0], notegroup
.inputs
[type['input']])
539 if (main_mat
.type != 'MIX_SHADER' and input_color
!= -1):
540 main_material
.links
.new(applink_tree
.outputs
[type['input']], main_mat
.inputs
[input_color
])
541 if(type['name'] == 'color'): #Alpha connection into Principled shader
542 main_material
.links
.new(applink_tree
.outputs
['Alpha'], main_mat
.inputs
['Alpha'])
545 location
= main_mat
.location
546 #applink_tree.location = main_mat.location[0], main_mat.location[1] + 200
548 if(type['name'] == 'emissive'):
549 for material
in main_material
.nodes
:
550 if(material
.name
== '3DC_Emission'):
551 main_material
.links
.new(applink_tree
.outputs
[type['input']], material
.inputs
[0])
554 uv_node
.location
= node
.location
555 uv_node
.location
[0] -= 300
556 uv_node
.location
[1] -= 200
559 node
.location
= type['node_location'][0], type['node_location'][1]
560 if (tile_list
== []):
561 uv_node
.location
= node
.location
562 uv_node
.location
[0] -= 300
563 act_material
.links
.new(node
.outputs
[0], notegroup
.inputs
[type['input']])
564 if (input_color
!= -1):
565 main_material
.links
.new(applink_tree
.outputs
[type['input']], main_mat
.inputs
[input_color
])
568 def createExtraNodes(act_material
, node
, type):
570 curvenode
= act_material
.nodes
.new('ShaderNodeRGBCurve')
571 curvenode
.name
= '3DC_RGBCurve'
572 curvenode
.use_custom_color
= True
573 curvenode
.color
= (type['node_color'][0], type['node_color'][1], type['node_color'][2])
575 if(type['huenode'] == 'yes'):
576 huenode
= act_material
.nodes
.new('ShaderNodeHueSaturation')
577 huenode
.name
= '3DC_HueSaturation'
578 huenode
.use_custom_color
= True
579 huenode
.color
= (type['node_color'][0], type['node_color'][1], type['node_color'][2])
581 huenode
= act_material
.nodes
.new('ShaderNodeMath')
582 huenode
.name
= '3DC_HueSaturation'
583 huenode
.operation
= 'MULTIPLY'
584 huenode
.inputs
[1].default_value
= 1
585 huenode
.use_custom_color
= True
586 huenode
.color
= (type['node_color'][0], type['node_color'][1], type['node_color'][2])
589 if(type['rampnode'] == 'yes'):
590 rampnode
= act_material
.nodes
.new('ShaderNodeValToRGB')
591 rampnode
.name
= '3DC_ColorRamp'
592 rampnode
.use_custom_color
= True
593 rampnode
.color
= (type['node_color'][0], type['node_color'][1], type['node_color'][2])
595 if (type['rampnode'] == 'yes'):
596 act_material
.links
.new(node
.outputs
[0], curvenode
.inputs
[1])
597 act_material
.links
.new(curvenode
.outputs
[0], rampnode
.inputs
[0])
598 if(type['huenode'] == 'yes'):
599 act_material
.links
.new(rampnode
.outputs
[0], huenode
.inputs
[4])
601 act_material
.links
.new(rampnode
.outputs
[0], huenode
.inputs
[0])
603 act_material
.links
.new(node
.outputs
[0], curvenode
.inputs
[1])
604 if (type['huenode'] == 'yes'):
605 act_material
.links
.new(curvenode
.outputs
[0], huenode
.inputs
[4])
607 act_material
.links
.new(curvenode
.outputs
[0], huenode
.inputs
[0])
609 if type['name'] == 'metalness':
610 node
.location
= -1300, 119
611 curvenode
.location
= -1000, 113
612 rampnode
.location
= -670, 115
613 huenode
.location
= -345, 118
615 elif type['name'] == 'rough':
616 node
.location
= -1300, -276
617 curvenode
.location
= -1000, -245
618 rampnode
.location
= -670, -200
619 huenode
.location
= -340, -100
621 elif type['name'] == 'color':
622 node
.location
= -990, 530
623 curvenode
.location
= -660, 480
624 huenode
.location
= -337, 335
626 elif type['name'] == 'emissive':
627 node
.location
= -1200, -900
628 curvenode
.location
= -900, -900
629 huenode
.location
= -340, -700
631 elif type['name'] == 'alpha':
632 node
.location
= -1200, -1200
633 curvenode
.location
= -900, -1250
634 rampnode
.location
= -600, -1200
635 huenode
.location
= -300, -1200
639 def matlab(objekti
,mat_list
,texturelist
,is_new
):
641 # FBX Materials: remove all nodes and create princibles node
644 RemoveFbxNodes(objekti
)
646 updatetextures(objekti
)
650 if(texturelist
!= []):
652 udim_textures
= False
656 if texturelist
[0][0].startswith('10') and len(texturelist
[0][0]) == 4:
660 udim_target
= texturelist
[0][2]
661 for texture
in texturelist
:
662 if texture
[2] == udim_target
:
663 udim_indexs
.append(int(texture
[0]))
665 udim_indexs
.sort() # sort tiles list -> 1001, 1002, 1003...
667 # Main loop for creating nodes
669 readtexturefolder(objekti
, mat_list
, texturelist
, is_new
, udim_textures
, udim_indexs
)