@@ -112,7 +112,38 @@ def apply(self, groupNode, properties):
112
112
if len (value_arr ) == 3 :
113
113
value_arr .append (1.0 )
114
114
115
- groupNode .inputs [self .color_dest ].default_value = value_arr
115
+ groupNode .inputs [self .color_dest ].default_value = value_arr
116
+
117
+ class FloatRgbaAlphaMapping :
118
+ def __init__ (self , property_name : str , color_dest : str ):
119
+ self .property_name = property_name
120
+ self .color_dest = color_dest
121
+
122
+ def __repr__ (self ):
123
+ return f"FloatRgbAlphaMapping({ self .property_name } , { self .color_dest } )"
124
+
125
+ def apply (self , groupNode , properties ):
126
+ value_arr = [0.5 , 0.5 , 0.5 , 1.0 ]
127
+ if self .property_name in properties :
128
+ value_arr = properties [self .property_name ].to_list ()
129
+ else :
130
+ print (f"Property { self .property_name } not found in material" )
131
+
132
+ if len (value_arr ) == 3 :
133
+ value_arr .append (1.0 )
134
+
135
+ groupNode .inputs [self .color_dest ].default_value = value_arr [3 ]
136
+
137
+ class FloatValueMapping :
138
+ def __init__ (self , value : float , property_dest : str ):
139
+ self .value = value
140
+ self .property_dest = property_dest
141
+
142
+ def __repr__ (self ):
143
+ return f"FloatValueMappping({ self .value } , { self .property_dest } )"
144
+
145
+ def apply (self , groupNode ):
146
+ groupNode .inputs [self .property_dest ].default_value = self .value
116
147
117
148
class ColorSetMapping :
118
149
# ColorSetMapping('ColorTable', 'g_SamplerIndex_PngCachePath', 'DiffuseTableA', 'DiffuseTableB', 'SpecularTableA', 'SpecularTableB', 'color_a', 'color_b', 'specular_a', 'specular_b', 'id_mix'),
@@ -396,6 +427,20 @@ def apply(self, groupNode, properties):
396
427
]
397
428
)
398
429
430
+ meddle_skin2 = NodeGroup (
431
+ 'meddle skin2.shpk' ,
432
+ [
433
+ PngMapping ('g_SamplerDiffuse_PngCachePath' , 'g_SamplerDiffuse' , 'g_SamplerDiffuse_alpha' , 'sRGB' ),
434
+ PngMapping ('g_SamplerNormal_PngCachePath' , 'g_SamplerNormal' , 'g_SamplerNormal_alpha' , 'Non-Color' ),
435
+ PngMapping ('g_SamplerMask_PngCachePath' , 'g_SamplerMask' , 'g_SamplerMask_alpha' , 'Non-Color' ),
436
+ FloatRgbMapping ('SkinColor' , 'Skin Color' ),
437
+ FloatRgbMapping ('LipColor' , 'Lip Color' ),
438
+ FloatRgbaAlphaMapping ('LipColor' , 'Lip Color Strength' ),
439
+ FloatRgbMapping ('MainColor' , 'Hair Color' ),
440
+ FloatRgbMapping ('MeshColor' , 'Highlights Color' ),
441
+ ]
442
+ )
443
+
399
444
nodegroups : list [NodeGroup ] = [
400
445
meddle_skin ,
401
446
meddle_face_skin ,
@@ -408,66 +453,68 @@ def apply(self, groupNode, properties):
408
453
meddle_bg ,
409
454
meddle_bg_colorchange ,
410
455
meddle_character_compatibility ,
411
- meddle_bg_prop
456
+ meddle_bg_prop ,
457
+ meddle_skin2
412
458
]
413
-
459
+
414
460
def matchShader (mat ):
415
461
if mat is None :
416
- return None
462
+ return ( None , [])
417
463
418
464
properties = mat
419
465
shaderPackage = properties ["ShaderPackage" ]
420
466
421
467
print (f"Matching shader { shaderPackage } on material { mat .name } " )
422
468
423
469
if shaderPackage is None :
424
- return None
470
+ return ( None , [])
425
471
426
472
if shaderPackage == 'skin.shpk' :
427
- output = meddle_face_skin
473
+ output = ( meddle_face_skin , [ FloatValueMapping ( 1.0 , 'IS_FACE' )])
428
474
if 'CategorySkinType' in properties :
429
475
if properties ["CategorySkinType" ] == 'Body' :
430
- output = meddle_skin
476
+ output = ( meddle_skin2 , [])
431
477
elif properties ["CategorySkinType" ] == 'Face' :
432
- output = meddle_face_skin
478
+ output = ( meddle_skin2 , [ FloatValueMapping ( 1.0 , 'IS_FACE' )])
433
479
elif properties ["CategorySkinType" ] == 'Hrothgar' :
434
480
print ("Hrothgar, not implemented" )
481
+ output = (meddle_skin2 , [FloatValueMapping (1.0 , 'IS_HROTHGAR' )])
435
482
436
483
return output
437
484
438
485
if shaderPackage == 'hair.shpk' :
439
- output = meddle_hair
486
+ output = ( meddle_hair , [])
440
487
if 'CategoryHairType' in properties :
441
488
if properties ["CategoryHairType" ] == 'Face' :
442
- output = meddle_face_hair
489
+ output = ( meddle_face_hair , [])
443
490
444
491
return output
445
492
446
493
if shaderPackage == 'iris.shpk' :
447
- return meddle_iris
494
+ return ( meddle_iris , [])
448
495
449
496
if shaderPackage == 'charactertattoo.shpk' :
450
- return meddle_character_tattoo
497
+ return ( meddle_character_tattoo , [])
451
498
452
499
if shaderPackage == 'characterocclusion.shpk' :
453
- return meddle_character_occlusion
500
+ return ( meddle_character_occlusion , [])
454
501
455
502
if shaderPackage == 'character.shpk' or shaderPackage == 'characterlegacy.shpk' or shaderPackage == 'characterscroll.shpk' :
456
503
# check if GetValuesTextureType is 'Compatibility'
457
504
if 'GetValuesTextureType' in properties :
458
505
if properties ['GetValuesTextureType' ] == 'Compatibility' :
459
- return meddle_character_compatibility
506
+ return ( meddle_character_compatibility , [])
460
507
461
- return meddle_character
508
+ return ( meddle_character , [])
462
509
463
510
if shaderPackage == 'bg.shpk' :
464
- return meddle_bg
511
+ return ( meddle_bg , [])
465
512
466
513
if shaderPackage == 'bgcolorchange.shpk' :
467
- return meddle_bg_colorchange
514
+ return ( meddle_bg_colorchange , [])
468
515
469
516
if shaderPackage == 'bgprop.shpk' :
470
- return meddle_bg_prop
517
+ return ( meddle_bg_prop , [])
471
518
472
519
print ("No suitable shader found for " + shaderPackage + " on material " + mat .name )
473
- return None
520
+ return ( None , [])
0 commit comments