diff --git a/i_scene_cp77_gltf/material_types/multilayered.py b/i_scene_cp77_gltf/material_types/multilayered.py index 05e6d6a..2e0be33 100644 --- a/i_scene_cp77_gltf/material_types/multilayered.py +++ b/i_scene_cp77_gltf/material_types/multilayered.py @@ -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)): @@ -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+ @@ -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: