-
Notifications
You must be signed in to change notification settings - Fork 10
/
load_shader_map.py
3706 lines (3086 loc) · 160 KB
/
load_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 all libraries including re needed for regex matching
#import Path library to search recursively for files
import bpy, re
import glob
from pathlib import Path
import base64
import time
import os
#import with relative imports
#import classes
from .save_shader_map import SHADER_PRESETS_UL_items, ShowMessageOperator, save_pref
#import functions
from .save_shader_map import get_preferences, get_selected_folder_presets, json_to_nodes_dict, log
#import pathlib for finding current working direction for LOADUESHADERSCRIPT_OT_use_custom_denoising
import pathlib
from mathutils import (Vector, Euler, Color)
#define globals
SHADER_EDITOR = "ShaderNodeTree"
COMPOSITOR_EDITOR = "CompositorNodeTree"
ANIMATION_NODE_EDITOR = "an_AnimationNodeTree"
# Special handled node types
NOT_NEEDED_NODE_TYPES = [
"NodeReroute"
]
# Not to handle atts for these node types
NOT_TO_HANDLE_ATTRS_NODES = [
# Need to handle CompositorNodeImage
# "CompositorNodeImage"
]
#need scene and context in order to be used within
#the x_color_space, such as the diffuse_color_space
#as a callback function for the items property
def color_spaces_callback(scene, context):
color_spaces = [
("sRGB" , "sRGB", ""),
("Non-Color" , "Non-Color", ""),
("Linear" , "Linear", ""),
("Filmic Log" , "Filmic Log", ""),
("Linear ACES" , "Linear ACES", ""),
("Raw" , "Raw", ""),
("XYZ" , "XYZ", "")
]
return color_spaces
#define all user input properties
class PathProperties(bpy.types.PropertyGroup):
#user input paths for textures and materials
props_txt_path: bpy.props.StringProperty(name="(!) Select PropsTxt File*", description="Select a props.txt file", subtype="FILE_PATH")
export_folder_path: bpy.props.StringProperty(name="(!) Select Exported Game Folder*", description="Select a Game folder", subtype="DIR_PATH")
#used to show the button and box to add a shader map to one material at a time
is_show_add_one_material_operator: bpy.props.BoolProperty(name="Show Add Shader Map to One Material Operator", default = False)
#used for the add shader maps to multiple materials operator
material_indices_list_string: bpy.props.StringProperty(name="(!) Indexes of Material Slots to be Loaded *", description="Enter the indices for the materials to be loaded", default = "0 1 2")
#--------------loading shader map settings
is_replace_nodes: bpy.props.BoolProperty(name="Replace Existing Shader Maps", default = True)
texture_file_type_enum: bpy.props.EnumProperty(
name = "Texture File Type",
description = "Dropdown List of all the texture file types",
items =
[
(".tga" , ".tga", ""),
(".png" , ".png", ""),
(".jpg", ".jpg", ""),
(".bmp", ".bmp", ""),
(".dds", ".dds", "")
]
)
clipping_method_enum: bpy.props.EnumProperty(
name = "Alpha Clipping Method",
description = "Dropdown List of all the texture file types",
items =
[
("CLIP" , "Alpha Clip", ""),
("HASHED" , "Alpha Hashed", ""),
("BLEND", "Alpha Blend", "")
]
)
is_load_img_textures: bpy.props.BoolProperty(name="Load Image Textures Dynamically", default= True)
is_delete_unused_img_texture_nodes: bpy.props.BoolProperty(name="Delete Unused Image Texture Nodes", default = True)
is_delete_unused_related_nodes: bpy.props.BoolProperty(name="Delete Unused Image Texture Nodes AND Related Nodes (Slower)", default = True)
is_change_principle_bsdf_emission_strength: bpy.props.BoolProperty(name="Change Principled BSDF Node Strength if Emissions Texture Loaded", default = True)
principled_bsdf_emission_strength_float: bpy.props.FloatProperty(name="Principled BSDF Emission Strength if Emissions Texture Loaded", default = 5.0)
material_alpha_threshold: bpy.props.FloatProperty(name="Material Clip Threshold if Transparency Texture Loaded", default = 0.3333)
#options to allow reuse of node groups and image textures
is_reuse_node_group_with_same_name: bpy.props.BoolProperty(name="Reuse Node Groups With Same Name", default = True)
is_reuse_img_texture_with_same_name: bpy.props.BoolProperty(name="Reuse Image Textures With Same Name", default = True)
#in case of overlap decide if first or last texture in props
#txt file takes priority this is done by
#reversing or not reversing the match_list
reverse_match_list_from_props_txt_enum: bpy.props.EnumProperty(
name = "Overlapping Textures Priority",
description = "If Dynamically Loaded Textures Overlap Choose Priority",
items =
[
("Reverse Match List" , "First in Materials Info File/props.txt Takes Priority (First > Last)", ""),
("Don't Reverse Match List" , "Last in Materials Info File/props.txt Takes Priority (Last > First)", "")
]
)
is_use_recolor_values: bpy.props.BoolProperty(name="Use Recolor RGB Colour Values", default = True)
is_add_non_match_textures: bpy.props.BoolProperty(name="Add Non Matching Textures from Props.txt file", default = False)
#---------------color space settings enums
#default global variables for the recommended
#colour spaces for image textures
#srgb color space isn't used but it is there for reference purposes
# srgb_color_space_list = ["diffuse", "tint_base_diffuse", "cust1", "cust2", "cust3", "cust4"]
# non_color_space_list = ["normal", "packed_orm", "emissive", "tint_mask", "specular", "gloss"]
# linear_color_space_list = ["transparency", "height", "hair_gradient"]
#set default for only those which are not srgb color space
#because the default color space is srgb the 0th option
#so if not stated the default is sRGB
diffuse_color_space: bpy.props.EnumProperty(
name = "Diffuse Color Space",
description = "Diffuse Image Texture Color Space",
#don't call the function immediately with ()
#but wait for the enum property to be defined
items = color_spaces_callback
#no default means sRGB
)
packed_rgb_color_space: bpy.props.EnumProperty(
name = "Packed RGB Color Space",
description = "Packed RGB Image Texture Color Space",
items = color_spaces_callback,
#1 means Non-Color
default = 1
)
normal_color_space: bpy.props.EnumProperty(
name = "Normal Color Space",
description = "Normal Map Image Texture Color Space",
items = color_spaces_callback,
#1 means Non-Color
default = 1
)
alpha_color_space: bpy.props.EnumProperty(
name = "Alpha Color Space",
description = "Alpha Image Texture Color Space",
items = color_spaces_callback,
#2 means Linear
default = 2
)
emissions_color_space: bpy.props.EnumProperty(
name = "Emissions Color Space",
description = "Emissions Map Image Texture Color Space",
items = color_spaces_callback,
#1 means Non-Color
default = 1
)
height_color_space: bpy.props.EnumProperty(
name = "Height Color Space",
description = "Height Map Image Texture Color Space",
items = color_spaces_callback,
#2 means Linear
default = 2
)
hair_gradient_color_space: bpy.props.EnumProperty(
name = "Hair Gradient Color Space",
description = "Hair Gradient Image Texture Color Space",
items = color_spaces_callback,
#2 means Linear
default = 2
)
specular_color_space: bpy.props.EnumProperty(
name = "Specular Color Space",
description = "Specular Image Texture Color Space",
items = color_spaces_callback,
#1 means Non-Color
default = 1
)
gloss_color_space: bpy.props.EnumProperty(
name = "Gloss Color Space",
description = "Gloss Image Texture Color Space",
items = color_spaces_callback,
#1 means Non-Color
default = 1
)
#------extra texture color spaces
roughness_color_space: bpy.props.EnumProperty(
name = "Roughness Color Space",
description = "Roughness Image Texture Color Space",
items = color_spaces_callback,
#1 means Non-Color
default = 1
)
metallic_color_space: bpy.props.EnumProperty(
name = "Metallic Color Space",
description = "Metallic Image Texture Color Space",
items = color_spaces_callback,
#1 means Non-Color
default = 1
)
subsurface_color_color_space: bpy.props.EnumProperty(
name = "Subsurface Color Color Space",
description = "Subsurface Color Image Texture Color Space",
items = color_spaces_callback
#no default means sRGB
)
subsurface_color_space: bpy.props.EnumProperty(
name = "Subsurface Color Space",
description = "Subsurface Image Texture Color Space",
items = color_spaces_callback,
#1 means Non-Color
default = 1
)
ambient_occlusion_color_space: bpy.props.EnumProperty(
name = "Ambient Occlusion Color Space",
description = "Ambient Occlusion Image Texture Color Space",
items = color_spaces_callback,
#1 means Non-Color
default = 1
)
detail_n_color_space: bpy.props.EnumProperty(
name = "Detail Normal Color Space",
description = "Detail Normal Image Texture Color Space",
items = color_spaces_callback,
#1 means Non-Color
default = 1
)
wpo_color_space: bpy.props.EnumProperty(
name = "World Position Offset Color Space",
description = "World Position Offset Image Texture Color Space",
items = color_spaces_callback,
#1 means Non-Color
default = 1
)
tint_color_space: bpy.props.EnumProperty(
name = "Tint Color Space",
description = "Tint Image Texture Color Space",
items = color_spaces_callback
#no default means sRGB
)
normal_detail_color_space: bpy.props.EnumProperty(
name = "Normal Detail Color Space",
description = "Normal Detail Image Texture Color Space",
items = color_spaces_callback,
#1 means Non-Color
default = 1
)
roughness_detail_color_space: bpy.props.EnumProperty(
name = "Roughness Detail Color Space",
description = "Roughness Detail Image Texture Color Space",
items = color_spaces_callback,
#1 means Non-Color
default = 1
)
smoothness_color_space: bpy.props.EnumProperty(
name = "Smoothness Color Space",
description = "Smoothness Image Texture Color Space",
items = color_spaces_callback,
#1 means Non-Color
default = 1
)
edge_mask_color_space: bpy.props.EnumProperty(
name = "Edge Mask Color Space",
description = "Edge Mask Image Texture Color Space",
items = color_spaces_callback,
#1 means Non-Color
default = 1
)
transmission_color_space: bpy.props.EnumProperty(
name = "Transmission Color Space",
description = "Transmission Image Texture Color Space",
items = color_spaces_callback,
#1 means Non-Color
default = 1
)
clearcoat_color_space: bpy.props.EnumProperty(
name = "Clearcoat Color Space",
description = "Clearcoat Image Texture Color Space",
items = color_spaces_callback,
#1 means Non-Color
default = 1
)
anisotropic_color_space: bpy.props.EnumProperty(
name = "Anisotropic Color Space",
description = "Anisotropic Image Texture Color Space",
items = color_spaces_callback,
#1 means Non-Color
default = 1
)
sheen_color_space: bpy.props.EnumProperty(
name = "Sheen Color Space",
description = "Sheen Image Texture Color Space",
items = color_spaces_callback,
#1 means Non-Color
default = 1
)
glass_mask_color_space: bpy.props.EnumProperty(
name = "Glass Mask Color Space",
description = "Glass Mask Image Texture Color Space",
items = color_spaces_callback,
#1 means Non-Color
default = 1
)
#------splat + environment textures
splat_color_space: bpy.props.EnumProperty(
name = "Splat Color Space",
description = "Splat Image Texture Color Space",
items = color_spaces_callback,
#1 means Non-Color
default = 1
)
red_bc_color_space: bpy.props.EnumProperty(
name = "Red Diffuse Color Space",
description = "Red Diffuse Image Texture Color Space",
items = color_spaces_callback
#no default means sRGB
)
red_orm_color_space: bpy.props.EnumProperty(
name = "Red Packed RGB Color Space",
description = "Red Packed RGB Image Texture Color Space",
items = color_spaces_callback,
#1 means Non-Color
default = 1
)
red_n_color_space: bpy.props.EnumProperty(
name = "Red Normal Color Space",
description = "Red Normal Image Texture Color Space",
items = color_spaces_callback,
#1 means Non-Color
default = 1
)
red_e_color_space: bpy.props.EnumProperty(
name = "Red Emissions Color Space",
description = "Red Emissions Image Texture Color Space",
items = color_spaces_callback,
#1 means Non-Color
default = 1
)
green_bc_color_space: bpy.props.EnumProperty(
name = "Green Diffuse Color Space",
description = "Green Diffuse Image Texture Color Space",
items = color_spaces_callback
#no default means sRGB
)
green_orm_color_space: bpy.props.EnumProperty(
name = "Green Packed RGB Color Space",
description = "Green Packed RGB Image Texture Color Space",
items = color_spaces_callback,
#1 means Non-Color
default = 1
)
green_n_color_space: bpy.props.EnumProperty(
name = "Green Normal Color Space",
description = "Green Normal Image Texture Color Space",
items = color_spaces_callback,
#1 means Non-Color
default = 1
)
green_e_color_space: bpy.props.EnumProperty(
name = "Green Emissions Color Space",
description = "Green Emissions Image Texture Color Space",
items = color_spaces_callback,
#1 means Non-Color
default = 1
)
blue_bc_color_space: bpy.props.EnumProperty(
name = "Blue Diffuse Color Space",
description = "Blue Diffuse Image Texture Color Space",
items = color_spaces_callback
#no default means sRGB
)
blue_orm_color_space: bpy.props.EnumProperty(
name = "Blue Packed RGB Color Space",
description = "Blue Packed RGB Image Texture Color Space",
items = color_spaces_callback,
#1 means Non-Color
default = 1
)
blue_n_color_space: bpy.props.EnumProperty(
name = "Blue Normal Color Space",
description = "Blue Normal Image Texture Color Space",
items = color_spaces_callback,
#1 means Non-Color
default = 1
)
blue_e_color_space: bpy.props.EnumProperty(
name = "Blue Emissions Color Space",
description = "Blue Emission Image Texture Color Space",
items = color_spaces_callback,
#1 means Non-Color
default = 1
)
cyan_bc_color_space: bpy.props.EnumProperty(
name = "Cyan Diffuse Color Space",
description = "Cyan Diffuse Image Texture Color Space",
items = color_spaces_callback
#no default means sRGB
)
cyan_orm_color_space: bpy.props.EnumProperty(
name = "Cyan Packed RGB Color Space",
description = "Cyan Packed RGB Image Texture Color Space",
items = color_spaces_callback,
#1 means Non-Color
default = 1
)
cyan_n_color_space: bpy.props.EnumProperty(
name = "Cyan Normal Color Space",
description = "Cyan Normal Image Texture Color Space",
items = color_spaces_callback,
#1 means Non-Color
default = 1
)
cyan_e_color_space: bpy.props.EnumProperty(
name = "Cyan Emissions Color Space",
description = "Cyan Emissions Image Texture Color Space",
items = color_spaces_callback,
#1 means Non-Color
default = 1
)
alpha_bc_color_space: bpy.props.EnumProperty(
name = "Alpha Diffuse Color Space",
description = "Alpha Diffuse Image Texture Color Space",
items = color_spaces_callback
#no default means sRGB
)
alpha_orm_color_space: bpy.props.EnumProperty(
name = "Alpha Packed RGB Color Space",
description = "Alpha Packed RGB Image Texture Color Space",
items = color_spaces_callback,
#1 means Non-Color
default = 1
)
alpha_n_color_space: bpy.props.EnumProperty(
name = "Alpha Normal Color Space",
description = "Alpha Normal Image Texture Color Space",
items = color_spaces_callback,
#1 means Non-Color
default = 1
)
alpha_e_color_space: bpy.props.EnumProperty(
name = "Alpha Emissions Color Space",
description = "Alpha Emissions Image Texture Color Space",
items = color_spaces_callback,
#1 means Non-Color
default = 1
)
moss_bc_color_space: bpy.props.EnumProperty(
name = "Moss Diffuse Color Space",
description = "Moss Diffuse Image Texture Color Space",
items = color_spaces_callback
#no default means sRGB
)
moss_orm_color_space: bpy.props.EnumProperty(
name = "Moss Packed RGB Color Space",
description = "Moss Packed RGB Image Texture Color Space",
items = color_spaces_callback,
#1 means Non-Color
default = 1
)
moss_mask_color_space: bpy.props.EnumProperty(
name = "Moss Mask Color Space",
description = "Moss Mask Image Texture Color Space",
items = color_spaces_callback,
#1 means Non-Color
default = 1
)
leaves_bc_color_space: bpy.props.EnumProperty(
name = "Leaves Diffuse Color Space",
description = "Leaves Diffuse Image Texture Color Space",
items = color_spaces_callback
#no default means sRGB
)
leaves_orm_color_space: bpy.props.EnumProperty(
name = "Leaves Packed RGB Color Space",
description = "Leaves Packed RGB Image Texture Color Space",
items = color_spaces_callback,
#1 means Non-Color
default = 1
)
leaves_mask_color_space: bpy.props.EnumProperty(
name = "Leaves Mask Color Space",
description = "Leaves Mask Image Texture Color Space",
items = color_spaces_callback,
#1 means Non-Color
default = 1
)
dirt_bc_color_space: bpy.props.EnumProperty(
name = "Dirt Diffuse Color Space",
description = "Dirt Diffuse Image Texture Color Space",
items = color_spaces_callback
#no default means sRGB
)
dirt_orm_color_space: bpy.props.EnumProperty(
name = "Dirt Packed RGB Color Space",
description = "Dirt Packed RGB Image Texture Color Space",
items = color_spaces_callback,
#1 means Non-Color
default = 1
)
dirt_mask_color_space: bpy.props.EnumProperty(
name = "Dirt Mask Color Space",
description = "Dirt Mask Image Texture Color Space",
items = color_spaces_callback,
#1 means Non-Color
default = 1
)
#------tint color spaces
tint_base_diffuse_color_space: bpy.props.EnumProperty(
name = "Tint Base Diffuse Color Space",
description = "Tint Base Diffuse Image Texture Color Space",
items = color_spaces_callback
)
tint_mask_color_space: bpy.props.EnumProperty(
name = "Tint Mask Color Space",
description = "Tint Mask Image Texture Color Space",
items = color_spaces_callback,
#1 means Non-Color
default = 1
)
tint_mask_2_color_space: bpy.props.EnumProperty(
name = "Tint Mask 2 Color Space",
description = "Tint Mask 2 Image Texture Color Space",
items = color_spaces_callback,
#1 means Non-Color
default = 1
)
hair_tint_id_color_space: bpy.props.EnumProperty(
name = "Hair Tint ID Color Space",
description = "Hair Tint ID Image Texture Color Space",
items = color_spaces_callback,
#2 means Linear
default = 2
)
#------custom color spaces
# all custom textures are by default Non-Color color space
cust1_color_space: bpy.props.EnumProperty(
name = "Custom1 Color Space",
description = "Custom1 Image Texture Color Space",
items = color_spaces_callback,
#1 means Non-Color
default = 1
)
cust2_color_space: bpy.props.EnumProperty(
name = "Custom2 Color Space",
description = "Custom2 Image Texture Color Space",
items = color_spaces_callback,
#1 means Non-Color
default = 1
)
cust3_color_space: bpy.props.EnumProperty(
name = "Custom3 Color Space",
description = "Custom3 Image Texture Color Space",
items = color_spaces_callback,
#1 means Non-Color
default = 1
)
cust4_color_space: bpy.props.EnumProperty(
name = "Custom4 Color Space",
description = "Custom4 Image Texture Color Space",
items = color_spaces_callback,
#1 means Non-Color
default = 1
)
non_match_color_space: bpy.props.EnumProperty(
name = "Non Match Textures Color Space",
description = "Non Match Image Textures Color Space",
items = color_spaces_callback,
#1 means Non-Color
default = 1
)
#advanced settings
props_txt_file_type: bpy.props.StringProperty(name="File extension for material info files:",
description="File extension for material info files, props.txt file equivalents", default = ".props.txt")
# Debug console options
#show textures from the props.txt file that did not match suffixes
#but were added to the shader map anyway for debug purposes
is_show_no_match_tex_debug: bpy.props.BoolProperty(name="Show Non Suffix Matching Textures in Console (Debug) ", default = False)
#show the abs_props_txt path in the debug console
is_show_abs_props_debug: bpy.props.BoolProperty(name="Show props.txt File Path in Console (Debug)", default = False)
#This is NOT a property that will show on any panel and the user
#cannot interact with this variable
#it is used to trigger a flag when accessing bpy.ops to save
#to the default preferences is not possible
#it will raise this boolean so the next time the user loads
#any preset it will make the add on preferences for the current file to be
#the default preferences
#it is set to true when the plugin is initialised and will be immediately
#set to false upon the first load shader map completion
is_save_to_default_preferences_on_next_load_shader_map: bpy.props.BoolProperty(name="N/A", default = True)
#------------code for drawing main panel in the 3D View
#don't register this class it is not a bpy panel or type so
#it does not need to be registered
class LOADUESHADERSCRIPT_shared_main_panel:
# bl_label = "Load UE Shaders"
# bl_idname = "LOADUESHADERSCRIPT_PT_main_panel"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
bl_category = "UE"
#main panel part 1
#inheriting the shared panel's bl_space_type, bl_region_type and bl_category
class LOADUESHADERSCRIPT_PT_select_preset_main_panel_1(LOADUESHADERSCRIPT_shared_main_panel, bpy.types.Panel):
bl_label = "Select Preset in Folder"
bl_idname = "LOADUESHADERSCRIPT_PT_select_preset_main_panel_1"
def draw(self, context):
layout = self.layout
#set isOverridePackage to override __package__ variable as it does
#not work for imported functions
isOverridePackage = True
preferences = get_preferences(isOverridePackage)
#make folder section
box = layout.box()
row = box.row()
row.label(text="Folders")
row = box.row()
left = row.column()
left.alignment = "RIGHT"
left.prop(preferences, 'folders', expand=False)
selected_folders_presets = get_selected_folder_presets(isOverridePackage)
#create the list of current presets
layout.template_list("SHADER_PRESETS_UL_items", "", selected_folders_presets,
"presets", selected_folders_presets, "preset_index", rows=5)
#main panel part 2
#inheriting the shared panel's bl_space_type, bl_region_type and bl_category
class LOADUESHADERSCRIPT_PT_load_settings_main_panel_2(LOADUESHADERSCRIPT_shared_main_panel, bpy.types.Panel):
bl_label = "Load Shader Map Settings"
bl_idname = "LOADUESHADERSCRIPT_PT_load_settings_main_panel_2"
bl_options = {"DEFAULT_CLOSED"}
def draw(self, context):
layout = self.layout
#store active/selected scene to variable
scene = context.scene
#allow access to user inputted properties through pointer
#to properties
pathtool = scene.path_tool
#--------make load shader map settings section
layout.prop(pathtool, "is_load_img_textures")
#option to replace or keep existing nodes in materials
layout.prop(pathtool, "is_replace_nodes")
if(pathtool.is_load_img_textures):
#option to delete image texture nodes which have not had a texture
#loaded into them
layout.prop(pathtool, "is_delete_unused_img_texture_nodes")
#only show this option if delete unused_img_texture_nodes is checked
if(pathtool.is_delete_unused_img_texture_nodes):
layout.prop(pathtool, "is_delete_unused_related_nodes")
layout.prop(pathtool, "texture_file_type_enum")
layout.prop(pathtool, "is_reuse_node_group_with_same_name")
layout.prop(pathtool, "is_reuse_img_texture_with_same_name")
layout.prop(pathtool, "reverse_match_list_from_props_txt_enum")
layout.prop(pathtool, "is_use_recolor_values")
layout.prop(pathtool, "is_add_non_match_textures")
#main panel part 3
#inheriting the shared panel's bl_space_type, bl_region_type and bl_category
class LOADUESHADERSCRIPT_PT_alpha_emissive_main_panel_3(LOADUESHADERSCRIPT_shared_main_panel, bpy.types.Panel):
bl_label = "Alpha and Emissive Settings"
bl_idname = "LOADUESHADERSCRIPT_PT_alpha_emissive_main_panel_3"
#put parent id so it knows this is a subpanel of the parent panel
bl_options = {"DEFAULT_CLOSED"}
#poll function only allows
#execute and draw functions to be executed
#if poll returns true
#in this case depends upon whether the
#is_load_img_textures settings is true
#if false then don't draw the advanced settings panel
@classmethod
def poll(self, context):
#store active scene to variable
scene = context.scene
#allow access to user inputted properties through pointer
#to properties
pathtool = scene.path_tool
return pathtool.is_load_img_textures
def draw(self, context):
layout = self.layout
#store active scene to variable
scene = context.scene
#allow access to user inputted properties through pointer
#to properties
pathtool = scene.path_tool
layout.prop(pathtool, "clipping_method_enum")
layout.prop(pathtool, "material_alpha_threshold")
layout.prop(pathtool, "is_change_principle_bsdf_emission_strength")
if(pathtool.is_change_principle_bsdf_emission_strength):
layout.prop(pathtool, "principled_bsdf_emission_strength_float")
#main panel part 4
#inheriting the shared panel's bl_space_type, bl_region_type and bl_category
class LOADUESHADERSCRIPT_PT_color_space_main_panel_4(LOADUESHADERSCRIPT_shared_main_panel, bpy.types.Panel):
bl_label = "Color Space Settings"
bl_idname = "LOADUESHADERSCRIPT_PT_color_space_main_panel_4"
bl_options = {"DEFAULT_CLOSED"}
#poll function only allows
#execute and draw functions to be executed
#if poll returns true
#in this case depends upon whether the
#is_load_img_textures settings is true
#if false then don't draw the advanced settings panel
@classmethod
def poll(self, context):
#store active scene to variable
scene = context.scene
#allow access to user inputted properties through pointer
#to properties
pathtool = scene.path_tool
return pathtool.is_load_img_textures
def draw(self, context):
layout = self.layout
#store active scene to variable
scene = context.scene
#allow access to user inputted properties through pointer
#to properties
pathtool = scene.path_tool
#formatting default blender attribute
#layout.use_property_split means that it will try and display
#the property label fully
layout.use_property_split = True
#prevent the animate button appearing to the right side
#of the enum properties
layout.use_property_decorate = False
layout.label(text = "Please do not change these settings unless you know what you are doing.")
layout.prop(pathtool, "diffuse_color_space")
layout.prop(pathtool, "packed_rgb_color_space")
layout.prop(pathtool, "normal_color_space")
layout.prop(pathtool, "alpha_color_space")
layout.prop(pathtool, "emissions_color_space")
layout.prop(pathtool, "height_color_space")
layout.prop(pathtool, "hair_gradient_color_space")
layout.prop(pathtool, "specular_color_space")
layout.prop(pathtool, "gloss_color_space")
layout.prop(pathtool, "roughness_color_space")
layout.prop(pathtool, "metallic_color_space")
layout.prop(pathtool, "subsurface_color_color_space")
layout.prop(pathtool, "subsurface_color_space")
layout.prop(pathtool, "ambient_occlusion_color_space")
layout.prop(pathtool, "detail_n_color_space")
layout.prop(pathtool, "wpo_color_space")
layout.prop(pathtool, "tint_color_space")
layout.prop(pathtool, "normal_detail_color_space")
layout.prop(pathtool, "roughness_detail_color_space")
layout.prop(pathtool, "smoothness_color_space")
layout.prop(pathtool, "edge_mask_color_space")
layout.prop(pathtool, "transmission_color_space")
layout.prop(pathtool, "clearcoat_color_space")
layout.prop(pathtool, "anisotropic_color_space")
layout.prop(pathtool, "sheen_color_space")
layout.prop(pathtool, "glass_mask_color_space")
layout.prop(pathtool, "splat_color_space")
layout.prop(pathtool, "red_bc_color_space")
layout.prop(pathtool, "red_orm_color_space")
layout.prop(pathtool, "red_n_color_space")
layout.prop(pathtool, "red_e_color_space")
layout.prop(pathtool, "green_bc_color_space")
layout.prop(pathtool, "green_orm_color_space")
layout.prop(pathtool, "green_n_color_space")
layout.prop(pathtool, "green_e_color_space")
layout.prop(pathtool, "blue_bc_color_space")
layout.prop(pathtool, "blue_orm_color_space")
layout.prop(pathtool, "blue_e_color_space")
layout.prop(pathtool, "cyan_bc_color_space")
layout.prop(pathtool, "cyan_orm_color_space")
layout.prop(pathtool, "cyan_n_color_space")
layout.prop(pathtool, "cyan_e_color_space")
layout.prop(pathtool, "alpha_bc_color_space")
layout.prop(pathtool, "alpha_orm_color_space")
layout.prop(pathtool, "alpha_n_color_space")
layout.prop(pathtool, "alpha_e_color_space")
layout.prop(pathtool, "moss_bc_color_space")
layout.prop(pathtool, "moss_orm_color_space")
layout.prop(pathtool, "moss_mask_color_space")
layout.prop(pathtool, "leaves_bc_color_space")
layout.prop(pathtool, "leaves_orm_color_space")
layout.prop(pathtool, "leaves_mask_color_space")
layout.prop(pathtool, "dirt_bc_color_space")
layout.prop(pathtool, "dirt_orm_color_space")
layout.prop(pathtool, "dirt_mask_color_space")
layout.prop(pathtool, "tint_base_diffuse_color_space")
layout.prop(pathtool, "tint_mask_color_space")
layout.prop(pathtool, "tint_mask_2_color_space")
layout.prop(pathtool, "hair_tint_id_color_space")
layout.prop(pathtool, "cust1_color_space")
layout.prop(pathtool, "cust2_color_space")
layout.prop(pathtool, "cust3_color_space")
layout.prop(pathtool, "cust4_color_space")
layout.separator()
layout.label(text = "(Need Load Shader Map Settings > Add Non Match enabled to do anything)")
layout.prop(pathtool, "non_match_color_space")
#main panel part 5
#inheriting the shared panel's bl_space_type, bl_region_type and bl_category
class LOADUESHADERSCRIPT_PT_advanced_settings_main_panel_5(LOADUESHADERSCRIPT_shared_main_panel, bpy.types.Panel):
bl_label = "Advanced Settings"
bl_idname = "LOADUESHADERSCRIPT_PT_advanced_settings_main_panel_5"
bl_options = {"DEFAULT_CLOSED"}
#poll function only allows
#execute and draw functions to be executed
#if poll returns true
#in this case depends upon whether the
#is_load_img_textures settings is true
#if false then don't draw the advanced settings panel
@classmethod
def poll(self, context):
#store active scene to variable
scene = context.scene
#allow access to user inputted properties through pointer
#to properties
pathtool = scene.path_tool
return pathtool.is_load_img_textures
def draw(self, context):
layout = self.layout
#store active scene to variable
scene = context.scene
#allow access to user inputted properties through pointer
#to properties
pathtool = scene.path_tool
#showing debug console file path
#this is if debugging is required
#enable this option so you can see which textures from
#the props.txt file never matched anything
layout.prop(pathtool, "is_show_no_match_tex_debug")
#enable this option so then you can see which material is causing the problem
#do this before use_property split so it is not affected by the use_property_spli
#because it looks bad with use property split
layout.prop(pathtool, "is_show_abs_props_debug")
#formatting default blender attribute
#layout.use_property_split means that it will try and display
#the property label fully
layout.use_property_split = True
layout.label(text = "Please only change these settings if you know what you are doing")
layout.prop(pathtool, "props_txt_file_type")
#main panel part 6
#inheriting the shared panel's bl_space_type, bl_region_type and bl_category
class LOADUESHADERSCRIPT_PT_reset_settings_main_panel_6(LOADUESHADERSCRIPT_shared_main_panel, bpy.types.Panel):
bl_label = "Reset Load Shader Map Settings"
bl_idname = "LOADUESHADERSCRIPT_PT_reset_settings_main_panel_6"
#hide header means to hide the title because we
#just want to see the button here
#not the bl_label
#bl_options = {"HIDE_HEADER"}
def draw(self, context):
layout = self.layout
layout.operator("loadueshaderscript.reset_settings_main_panel_operator")
#main panel part 7
#inheriting the shared panel's bl_space_type, bl_region_type and bl_category
class LOADUESHADERSCRIPT_PT_load_methods_main_panel_7(LOADUESHADERSCRIPT_shared_main_panel, bpy.types.Panel):
bl_label = "Load Shader Map Methods"