Skip to content

Commit

Permalink
Handle single layer mlsetup with no mask (ashtray_a)
Browse files Browse the repository at this point in the history
  • Loading branch information
Simarilius-uk committed Sep 16, 2024
1 parent b7d4438 commit a2697f2
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions i_scene_cp77_gltf/material_types/multilayered.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ def setGlobNormal(self,normalimgpath,CurMat,input):
def createLayerMaterial(self,LayerName,LayerCount,CurMat,mlmaskpath,normalimgpath):
NG = _getOrCreateLayerBlend()
for x in range(LayerCount-1):
MaskTexture=None
if os.path.exists((os.path.splitext(self.ProjPath + mlmaskpath)[0]+'_layers\\'+mlmaskpath.split('\\')[-1:][0][:-7]+"_"+str(x+1)+".png").replace('\\',os.sep)):
MaskTexture = imageFromPath(os.path.splitext(self.ProjPath+ mlmaskpath)[0]+'_layers\\'+mlmaskpath.split('\\')[-1:][0][:-7]+"_"+str(x+1)+".png",self.image_format,isNormal = True)
elif os.path.exists((os.path.splitext(self.BasePath + mlmaskpath)[0]+'_layers\\'+mlmaskpath.split('\\')[-1:][0][:-7]+"_"+str(x+1)+".png").replace('\\',os.sep)):
Expand All @@ -188,8 +189,9 @@ def createLayerMaterial(self,LayerName,LayerCount,CurMat,mlmaskpath,normalimgpat
LayerGroupN = create_node(CurMat.nodes,"ShaderNodeGroup", (-1400,400-100*x))
LayerGroupN.node_tree = NG
LayerGroupN.name = "Layer_"+str(x)

MaskN = create_node(CurMat.nodes,"ShaderNodeTexImage",(-2400,400-100*x), image = MaskTexture,label="Layer_"+str(x+1))
MaskN=None
if MaskTexture:
MaskN = create_node(CurMat.nodes,"ShaderNodeTexImage",(-2400,400-100*x), image = MaskTexture,label="Layer_"+str(x+1))

#if self.flipMaskY:
# Mask flip deprecated in WolvenKit deveolpment build 8.7+
Expand All @@ -213,7 +215,8 @@ def createLayerMaterial(self,LayerName,LayerCount,CurMat,mlmaskpath,normalimgpat
CurMat.links.new(CurMat.nodes["Mat_Mod_Layer_"+str(x+1)].outputs[1],LayerGroupN.inputs[5])
CurMat.links.new(CurMat.nodes["Mat_Mod_Layer_"+str(x+1)].outputs[2],LayerGroupN.inputs[6])
CurMat.links.new(CurMat.nodes["Mat_Mod_Layer_"+str(x+1)].outputs[3],LayerGroupN.inputs[7])
CurMat.links.new(MaskN.outputs[0],CurMat.nodes["Mat_Mod_Layer_"+str(x+1)].inputs[9])
if MaskN:
CurMat.links.new(MaskN.outputs[0],CurMat.nodes["Mat_Mod_Layer_"+str(x+1)].inputs[9])
CurMat.links.new(CurMat.nodes["Mat_Mod_Layer_"+str(x+1)].outputs[4],CurMat.nodes["Layer_"+str(x)].inputs[8])

if LayerCount>1:
Expand Down

0 comments on commit a2697f2

Please sign in to comment.