-
Notifications
You must be signed in to change notification settings - Fork 10
/
save_shader_map.py
2842 lines (2403 loc) · 125 KB
/
save_shader_map.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import bpy
import json
import os
from bpy.props import (StringProperty,
BoolProperty,
IntProperty,
FloatProperty,
FloatVectorProperty,
EnumProperty,
PointerProperty,
CollectionProperty
)
from bpy.types import (Panel,
Operator,
AddonPreferences,
PropertyGroup,
UIList
)
#import libraries required for types
#for dict to nodes
from mathutils import (Vector, Euler, Color)
from bpy.types import Text
from bpy.types import Object
from bpy.types import ColorMapping, CurveMapping, ColorRamp
from bpy.types import Image, ImageUser, ParticleSystem
from bpy.types import (
NodeSocketBool, NodeSocketColor, NodeSocketFloat, NodeSocketFloatAngle,
NodeSocketFloatFactor, NodeSocketFloatPercentage, NodeSocketFloatTime,
NodeSocketFloatUnsigned, NodeSocketInt, NodeSocketIntFactor, NodeSocketIntPercentage,
NodeSocketIntUnsigned, NodeSocketShader, NodeSocketString, NodeSocketVector,
NodeSocketVectorAcceleration, NodeSocketVectorDirection, NodeSocketVectorEuler,
NodeSocketVectorTranslation, NodeSocketVectorVelocity, NodeSocketVectorXYZ, NodeSocketVirtual
)
#import pathlib for finding current working direction for get_default_and_current_json_paths()
#and .exists in import_current_or_default_json()
import pathlib
#define globals
SHADER_EDITOR = "ShaderNodeTree"
COMPOSITOR_EDITOR = "CompositorNodeTree"
ANIMATION_NODE_EDITOR = "an_AnimationNodeTree"
class SAVEUESHADERSCRIPT_OT_save_shader_map(bpy.types.Operator):
#default name is for Roman Noodles label
#text is changed for other Shader Map Types
bl_label = "Save Shader Map"
bl_description = "Save Current Shader Map as a Preset"
bl_idname = "saveueshaderscript.saveshadermap_operator"
def execute(self, context):
#store active/selected scene to variable
scene = context.scene
#allow access to user inputted properties through pointer
#to properties
savetool = scene.save_tool
if preset_name_exist(savetool.cust_map_name):
bpy.ops.ueshaderscript.show_message(
message="The nodes preset name exists, please choose another name and try again.")
return {'FINISHED'}
area = context.area
editor_type = area.ui_type
scene = context.scene
#allow access to user inputted properties through pointer
#to properties
savetool = scene.save_tool
node_editor = area
tree = node_editor.spaces[0].node_tree
#debug
#print("context.area.spaces[0].node_tree: ", tree)
#print("tree.nodes[0].bl_idname", tree.nodes[0].bl_idname)
try:
nodes_list, links_list, img_textures_list, regex_props_txt, total_capture_groups, texture_type_capture_group_index = nodes_to_dict(tree, savetool)
except emptySuffixError:
warning_message = "Error: Delete the extra comma and/or space for suffixes before saving"
bpy.ops.ueshaderscript.show_message(message = warning_message)
log(warning_message)
return {"FINISHED"}
except captureGroupNotInRangeError:
warning_message = "Error: Texture Type Index is invalid must 0 not 1 for 2 Total Capture Groups"
bpy.ops.ueshaderscript.show_message(message = warning_message)
log(warning_message)
return {"FINISHED"}
#img_textures_list will be blank [] and regex_props_txt will be an empty string ""
#if add_image_textures is False or if no image textures should be loaded
nodes_dict = {"nodes_list": nodes_list, "links_list": links_list, "img_textures_list": img_textures_list, "regex_props_txt": regex_props_txt,
"total_capture_groups": total_capture_groups, "texture_type_capture_group_index": texture_type_capture_group_index}
nodes_dict["editor_type"] = editor_type
shader_type = area.spaces[0].shader_type
nodes_dict["shader_type"] = shader_type
# Debug:
# print(nodes_dict)
JSON = nodes_dict_to_json(nodes_dict)
selected_folder_presets = get_selected_folder_presets()
presets = selected_folder_presets.presets
new_preset = presets.add()
#debug
#print("savetool.cust_map_name:", savetool.cust_map_name)
new_preset.name = savetool.cust_map_name
new_preset.content = JSON
selected_folder_presets.preset_index = len(presets) - 1
save_pref()
redraw_all()
return {"FINISHED"}
#------------------------NODES TO DICTIONARY RELATED CODE
#by default not in a node group
def nodes_to_dict(tree, savetool, is_in_node_group = False):
""" Actually, we construct and return a List """
if tree is not None:
nodes = tree.nodes
else:
nodes = []
nodes_list = []
for node in nodes:
#copy default node properties to node_dict
node_dict = {"node_name": node.bl_idname}
node_dict["x"] = node.location.x
node_dict["y"] = node.location.y
node_dict["width"] = node.width
node_dict["width_hidden"] = node.width_hidden
node_dict["height"] = node.height
#debug
#print("node dict after basic node properties:", node_dict)
#copy node parents means which frames
#each node belongs to to node_dict
parent = node.parent
if parent == None:
node_dict["parent"] = "None"
else:
parent_index = get_node_index(nodes, parent)
node_dict["parent"] = parent_index
#copy node attributes to node_dict
#dir() returns all properties and methods of
#the specified object, without the values.
attrs = dir(node)
attrs_list = []
for attr in attrs:
attr_dict = attr_to_dict(node, attr)
if attr_dict["type_name"] == "NoneType" \
or attr_dict["type_name"] == "Not Handle Type":
continue
attrs_list.append(attr_dict)
node_dict["attrs"] = attrs_list
#debug
#print("node dict after attrs:", node_dict)
#copy node inputs and output values and types to node_dict
inputs = []
for input in node.inputs:
input_dict = socket_to_dict_input(input)
inputs.append(input_dict)
if node.bl_idname != "CompositorNodeOutputFile":
node_dict["inputs"] = inputs
else:
node_dict["inputs"] = []
outputs = []
for output in node.outputs:
output_dict = socket_to_dict_output(output)
outputs.append(output_dict)
node_dict["outputs"] = outputs
#debug
#print("node dict after inputs outputs:", node_dict)
# Special handling ShaderNodeGroup
# this is for recording node groups
if node.bl_idname == "ShaderNodeGroup":
node_dict["node_tree"] = nodes_to_dict_handle_shader_node_group(
node, savetool)
### ignore as we only need to use the Shader Editor none of the other editors
# if node.bl_idname == "CompositorNodeGroup":
# node_dict["node_tree"] = nodes_to_dict_handle_compositor_node_group(
# node)
# if node.bl_idname == "CompositorNodeOutputFile":
# # We just handle OutputFile->file_slots, does not handle layer_slots (Waiting for bugs)
# node_dict["file_slots"] = nodes_to_dict_handle_compositor_node_output_file(
# node)
# # We treat all file slot's file format as the same of OutputFile->format->file_format
# node_dict["file_format"] = node.format.file_format
nodes_list.append(node_dict)
#debug
#print("full node_dict:", node_dict)
#print("\n\nfull nodes_list", nodes_list)
#print("\n\nfull nodes_list length", len(nodes_list))
#record all links in a python list
links_list = links_to_list(tree)
#debug
#print("\n\nlinks_list", links_list)
#if the option to load image textures is true then record
#what image texture suffixes and node names the user has written
#and the regex they have decided to use
if(savetool.is_add_img_textures == True and not is_in_node_group):
nodes = tree.nodes
img_textures_list = textures_to_list(savetool, nodes)
regex_props_txt = savetool.regex_props_txt
total_capture_groups = savetool.total_capture_groups
texture_type_capture_group_index = savetool.texture_type_capture_group_index
#if total capture groups is one then texture_type_capture_group_index cannot be 1
#because 1 refers to the non existent second capture group
#thus, raise an error and prevent the preset from being saved
if(total_capture_groups=="1" and texture_type_capture_group_index=="1"):
raise captureGroupNotInRangeError
else:
img_textures_list = []
regex_props_txt = ""
total_capture_groups = ""
texture_type_capture_group_index = ""
#only record textures to list and regex_props_txt if not in a node group
#because the node group has no textures to load
if(is_in_node_group):
return (nodes_list, links_list)
else:
return (nodes_list, links_list, img_textures_list, regex_props_txt, total_capture_groups, texture_type_capture_group_index)
#this class is just used as a custom error
#so can get out of any depth
#and stop preset being created
class captureGroupNotInRangeError(Exception):
pass
def socket_to_dict_output(output):
return socket_to_dict_input(output)
def socket_to_dict_input(input):
t = type(input)
dict = {}
if t == NodeSocketColor:
dict["type_name"] = "NodeSocketColor"
dict["value"] = list(input.default_value)
elif t == NodeSocketFloatFactor:
dict["type_name"] = "NodeSocketFloatFactor"
dict["value"] = input.default_value
elif t == NodeSocketVector or t == NodeSocketVectorDirection or \
t == NodeSocketVectorEuler or t == NodeSocketVectorTranslation or \
t == NodeSocketVectorVelocity or t == NodeSocketVectorXYZ:
dict["type_name"] = "NodeSocketVector"
dict["value"] = list(input.default_value)
elif t == NodeSocketBool:
dict["type_name"] = "NodeSocketBool"
if input.default_value == True:
value = 1
else:
value = 0
dict["value"] = value
elif t == NodeSocketFloat:
dict["type_name"] = "NodeSocketFloat"
dict["value"] = input.default_value
elif t == NodeSocketFloatAngle:
dict["type_name"] = "NodeSocketFloatAngle"
dict["value"] = input.default_value
elif t == NodeSocketFloatPercentage:
dict["type_name"] = "NodeSocketFloatPercentage"
dict["value"] = input.default_value
elif t == NodeSocketFloatTime:
dict["type_name"] = "NodeSocketFloatTime"
dict["value"] = input.default_value
elif t == NodeSocketFloatUnsigned:
dict["type_name"] = "NodeSocketFloatUnsigned"
dict["value"] = input.default_value
elif t == NodeSocketInt:
dict["type_name"] = "NodeSocketInt"
dict["value"] = input.default_value
elif t == NodeSocketIntFactor:
dict["type_name"] = "NodeSocketIntFactor"
dict["value"] = input.default_value
elif t == NodeSocketIntPercentage:
dict["type_name"] = "NodeSocketIntPercentage"
dict["value"] = input.default_value
elif t == NodeSocketIntUnsigned:
dict["type_name"] = "NodeSocketIntUnsigned"
dict["value"] = input.default_value
elif t == NodeSocketString:
dict["type_name"] = "NodeSocketString"
dict["value"] = input.default_value
elif t == NodeSocketVector:
dict["type_name"] = "NodeSocketVector"
dict["value"] = list(input.default_value)
elif t == NodeSocketVectorAcceleration:
dict["type_name"] = "NodeSocketVectorAcceleration"
dict["value"] = list(input.default_value)
elif t == NodeSocketShader:
dict["type_name"] = "NodeSocketShader"
elif t == NodeSocketVirtual:
dict["type_name"] = "NodeSocketVirtual"
else:
log("socket_to_dict_input() can not handle input type: %s" % t)
raise ValueError(
"socket_to_dict_input() can not handle input type: %s" % t)
dict["name"] = input.name
return dict
def get_node_index(nodes, node):
index = 0
for n in nodes:
if n == node:
return index
index += 1
return "None"
def attr_to_dict(node, attr):
dict = {}
if not is_default_attr(attr):
t = type(getattr(node, attr))
v = getattr(node, attr)
if v == None:
dict["type_name"] = "NoneType"
elif t == str:
dict["type_name"] = "str"
dict["value"] = getattr(node, attr)
elif t == int:
dict["type_name"] = "int"
dict["value"] = getattr(node, attr)
elif t == float:
dict["type_name"] = "float"
dict["value"] = getattr(node, attr)
elif t == bool:
dict["type_name"] = "bool"
if getattr(node, attr) == True:
value = 1
else:
value = 0
dict["value"] = value
elif t == list:
dict["type_name"] = "list"
dict["value"] = getattr(node, attr)
elif t == tuple:
dict["type_name"] = "tuple"
dict["value"] = list(getattr(node, attr))
elif t == Vector:
dict["type_name"] = "Vector"
dict["value"] = list(getattr(node, attr).to_tuple())
elif t == Euler:
dict["type_name"] = "Euler"
value = getattr(node, attr)
dict["value"] = list(value[:])
elif t == Text:
dict["type_name"] = "Text"
value = getattr(node, attr)
dict["value"] = value.name
elif t == ColorMapping:
dict["type_name"] = "NoneType"
elif t == Image:
dict["type_name"] = "Image"
image = getattr(node, attr)
dict["value"] = image.name
dict["image_filepath"] = image.filepath
dict["image_source"] = image.source
elif t == Object:
dict["type_name"] = "Object"
value = getattr(node, attr)
dict["value"] = value.name
elif t == ImageUser:
dict["type_name"] = "ImageUser"
image_user = getattr(node, attr)
value = get_value_from_ImageUser(image_user)
dict["value"] = value
elif t == ParticleSystem:
dict["type_name"] = "ParticleSystem"
value = getattr(node, attr)
dict["value"] = value.name
dict["object_name"] = bpy.context.object.name
elif t == CurveMapping:
dict["type_name"] = "CurveMapping"
dict["value"] = get_value_from_CurveMapping(getattr(node, attr))
elif t == Color:
dict["type_name"] = "Color"
value = getattr(node, attr)
dict["value"] = list(value)
elif t == ColorRamp:
dict["type_name"] = "ColorRamp"
color_ramp = getattr(node, attr)
color_ramp_dict = {}
color_ramp_dict["color_mode"] = color_ramp.color_mode
color_ramp_dict["hue_interpolation"] = color_ramp.hue_interpolation
color_ramp_dict["interpolation"] = color_ramp.interpolation
elements = []
for ele in color_ramp.elements:
color_ramp_element = {}
color_ramp_element["alpha"] = ele.alpha
color_ramp_element["color"] = list(ele.color)
color_ramp_element["position"] = ele.position
elements.append(color_ramp_element)
color_ramp_dict["elements"] = elements
dict["value"] = color_ramp_dict
else:
dict["type_name"] = "NoneType"
log("attr_to_dict() can not handle attr type: %s attr:%s" % (t, attr))
# We don't raise error because some type no need to handle, and
# it works well for restore
#raise ValueError("attr_to_dict() can not handle attr type: %s" % t)
else:
dict["type_name"] = "Not Handle Type"
dict["attr_name"] = attr
return dict
def get_value_from_CurveMapping(curve_mapping):
def get_curve_points(curve):
ret = []
for p in curve.points:
point_dict = {}
point_dict["handle_type"] = p.handle_type
point_dict["location"] = list(p.location)
ret.append(point_dict)
return ret
dict = {}
dict["black_level"] = list(curve_mapping.black_level)
dict["clip_max_x"] = curve_mapping.clip_max_x
dict["clip_max_y"] = curve_mapping.clip_max_y
dict["clip_min_x"] = curve_mapping.clip_min_x
dict["clip_min_y"] = curve_mapping.clip_min_y
dict["tone"] = curve_mapping.tone
dict["use_clip"] = curve_mapping.use_clip
dict["white_level"] = list(curve_mapping.white_level)
curves = []
for curve in curve_mapping.curves:
curve_dict = {}
#curve_dict["extend"] = curve.extend
set_attr_if_exist_for_dict(curve, "extend", curve_dict)
curve_dict["points"] = get_curve_points(curve)
curves.append(curve_dict)
dict["curves"] = curves
return dict
def set_attr_if_exist_for_dict(obj, attr, dict):
if hasattr(obj, attr):
dict[attr] = getattr(obj, attr)
else:
dict[attr] = "None"
def get_value_from_ImageUser(image_user):
dict = {}
dict["frame_current"] = image_user.frame_current
dict["frame_duration"] = image_user.frame_duration
dict["frame_offset"] = image_user.frame_offset
dict["frame_start"] = image_user.frame_start
dict["use_cyclic"] = image_user.use_cyclic
dict["use_auto_refresh"] = image_user.use_auto_refresh
return dict
def get_value_from_ColorMapping(color_mapping):
dict = {}
dict["blend_color"] = list(color_mapping.blend_color)
dict["blend_factor"] = color_mapping.blend_factor
dict["blend_type"] = color_mapping.blend_type
dict["brightness"] = color_mapping.brightness
dict["contrast"] = color_mapping.contrast
dict["saturation"] = color_mapping.saturation
dict["use_color_ramp"] = color_mapping.use_color_ramp
return dict
def is_default_attr(attr):
if attr in get_default_attrs():
return True
else:
return False
def get_default_attrs():
# `codeEffects` is a value which can not be JSONify in KDTree (Animation Node)
return ['__doc__', '__module__', '__slots__', 'bl_description',
'bl_height_default',
'bl_height_max', 'bl_height_min', 'bl_icon', 'bl_idname',
'bl_label', 'bl_rna', 'bl_static_type', 'bl_width_default',
'bl_width_max', 'bl_width_min', 'dimensions',
'draw_buttons', 'draw_buttons_ext', 'height',
'input_template', 'inputs', 'internal_links', 'is_active_output',
'is_registered_node_type', 'location', 'mute',
'output_template', 'outputs', 'parent', 'poll', 'poll_instance',
'rna_type', 'select', 'show_options', 'show_preview',
'show_texture', 'socket_value_update', 'type', 'update',
'width', 'width_hidden',
'codeEffects'
]
#this is to handle node groups
def nodes_to_dict_handle_shader_node_group(node, savetool):
node_tree_of_node_group = node.node_tree
inputs = node_tree_of_node_group.inputs
interface_inputs_list = interface_inputs_to_list(inputs)
node_tree_dict = {}
node_tree_dict["interface_inputs"] = interface_inputs_list
node_tree_dict["name"] = node_tree_of_node_group.name
#set in node group bool to true
is_in_node_group = True
nodes_list, links_list = nodes_to_dict(node_tree_of_node_group, savetool, is_in_node_group)
node_tree_dict["nodes_list"] = nodes_list
node_tree_dict["links_list"] = links_list
return node_tree_dict
def interface_inputs_to_list(inputs):
inputs_list = []
for input in inputs:
if hasattr(input, "min_value"):
min_value = input.min_value
else:
min_value = "None"
if hasattr(input, "max_value"):
max_value = input.max_value
else:
max_value = "None"
dict = {"min_value": min_value, "max_value": max_value}
inputs_list.append(dict)
return inputs_list
def links_to_list(tree):
if tree is None:
links = []
nodes = []
else:
links = tree.links
nodes = tree.nodes
links_list = []
for link in links:
link_dict = {}
for node_index, n in enumerate(nodes):
inputs = n.inputs
outputs = n.outputs
for index, o in enumerate(outputs):
if link.from_socket == o:
link_dict["from_node_index"] = node_index
link_dict["from_socket_index"] = index
link_dict["from_socket_name"] = o.name
for index, i in enumerate(inputs):
if link.to_socket == i:
link_dict["to_node_index"] = node_index
link_dict["to_socket_index"] = index
link_dict["to_socket_name"] = i.name
links_list.append(link_dict)
return links_list
def textures_to_list(savetool, nodes):
#nested function so that don't have to pass lists around
#nested functions can access parent function's variables
def suffix_and_node_name_to_list(suffix, node_name, texture):
img_textures_dict = {}
#if both the suffix and suffix node are not empty
#record the suffix in the dictionary
if suffix != "" and node_name != "":
#try get the node by node name
#if it does not exist
#do not let it be recorded in the img_textures_dict or img_textures_list
#because we don't want to record
#img textures that will never get loaded
#debug
#print("node_name:", node_name)
node = nodes.get(node_name, None)
#print("node:", node, "\n")
#by default assume node with suffix node name does not exist
is_node_with_node_name_exist = False
if (node != None):
is_node_with_node_name_exist = True
else:
#notify user if their
#Shader Map did not have a Node with the correctly named Node Name
#two brackets inner brackets converts to tuple .join needs a tuple
warning_message = "".join(("A node with Node Name: \"", node_name, "\" does not exist so the ", texture, " texture was not recorded to load!"))
bpy.ops.ueshaderscript.show_message(message = warning_message)
#only record in the img_textures_dict and img_textures_list if the node exists
#in the current shader setup
if is_node_with_node_name_exist:
#texture is for debugging purposes so can check JSON file
#but it is also used to uniquely identify a
#specific marked image texture node
#this is because both suffix and node_name can be changed
#but texture is always the same
img_textures_dict["texture"] = texture
img_textures_dict["node_name"] = node_name
#for the suffix property the rules are
#every suffix should be separated by a space
#so we are separating every suffix with .split()
#.split generates a list so no need for extra square brackets
#around suffix.split(", ")
#"Base Color Texture, Diffuse" becomes
#['Base Color Texture', 'Diffuse']
#extra space gets rid of the space between the suffixes
suffix_list = suffix.split(", ")
#if there is empty suffixes,
#don't allow the preset to be saved
#and exit early out of all functions by raising an error
if "" in suffix_list or " " in suffix_list:
raise emptySuffixError
img_textures_dict["suffix_list"] = suffix_list
#if node name is missing but suffix is there
#special case to avoid skin bump texture because
#the default is always missing the Node Name
#since it only needs a Node Name
elif suffix != "" and node_name == "" and texture != "skin_bump":
#notify user if they
#did not fill in both the suffix and the node name
warning_message = "".join(("The Node Name input is missing for texture: \"", texture, "\" so the texture was not recorded to load!"))
bpy.ops.ueshaderscript.show_message(message = warning_message)
#if suffix is missing but node name is there
elif suffix == "" and node_name != "":
#notify user if they
#did not fill in both the suffix and the node name
warning_message = "".join(("The Suffix input is missing for texture: \"", texture, "\" so the texture was not recorded to load!"))
bpy.ops.ueshaderscript.show_message(message = warning_message)
#if the suffix and node name is missing then this is the default state
#so no warning message needs to be shown
#if an entry was added into the img_textures_dict
#append it to the list
#otherwise don't append anything to the list
if img_textures_dict != {}:
img_textures_list.append(img_textures_dict)
#-------------------------------end of nested function
img_textures_list = []
suffix_and_node_name_to_list(savetool.bc_suffix, savetool.bc_node_name, "diffuse")
suffix_and_node_name_to_list(savetool.orm_suffix, savetool.orm_node_name, "packed_orm")
suffix_and_node_name_to_list(savetool.n_suffix, savetool.n_node_name, "normal")
suffix_and_node_name_to_list(savetool.m_suffix, savetool.m_node_name, "transparency")
suffix_and_node_name_to_list(savetool.bde_suffix, savetool.bde_node_name, "emissive")
suffix_and_node_name_to_list(savetool.hm_suffix, savetool.hm_node_name, "height")
suffix_and_node_name_to_list(savetool.hair_gradient_suffix, savetool.hair_gradient_node_name, "hair_gradient")
suffix_and_node_name_to_list(savetool.specular_suffix, savetool.specular_node_name, "specular")
suffix_and_node_name_to_list(savetool.gloss_suffix, savetool.gloss_node_name, "gloss")
#extra textures
suffix_and_node_name_to_list(savetool.roughness_suffix, savetool.roughness_node_name, "roughness")
suffix_and_node_name_to_list(savetool.metallic_suffix, savetool.metallic_node_name, "metallic")
suffix_and_node_name_to_list(savetool.subsurface_color_suffix, savetool.subsurface_color_node_name, "subsurface_color")
suffix_and_node_name_to_list(savetool.subsurface_suffix, savetool.subsurface_node_name, "subsurface")
suffix_and_node_name_to_list(savetool.ambient_occlusion_suffix, savetool.ambient_occlusion_node_name, "ambient_occlusion")
suffix_and_node_name_to_list(savetool.detail_n_suffix, savetool.detail_n_node_name, "detail_normal")
suffix_and_node_name_to_list(savetool.wpo_suffix, savetool.wpo_node_name, "world_position_offset")
suffix_and_node_name_to_list(savetool.tint_suffix, savetool.tint_node_name, "tint")
suffix_and_node_name_to_list(savetool.normal_detail_suffix, savetool.normal_detail_node_name, "normal_detail")
suffix_and_node_name_to_list(savetool.roughness_detail_suffix, savetool.roughness_detail_node_name, "roughness_detail")
suffix_and_node_name_to_list(savetool.smoothness_suffix, savetool.smoothness_node_name, "smoothness")
suffix_and_node_name_to_list(savetool.edge_mask_suffix, savetool.edge_mask_node_name, "edge_mask")
suffix_and_node_name_to_list(savetool.transmission_suffix, savetool.transmission_node_name, "transmission")
suffix_and_node_name_to_list(savetool.clearcoat_suffix, savetool.clearcoat_node_name, "clearcoat")
suffix_and_node_name_to_list(savetool.anisotropic_suffix, savetool.anisotropic_suffix_node_name, "anisotropic")
suffix_and_node_name_to_list(savetool.sheen_suffix, savetool.sheen_node_name, "sheen")
suffix_and_node_name_to_list(savetool.glass_mask_suffix, savetool.glass_mask_node_name, "glass_mask")
#splat + environment textures
suffix_and_node_name_to_list(savetool.splat_suffix, savetool.splat_node_name, "splat")
suffix_and_node_name_to_list(savetool.red_bc_suffix, savetool.red_bc_node_name, "red_bc")
suffix_and_node_name_to_list(savetool.red_orm_suffix, savetool.red_orm_node_name, "red_orm")
suffix_and_node_name_to_list(savetool.red_n_suffix, savetool.red_n_node_name, "red_n")
suffix_and_node_name_to_list(savetool.red_e_suffix, savetool.red_e_node_name, "red_e")
suffix_and_node_name_to_list(savetool.green_bc_suffix, savetool.green_bc_node_name, "green_bc")
suffix_and_node_name_to_list(savetool.green_orm_suffix, savetool.green_orm_node_name, "green_orm")
suffix_and_node_name_to_list(savetool.green_n_suffix, savetool.green_n_node_name, "green_n")
suffix_and_node_name_to_list(savetool.green_e_suffix, savetool.green_e_node_name, "green_e")
suffix_and_node_name_to_list(savetool.blue_bc_suffix, savetool.blue_bc_node_name, "blue_bc")
suffix_and_node_name_to_list(savetool.blue_orm_suffix, savetool.blue_orm_node_name, "blue_orm")
suffix_and_node_name_to_list(savetool.blue_n_suffix, savetool.blue_n_node_name, "blue_n")
suffix_and_node_name_to_list(savetool.blue_e_suffix, savetool.blue_e_node_name, "blue_e")
suffix_and_node_name_to_list(savetool.cyan_bc_suffix, savetool.cyan_bc_node_name, "cyan_bc")
suffix_and_node_name_to_list(savetool.cyan_orm_suffix, savetool.cyan_orm_node_name, "cyan_orm")
suffix_and_node_name_to_list(savetool.cyan_n_suffix, savetool.cyan_n_node_name, "cyan_n")
suffix_and_node_name_to_list(savetool.cyan_e_suffix, savetool.cyan_e_node_name, "cyan_e")
suffix_and_node_name_to_list(savetool.alpha_bc_suffix, savetool.alpha_bc_node_name, "alpha_bc")
suffix_and_node_name_to_list(savetool.alpha_orm_suffix, savetool.alpha_orm_node_name, "alpha_orm")
suffix_and_node_name_to_list(savetool.alpha_n_suffix, savetool.alpha_n_node_name, "alpha_n")
suffix_and_node_name_to_list(savetool.alpha_e_suffix, savetool.alpha_e_node_name, "alpha_e")
suffix_and_node_name_to_list(savetool.moss_bc_suffix, savetool.moss_bc_node_name, "moss_bc")
suffix_and_node_name_to_list(savetool.moss_orm_suffix, savetool.moss_orm_node_name, "moss_orm")
suffix_and_node_name_to_list(savetool.moss_mask_suffix, savetool.moss_mask_node_name, "moss_mask")
suffix_and_node_name_to_list(savetool.leaves_bc_suffix, savetool.leaves_bc_node_name, "leaves_bc")
suffix_and_node_name_to_list(savetool.leaves_orm_suffix, savetool.leaves_orm_node_name, "leaves_orm")
suffix_and_node_name_to_list(savetool.leaves_mask_suffix, savetool.leaves_mask_node_name, "leaves_mask")
suffix_and_node_name_to_list(savetool.dirt_bc_suffix, savetool.dirt_bc_node_name, "dirt_bc")
suffix_and_node_name_to_list(savetool.dirt_orm_suffix, savetool.dirt_orm_node_name, "dirt_orm")
suffix_and_node_name_to_list(savetool.dirt_mask_suffix, savetool.dirt_mask_node_name, "dirt_mask")
#tint textures
suffix_and_node_name_to_list(savetool.tint_base_diffuse_suffix, savetool.tint_base_diffuse_node_name, "tint_base_diffuse")
suffix_and_node_name_to_list(savetool.tint_mask_suffix, savetool.tint_mask_node_name, "tint_mask")
suffix_and_node_name_to_list(savetool.tint_mask_suffix_2, savetool.tint_mask_node_name_2, "tint_mask_2")
suffix_and_node_name_to_list(savetool.hair_tint_id_suffix, savetool.hair_tint_id_node_name, "hair_tint_id")
#skin bump texture is always added and is found from the user chosen path
#not from the exported game folder
suffix_and_node_name_to_list(savetool.cust1_suffix, savetool.cust1_node_name, "cust1")
suffix_and_node_name_to_list(savetool.cust2_suffix, savetool.cust2_node_name, "cust2")
suffix_and_node_name_to_list(savetool.cust3_suffix, savetool.cust3_node_name, "cust3")
suffix_and_node_name_to_list(savetool.cust4_suffix, savetool.cust4_node_name, "cust4")
#if the img_textures list is empty
#that is equivalent to having
#no image textures to load
#debug
#print("img_textures_list: ", img_textures_list)
#print("img_textures_list length: ", len(img_textures_list))
return img_textures_list
#this class is just used as a custom error
#so can get out of any depth
#and stop preset being created
class emptySuffixError(Exception):
pass
#---------------------------Panel related code including preset and folder new , deletion, renaming
#define all user input properties
class SaveProperties(bpy.types.PropertyGroup):
cust_map_name: bpy.props.StringProperty(name="Name of Shader Map", description="Name of your custom shader map")
bc_suffix: bpy.props.StringProperty(name="Diffuse Suffix", description="Suffix of Diffuse", default="Base Color Texture, Diffuse, BaseColor Map, Main_BaseColor")
bc_node_name: bpy.props.StringProperty(name="Diffuse Node Name", description="Diffuse image texture node name", default="Diffuse Node")
orm_suffix: bpy.props.StringProperty(name="Packed RGB ARM Suffix", description="Suffix of Packed RGB (AO, Rough, Metallic)", default="AORoughnessMetallic, HRM\ORM Map, Main_ORM")
orm_node_name: bpy.props.StringProperty(name="Packed RGB Node Name", description="Packed RGB image texture node name", default="Packed RGB Node")
n_suffix: bpy.props.StringProperty(name="Normal Map Suffix", description="Suffix of Normal Map", default="NormalMap Texture, Normal, Normal Map, Main_Normal")
n_node_name: bpy.props.StringProperty(name="Normal Map Node Name", description="Normal Map image texture node name", default="Normal Map Node")
m_suffix: bpy.props.StringProperty(name="Alpha Map Suffix", description="Suffix of Alpha (Transparency) Map", default="Opacity Mask Texture, Transparency Map Node, Alpha_Mask")
m_node_name: bpy.props.StringProperty(name="Alpha Map Node Name", description="Alpha Map image texture node name", default="Transparency Map Node")
bde_suffix: bpy.props.StringProperty(name="Emissions Map Suffix", description="Suffix of Emissions Map", default="Blood Dirt Emissive")
bde_node_name: bpy.props.StringProperty(name="Emissions Map Node Name", description="Emissions Map image texture node name", default="Emissions Map Node")
hm_suffix: bpy.props.StringProperty(name="Height Map Suffix", description="Suffix of Height Map", default="")
hm_node_name: bpy.props.StringProperty(name="Height Map Node Name", description="Height Map image texture node name", default="")
hair_gradient_suffix: bpy.props.StringProperty(name="Hair Gradient Map Suffix", description="Suffix of Hair Gradient Map", default="")
hair_gradient_node_name: bpy.props.StringProperty(name="Hair Gradient Map Node Name", description="Hair Gradient Map image texture node name", default="")
specular_suffix: bpy.props.StringProperty(name="Specular Map Suffix", description="Suffix of Specular Map", default="")
specular_node_name: bpy.props.StringProperty(name="Specular Map Node Name", description="Specular Map image texture node name", default="")
gloss_suffix: bpy.props.StringProperty(name="Gloss Map Suffix", description="Suffix of Gloss Map", default="")
gloss_node_name: bpy.props.StringProperty(name="Gloss Map Node Name", description="Gloss Map image texture node name", default="")
#extra suffixes and node names
is_show_extra_textures: bpy.props.BoolProperty(name="Show Extra Suffix and Node Names", default= False)
roughness_suffix: bpy.props.StringProperty(name="Roughness Map Suffix", description="Suffix of Roughness Map", default="")
roughness_node_name: bpy.props.StringProperty(name="Roughness Map Node Name", description="Roughness Map image texture node name", default="")
metallic_suffix: bpy.props.StringProperty(name="Metallic Map Suffix", description="Suffix of Metallic Map", default="")
metallic_node_name: bpy.props.StringProperty(name="Metallic Map Node Name", description="Metallic Map image texture node name", default="")
subsurface_color_suffix: bpy.props.StringProperty(name="Subsurface Color Suffix", description="Suffix of Subsurface Color", default="")
subsurface_color_node_name: bpy.props.StringProperty(name="Subsurface Color Node Name", description="Subsurface Color image texture node name", default="")
subsurface_suffix: bpy.props.StringProperty(name="Subsurface Suffix", description="Suffix of Subsurface", default="")
subsurface_node_name: bpy.props.StringProperty(name="Subsurface Node Name", description="Subsurface image texture node name", default="")
ambient_occlusion_suffix: bpy.props.StringProperty(name="Ambient Occlusion Suffix", description="Suffix of Ambient Occlusion", default="")
ambient_occlusion_node_name: bpy.props.StringProperty(name="Ambient Occlusion Node Name", description="Ambient Occlusion image texture node name", default="")
detail_n_suffix: bpy.props.StringProperty(name="Detail Normal Map Suffix", description="Suffix of Detail Normal Map")
detail_n_node_name: bpy.props.StringProperty(name="Detail Normal Map Node Name", description="Detail Normal Map image texture node name")
wpo_suffix: bpy.props.StringProperty(name="World Position Offset Suffix", description="Suffix of World Position Offset", default="")
wpo_node_name: bpy.props.StringProperty(name="World Position Offset Node Name", description="World Position Offset image texture node name", default="")
tint_suffix: bpy.props.StringProperty(name="Tint Suffix", description="Suffix of Tint", default="")
tint_node_name: bpy.props.StringProperty(name="Tint Node Name", description="Tint image texture node name", default="")
normal_detail_suffix: bpy.props.StringProperty(name="Normal Detail Suffix", description="Suffix of Normal Detail", default="")
normal_detail_node_name: bpy.props.StringProperty(name="Normal Detail Node Name", description="Normal Detail image texture node name", default="")
roughness_detail_suffix: bpy.props.StringProperty(name="Roughness Detail Suffix", description="Suffix of Roughness Detail", default="")
roughness_detail_node_name: bpy.props.StringProperty(name="Roughness Detail Node Name", description="Roughness Detail image texture node name", default="")
smoothness_suffix: bpy.props.StringProperty(name="Smoothness Suffix", description="Suffix of Smoothness", default="")
smoothness_node_name: bpy.props.StringProperty(name="Smoothness Node Name", description="Smoothness image texture node name", default="")
edge_mask_suffix: bpy.props.StringProperty(name="Edge Mask Suffix", description="Suffix of Edge Mask", default="")
edge_mask_node_name: bpy.props.StringProperty(name="Edge Mask Node Name", description="Edge Mask image texture node name", default="")
transmission_suffix: bpy.props.StringProperty(name="Transmission Suffix", description="Suffix of Transmission", default="")
transmission_node_name: bpy.props.StringProperty(name="Transmission Node Name", description="Transmission image texture node name", default="")
clearcoat_suffix: bpy.props.StringProperty(name="Clearcoat Suffix", description="Suffix of Clearcoat", default="")
clearcoat_node_name: bpy.props.StringProperty(name="Clearcoat Node Name", description="Clearcoat image texture node name", default="")
anisotropic_suffix: bpy.props.StringProperty(name="Anisotropic Suffix", description="Suffix of Anisotropic", default="")
anisotropic_suffix_node_name: bpy.props.StringProperty(name="Anisotropic Node Name", description="Anisotropic image texture node name", default="")
sheen_suffix: bpy.props.StringProperty(name="Sheen Suffix", description="Suffix of Sheen", default="")
sheen_node_name: bpy.props.StringProperty(name="Sheen Node Name", description="Sheen image texture node name", default="")
glass_mask_suffix: bpy.props.StringProperty(name="Glass Mask Suffix", description="Suffix of Glass Mask", default="")
glass_mask_node_name: bpy.props.StringProperty(name="Glass Mask Node Name", description="Glass Mask image texture node name", default="")
#splat + environment textures
is_show_env_textures: bpy.props.BoolProperty(name="Show Environment + Suffix Suffix and Node Names", default= False)
splat_suffix: bpy.props.StringProperty(name="Splat Suffix", description="Suffix of Splat", default="")
splat_node_name: bpy.props.StringProperty(name="Splat Node Name", description="Splat image texture node name", default="")
red_bc_suffix: bpy.props.StringProperty(name="Red Diffuse Suffix", description="Suffix of Red Diffuse", default="")
red_bc_node_name: bpy.props.StringProperty(name="Red Diffuse Node Name", description="Red Diffuse image texture node name", default="")
red_orm_suffix: bpy.props.StringProperty(name="Red Packed RGB ARM Suffix", description="Suffix of Red Packed RGB ARM", default="")
red_orm_node_name: bpy.props.StringProperty(name="Red Packed RGB ARM Node Name", description="Red Packed RGB ARM image texture node name", default="")
red_n_suffix: bpy.props.StringProperty(name="Red Normal Suffix", description="Suffix of Red Normal", default="")
red_n_node_name: bpy.props.StringProperty(name="Red Normal Node Name", description="Red Normal image texture node name", default="")
red_e_suffix: bpy.props.StringProperty(name="Red Emissions Map Suffix", description="Suffix of Red Emissions Map")
red_e_node_name: bpy.props.StringProperty(name="Red Emissions Map Node Name", description="Red Emissions Map image texture node name")
green_bc_suffix: bpy.props.StringProperty(name="Green Diffuse Suffix", description="Suffix of Green Diffuse", default="")
green_bc_node_name: bpy.props.StringProperty(name="Green Diffuse Node Name", description="Green Diffuse image texture node name", default="")
green_orm_suffix: bpy.props.StringProperty(name="Green Packed RGB ARM Suffix", description="Suffix of Green Packed RGB ARM", default="")
green_orm_node_name: bpy.props.StringProperty(name="Green Packed RGB ARM Node Name", description="Green Packed RGB ARM image texture node name", default="")
green_n_suffix: bpy.props.StringProperty(name="Green Normal Suffix", description="Suffix of Green Normal", default="")
green_n_node_name: bpy.props.StringProperty(name="Green Normal Node Name", description="Green Normal image texture node name", default="")
green_e_suffix: bpy.props.StringProperty(name="Green Emissions Map Suffix", description="Suffix of Green Emissions Map")
green_e_node_name: bpy.props.StringProperty(name="Green Emissions Map Node Name", description="Green Emissions Map image texture node name")
blue_bc_suffix: bpy.props.StringProperty(name="Blue Diffuse Suffix", description="Suffix of Blue Diffuse", default="")
blue_bc_node_name: bpy.props.StringProperty(name="Blue Diffuse Node Name", description="Blue Diffuse image texture node name", default="")
blue_orm_suffix: bpy.props.StringProperty(name="Blue Packed RGB ARM Suffix", description="Suffix of Blue Packed RGB ARM", default="")
blue_orm_node_name: bpy.props.StringProperty(name="Blue Packed RGB ARM Node Name", description="Blue Packed RGB ARM image texture node name", default="")
blue_n_suffix: bpy.props.StringProperty(name="Blue Normal Suffix", description="Suffix of Blue Normal", default="")
blue_n_node_name: bpy.props.StringProperty(name="Blue Normal Node Name", description="Blue Normal image texture node name", default="")
blue_e_suffix: bpy.props.StringProperty(name="Blue Emissions Map Suffix", description="Suffix of Blue Emissions Map")
blue_e_node_name: bpy.props.StringProperty(name="Blue Emissions Map Node Name", description="Blue Emissions Map image texture node name")
cyan_bc_suffix: bpy.props.StringProperty(name="Cyan Diffuse Suffix", description="Suffix of Cyan Diffuse", default="")
cyan_bc_node_name: bpy.props.StringProperty(name="Cyan Diffuse Node Name", description="Cyan Diffuse image texture node name", default="")
cyan_orm_suffix: bpy.props.StringProperty(name="Cyan Packed RGB ARM Suffix", description="Suffix of Cyan Packed RGB ARM", default="")
cyan_orm_node_name: bpy.props.StringProperty(name="Cyan Packed RGB ARM Node Name", description="Cyan Packed RGB ARM image texture node name", default="")
cyan_n_suffix: bpy.props.StringProperty(name="Cyan Normal Suffix", description="Suffix of Cyan Normal", default="")
cyan_n_node_name: bpy.props.StringProperty(name="Cyan Normal Node Name", description="Cyan Normal image texture node name", default="")
cyan_e_suffix: bpy.props.StringProperty(name="Cyan Emissions Map Suffix", description="Suffix of Cyan Emissions Map")
cyan_e_node_name: bpy.props.StringProperty(name="Cyan Emissions Map Node Name", description="Cyan Emissions Map image texture node name")
alpha_bc_suffix: bpy.props.StringProperty(name="Alpha Diffuse Suffix", description="Suffix of Alpha Diffuse", default="")
alpha_bc_node_name: bpy.props.StringProperty(name="Alpha Diffuse Node Name", description="Alpha Diffuse image texture node name", default="")
alpha_orm_suffix: bpy.props.StringProperty(name="Alpha Packed RGB ARM Suffix", description="Suffix of Alpha Packed RGB ARM", default="")
alpha_orm_node_name: bpy.props.StringProperty(name="Alpha Packed RGB ARM Node Name", description="Alpha Packed RGB ARM image texture node name", default="")
alpha_n_suffix: bpy.props.StringProperty(name="Alpha Normal Suffix", description="Suffix of Alpha Normal", default="")
alpha_n_node_name: bpy.props.StringProperty(name="Alpha Normal Node Name", description="Alpha Normal image texture node name", default="")
alpha_e_suffix: bpy.props.StringProperty(name="Alpha Emissions Map Suffix", description="Suffix of Alpha Emissions Map")
alpha_e_node_name: bpy.props.StringProperty(name="Alpha Emissions Map Node Name", description="Alpha Emissions Map image texture node name")
moss_bc_suffix: bpy.props.StringProperty(name="Moss Diffuse Suffix", description="Suffix of Moss Diffuse", default="")
moss_bc_node_name: bpy.props.StringProperty(name="Moss Diffuse Node Name", description="Moss Diffuse image texture node name", default="")
moss_orm_suffix: bpy.props.StringProperty(name="Moss Packed RGB ARM Suffix", description="Suffix of Moss Packed RGB ARM", default="")
moss_orm_node_name: bpy.props.StringProperty(name="Moss Packed RGB ARM Node Name", description="Moss Packed RGB ARM image texture node name", default="")
moss_mask_suffix: bpy.props.StringProperty(name="Moss Mask Suffix", description="Suffix of Moss Mask", default="")
moss_mask_node_name: bpy.props.StringProperty(name="Moss Mask Node Name", description="Moss Mask image texture node name", default="")
leaves_bc_suffix: bpy.props.StringProperty(name="Leaves Diffuse Suffix", description="Suffix of Dirt", default="")
leaves_bc_node_name: bpy.props.StringProperty(name="Leaves Diffuse Node Name", description="Leaves Diffuse image texture node name", default="")
leaves_orm_suffix: bpy.props.StringProperty(name="Leaves Packed RGB ARM Suffix", description="Suffix of Leaves Packed RGB ARM", default="")
leaves_orm_node_name: bpy.props.StringProperty(name="Leaves Packed RGB ARM Node Name", description="Leaves Packed RGB ARM image texture node name", default="")
leaves_mask_suffix: bpy.props.StringProperty(name="Leaves Mask Suffix", description="Suffix of Leaves Mask", default="")
leaves_mask_node_name: bpy.props.StringProperty(name="Leaves Mask Node Name", description="Leaves Mask image texture node name", default="")
dirt_bc_suffix: bpy.props.StringProperty(name="Dirt Diffuse Suffix", description="Suffix of Dirt Diffuse", default="")
dirt_bc_node_name: bpy.props.StringProperty(name="Dirt Diffuse Node Name", description="Dirt Diffuse image texture node name", default="")
dirt_orm_suffix: bpy.props.StringProperty(name="Dirt Packed RGB ARM Suffix", description="Suffix of Dirt Packed RGB ARM", default="")
dirt_orm_node_name: bpy.props.StringProperty(name="Dirt Packed RGB ARM Node Name", description="Dirt Packed RGB ARM image texture node name", default="")
dirt_mask_suffix: bpy.props.StringProperty(name="Dirt Mask Suffix", description="Suffix of Dirt Mask", default="")
dirt_mask_node_name: bpy.props.StringProperty(name="Dirt Mask Node Name", description="Dirt Mask image texture node name", default="")
#tint textures
is_show_tint_textures: bpy.props.BoolProperty(name="Show Tint Suffix and Node Names", default= False)
#this is called base diffuse, because it is the color which is applied as
#a base before the tint is applied on top of the base color
tint_base_diffuse_suffix: bpy.props.StringProperty(name="Tint Base Diffuse Suffix", description="Suffix of Tint Base Diffuse Texture", default="")
tint_base_diffuse_node_name: bpy.props.StringProperty(name="Tint Base Diffuse Node Name", description="Tint Base Diffuse image texture node name", default="")
tint_mask_suffix: bpy.props.StringProperty(name="Tint Mask Suffix", description="Suffix of Tint Mask Texture", default="")
tint_mask_node_name: bpy.props.StringProperty(name="Tint Mask Node Name", description="Tint Mask image texture node name", default="")
tint_mask_suffix_2: bpy.props.StringProperty(name="Tint Mask Suffix 2", description="Suffix of Tint Mask 2 Texture", default="")
tint_mask_node_name_2: bpy.props.StringProperty(name="Tint Mask Node Name 2", description="Tint Mask 2 image texture node name", default="")
hair_tint_id_suffix: bpy.props.StringProperty(name="Hair Tint ID Suffix", description="Suffix of Hair Tint ID Texture", default="")
hair_tint_id_node_name: bpy.props.StringProperty(name="Hair Tint ID Node Name", description="Hair Tint image texture node name", default="")
#custom textures
is_show_custom_textures: bpy.props.BoolProperty(name="Show Custom Suffix and Node Names", default= False)
cust1_suffix: bpy.props.StringProperty(name="Custom1 Suffix", description="Suffix of Custom1 Texture", default="")
cust1_node_name: bpy.props.StringProperty(name="Custom1 Node Name", description="Custom1 image texture node name", default="")
cust2_suffix: bpy.props.StringProperty(name="Custom2 Suffix", description="Suffix of Custom2 Texture", default="")
cust2_node_name: bpy.props.StringProperty(name="Custom2 Node Name", description="Custom2 image texture node name", default="")
cust3_suffix: bpy.props.StringProperty(name="Custom3 Suffix", description="Suffix of Custom3 Texture", default="")
cust3_node_name: bpy.props.StringProperty(name="Custom3 Node Name", description="Custom3 image texture node name", default="")
cust4_suffix: bpy.props.StringProperty(name="Custom4 Suffix", description="Suffix of Custom4 Texture", default="")
cust4_node_name: bpy.props.StringProperty(name="Custom4 Node Name", description="Custom4 image texture node name", default="")
is_add_img_textures: bpy.props.BoolProperty(name="Load Image Textures to Shader Map Dynamically", default= True)
#enum property for using default suffixes
default_suffix_enum: bpy.props.EnumProperty(
name = "(Optional) Suffix/Node Name Preset",
description = "Default Suffix Type",
items =
[
("DBD_GENERAL" , "DBD Generic/Clothing/Basic", ""),
("DBD_HAIR" , "DBD Hair", ""),
("DBD_SKIN", "DBD Skin", ""),
("DBD_EYES" , "DBD Eyes", ""),
("DBD_ENVIRONMENT", "DBD Environment", ""),
("DBD_CLOTHING_TINT_RECOLOUR" , "DBD Tint Clothing Recolour", ""),
("DBD_HAIR_TINT_RECOLOUR" , "DBD Tint Hair Recolour", ""),
("FNAF_SECURITY_BREACH_ENVIRONMENT", "FNAF Security Breach Environment", ""),
("FORTNITE_BASIC", "Fortnite Basic", "")
]
)
is_show_regex_options: bpy.props.BoolProperty(name="Show Regex Advanced Options", default= False)
default_regex_props_txt_enum: bpy.props.EnumProperty(
name = "Regex Method for Textures and Type",
description = "Regex pattern used for finding texture Textures",
items =
[
("PARAMETER_INFO" , "props.txt ParameterInfo (e.g. Diffuse)", ""),
("SUFFIX" , "props.txt ParameterValue Suffix (e.g. _BC)", ""),
("UE5_PARAMETER_INFO", "Unreal Engine 5 json Parameter Info (e.g. Diffuse)", ""),
("OTHER", "Custom Regular Expression", "")
]
)
regex_props_txt: bpy.props.StringProperty(name="Custom Regex Pattern:",
description="Custom Regex pattern used for finding textures", default = "TextureParameterValues\[\d+\][\s\S]+?ParameterInfo = { Name=(.+) }[\s\S]+?Texture2D'(.*)\'")
total_capture_groups: bpy.props.EnumProperty(
name = "Total Capture Groups in Regular Expression",
description = "Total Number of Capture Groups in Regular Expression",
items =
[
("2" , "2", ""),
("1" , "1", "")
]
)
texture_type_capture_group_index: bpy.props.EnumProperty(
name = "Texture Type Capture Group Index",
description = "Texture Type Capture Group Index",
items =
[
("0" , "0", ""),
("1" , "1", ""),
]