@@ -641,13 +641,22 @@ def clearMaterialNodes(node_tree: bpy.types.ShaderNodeTree):
641
641
for node in node_tree .nodes :
642
642
node_tree .nodes .remove (node )
643
643
644
- def createBsdfNode (node_tree : bpy .types .ShaderNodeTree ):
644
+ def createBsdfNode (node_tree : bpy .types .ShaderNodeTree , subsurface_method :str = 'BURLEY' ):
645
+ """Creates the principled BSDF node for the material
646
+
647
+ Args:
648
+ node_tree (bpy.types.ShaderNodeTree): A reference to the material's node tree
649
+ subsurface_method (str, optional): Which subsurface method to use from BURLEY, RANDOM_WALK and RANDOM_WALK_SKIN. Defaults to 'BURLEY'.
650
+
651
+ Returns:
652
+ bsdf_node (bpy.types.ShaderNodeBsdfPrincipled): A reference to the newly created principled BSDF node
653
+ """
645
654
bsdf_node : bpy .types .ShaderNodeBsdfPrincipled = node_tree .nodes .new ('ShaderNodeBsdfPrincipled' ) # type: ignore
646
655
bsdf_node .width = 300
647
656
try :
648
- bsdf_node .subsurface_method = 'BURLEY'
657
+ bsdf_node .subsurface_method = subsurface_method
649
658
except :
650
- print ("Subsurface method not found " )
659
+ print (f"Something went wrong when trying to set subsurface method: \" { subsurface_method } \" " )
651
660
return bsdf_node
652
661
653
662
def mapBsdfOutput (mat : bpy .types .Material , material_output : bpy .types .ShaderNodeOutputMaterial , bsdf_node : bpy .types .ShaderNodeBsdfPrincipled , targetIdentifier : str ):
@@ -800,7 +809,7 @@ def handleSkin(mat: bpy.types.Material, mesh, directory):
800
809
group_node .node_tree = bpy .data .node_groups [group_name ] # type: ignore
801
810
group_node .width = 300
802
811
803
- bsdf_node = createBsdfNode (node_tree )
812
+ bsdf_node = createBsdfNode (node_tree , 'RANDOM_WALK_SKIN' ) # Specify Skin subsurface method
804
813
mapBsdfOutput (mat , material_output , bsdf_node , 'Surface' )
805
814
mapGroupOutputs (mat , bsdf_node , group_node )
806
815
mapMappings (mat , mesh , group_node , directory , base_mappings + mappings )
@@ -887,6 +896,14 @@ def handleHair(mat: bpy.types.Material, mesh, directory):
887
896
mapBsdfOutput (mat , material_output , bsdf_node , 'Surface' )
888
897
mapGroupOutputs (mat , bsdf_node , group_node )
889
898
mapMappings (mat , mesh , group_node , directory , base_mappings + mappings )
899
+
900
+ try :
901
+ bsdf_node .inputs .get ("Transmission Weight" ).default_value = 0.01
902
+ bsdf_node .inputs .get ("Subsurface Scale" ).default_value = 0.15
903
+ node_tree .links .new (group_node .outputs .get ("Base Color" ), bsdf_node .inputs .get ("Subsurface Radius" ))
904
+ except Exception as e :
905
+ print (f"Exception occured when setting some hair inputs: { e } " )
906
+
890
907
east = getEastModePosition (node_tree )
891
908
group_node .location = (east + 300 , 300 )
892
909
bsdf_node .location = (east + 600 , 300 )
0 commit comments