From 9cbfec578a1af07fc445e2e66e23b09853ab9ce5 Mon Sep 17 00:00:00 2001 From: ja-to <65016231+ja-to@users.noreply.github.com> Date: Tue, 8 Mar 2022 21:05:25 -0600 Subject: [PATCH] Update for WK 8.5 -Updated to support new json format from WolvenKit 8.5 - Added normal detail and microblend preview for skin.mt --- i_scene_cp77_gltf/__init__.py | 2 +- i_scene_cp77_gltf/main/common.py | 5 +- i_scene_cp77_gltf/material_types/hair.py | 28 +-- .../material_types/multilayered.py | 63 ++++--- i_scene_cp77_gltf/material_types/skin.py | 177 ++++++++++++++---- .../material_types/vehicledestrblendshape.py | 63 ++++--- .../material_types/vehiclemeshdecal.py | 2 +- 7 files changed, 226 insertions(+), 114 deletions(-) diff --git a/i_scene_cp77_gltf/__init__.py b/i_scene_cp77_gltf/__init__.py index 5e85e11..3b07cbb 100644 --- a/i_scene_cp77_gltf/__init__.py +++ b/i_scene_cp77_gltf/__init__.py @@ -2,7 +2,7 @@ "name": "Cyberpunk 2077 glTF Importer", "author": "HitmanHimself, Turk, Jato", "version": (1, 0, 5), - "blender": (2, 93, 0), + "blender": (3, 0, 0), "location": "File > Import-Export", "description": "Import WolvenKit Cyberpunk2077 glTF Models With Materials", "warning": "", diff --git a/i_scene_cp77_gltf/main/common.py b/i_scene_cp77_gltf/main/common.py index 7edbeba..045a1b8 100644 --- a/i_scene_cp77_gltf/main/common.py +++ b/i_scene_cp77_gltf/main/common.py @@ -95,6 +95,7 @@ def CreateRebildNormalGroup(curMat, x = 0, y = 0,name = 'Rebuild Normal Z'): group.links.new(VMup.outputs[0],VSub.inputs[0]) group.links.new(VSub.outputs[0],VDot.inputs[0]) group.links.new(VSub.outputs[0],VDot.inputs[1]) + group.links.new(VDot.outputs["Value"],Sub.inputs[1]) group.links.new(Sub.outputs[0],SQR.inputs[0]) group.links.new(SQR.outputs[0],Range.inputs[0]) group.links.new(GroupInN.outputs[0],Sep.inputs[0]) @@ -125,7 +126,7 @@ def CreateShaderNodeNormalMap(curMat,path = None, x = 0, y = 0, name = None,imag Img = imageFromPath(path,image_format,nonCol) ImgNode.image = Img - NormalRebuildGroup = CreateRebildNormalGroup(curMat, x - 200, y, name + ' Rebuilt') + NormalRebuildGroup = CreateRebildNormalGroup(curMat, x - 150, y, name + ' Rebuilt') curMat.links.new(ImgNode.outputs[0],NormalRebuildGroup.inputs[0]) curMat.links.new(NormalRebuildGroup.outputs[0],nMap.inputs[1]) @@ -159,11 +160,9 @@ def crop_image(orig_img,outname, cropped_min_x, cropped_max_x, cropped_min_y, cr if you put cropped_min_x = 2 and cropped_max_x = 6, you would get back a cropped image with width 4, and pixels ranging from the 2 to 5 in the x-coordinate - Note: here y increasing as you down the image. So, if cropped_min_x and cropped_min_y are both zero, you'll get the top-left of the image (as in GIMP). - Returns: An image of type ''' diff --git a/i_scene_cp77_gltf/material_types/hair.py b/i_scene_cp77_gltf/material_types/hair.py index a5c346a..9dfb08c 100644 --- a/i_scene_cp77_gltf/material_types/hair.py +++ b/i_scene_cp77_gltf/material_types/hair.py @@ -12,7 +12,7 @@ def __init__(self, BasePath,image_format): def create(self,hair,Mat): file = open(self.BasePath + hair["HairProfile"] + ".json",mode='r') - profile = json.loads(file.read())["Chunks"]["0"]["Properties"] + profile = json.loads(file.read())["Data"]["RootChunk"]["Properties"] file.close() CurMat = Mat.node_tree @@ -32,13 +32,13 @@ def create(self,hair,Mat): counter = 0 for Entry in profile["gradientEntriesRootToTip"]: if counter is 0: - RootToTip.color_ramp.elements[0].position = Entry.get("value",0) - colr = Entry.get("color","255, 255, 255").split(', ') - RootToTip.color_ramp.elements[0].color = (float(colr[0])/255,float(colr[1])/255,float(colr[2])/255,float(1)) + RootToTip.color_ramp.elements[0].position = Entry["Properties"].get("value",0) + colr = Entry["Properties"]["color"].get("Properties") + RootToTip.color_ramp.elements[0].color = (float(colr["Red"])/255,float(colr["Green"])/255,float(colr["Blue"])/255,float(1)) else: - element = RootToTip.color_ramp.elements.new(Entry.get("value",0)) - colr = Entry.get("color","255, 255, 255").split(', ') - element.color = (float(colr[0])/255,float(colr[1])/255,float(colr[2])/255,float(1)) + element = RootToTip.color_ramp.elements.new(Entry["Properties"].get("value",0)) + colr = Entry["Properties"]["color"].get("Properties") + element.color = (float(colr["Red"])/255,float(colr["Green"])/255,float(colr["Blue"])/255,float(1)) counter = counter + 1 CurMat.links.new(gImgNode.outputs[0],RootToTip.inputs[0]) @@ -54,15 +54,15 @@ def create(self,hair,Mat): counter = 0 for Entry in profile["gradientEntriesID"]: if counter is 0: - ID.color_ramp.elements[0].position = Entry.get("value",0) - colr = Entry.get("color","255, 255, 255").split(', ') - ID.color_ramp.elements[0].color = (float(colr[0])/255,float(colr[1])/255,float(colr[2])/255,float(1)) + ID.color_ramp.elements[0].position = Entry["Properties"].get("value",0) + colr = Entry["Properties"]["color"].get("Properties") + ID.color_ramp.elements[0].color = (float(colr["Red"])/255,float(colr["Green"])/255,float(colr["Blue"])/255,float(1)) else: - element = ID.color_ramp.elements.new(Entry.get("value",0)) - colr = Entry.get("color","255, 255, 255").split(', ') - element.color = (float(colr[0])/255,float(colr[1])/255,float(colr[2])/255,float(1)) + element = ID.color_ramp.elements.new(Entry["Properties"].get("value",0)) + colr = Entry["Properties"]["color"].get("Properties") + element.color = (float(colr["Red"])/255,float(colr["Green"])/255,float(colr["Blue"])/255,float(1)) counter = counter + 1 - + CurMat.links.new(idImgNode.outputs[0],ID.inputs[0]) mulNode = CurMat.nodes.new("ShaderNodeMixRGB") diff --git a/i_scene_cp77_gltf/material_types/multilayered.py b/i_scene_cp77_gltf/material_types/multilayered.py index bd639f6..e9b320a 100644 --- a/i_scene_cp77_gltf/material_types/multilayered.py +++ b/i_scene_cp77_gltf/material_types/multilayered.py @@ -8,10 +8,10 @@ def __init__(self, BasePath,image_format): self.BasePath = str(BasePath) self.image_format = image_format def createBaseMaterial(self,matTemplateObj,name): - CT = imageFromPath(self.BasePath + matTemplateObj["colorTexture"],self.image_format) - NT = imageFromPath(self.BasePath + matTemplateObj["normalTexture"],self.image_format,isNormal = True) - RT = imageFromPath(self.BasePath + matTemplateObj["roughnessTexture"],self.image_format,isNormal = True) - MT = imageFromPath(self.BasePath + matTemplateObj["metalnessTexture"],self.image_format,isNormal = True) + CT = imageFromPath(self.BasePath + matTemplateObj["colorTexture"]["DepotPath"],self.image_format) + NT = imageFromPath(self.BasePath + matTemplateObj["normalTexture"]["DepotPath"],self.image_format,isNormal = True) + RT = imageFromPath(self.BasePath + matTemplateObj["roughnessTexture"]["DepotPath"],self.image_format,isNormal = True) + MT = imageFromPath(self.BasePath + matTemplateObj["metalnessTexture"]["DepotPath"],self.image_format,isNormal = True) TileMult = float(matTemplateObj.get("tilingMultiplier",1)) @@ -95,7 +95,7 @@ def createBaseMaterial(self,matTemplateObj,name): return def createOverrideTable(self,matTemplateObj): - OverList = matTemplateObj.get("overrides") + OverList = matTemplateObj["overrides"].get("Properties") if OverList is None: OverList = matTemplateObj.get("Overrides") Output = {} @@ -104,27 +104,27 @@ def createOverrideTable(self,matTemplateObj): Output["RoughLevelsOut"] = {} Output["MetalLevelsOut"] = {} for x in OverList["colorScale"]: - tmpName = x["n"] - tmpR = float(x["v"][0]) - tmpG = float(x["v"][1]) - tmpB = float(x["v"][2]) + tmpName = x["Properties"]["n"] + tmpR = float(x["Properties"]["v"]["Elements"][0]) + tmpG = float(x["Properties"]["v"]["Elements"][1]) + tmpB = float(x["Properties"]["v"]["Elements"][2]) Output["ColorScale"][tmpName] = (tmpR,tmpG,tmpB,1) for x in OverList["normalStrength"]: - tmpName = x["n"] + tmpName = x["Properties"]["n"] tmpStrength = 0 if x.get("v") is not None: - tmpStrength = float(x["v"]) + tmpStrength = float(x["Properties"]["v"]) Output["NormalStrength"][tmpName] = tmpStrength for x in OverList["roughLevelsOut"]: - tmpName = x["n"] - tmpStrength0 = float(x["v"][0]) - tmpStrength1 = float(x["v"][1]) + tmpName = x["Properties"]["n"] + tmpStrength0 = float(x["Properties"]["v"]["Elements"][0]) + tmpStrength1 = float(x["Properties"]["v"]["Elements"][1]) Output["RoughLevelsOut"][tmpName] = [(tmpStrength0,tmpStrength0,tmpStrength0,1),(tmpStrength1,tmpStrength1,tmpStrength1,1)] for x in OverList["metalLevelsOut"]: - tmpName = x["n"] + tmpName = x["Properties"]["n"] if x.get("v") is not None: - tmpStrength0 = float(x["v"][0]) - tmpStrength1 = float(x["v"][1]) + tmpStrength0 = float(x["Properties"]["v"]["Elements"][0]) + tmpStrength1 = float(x["Properties"]["v"]["Elements"][1]) else: tmpStrength0 = 0 tmpStrength1 = 1 @@ -281,7 +281,7 @@ def createLayerMaterial(self,LayerName,LayerCount,CurMat,mlmaskpath,normalimgpat def create(self,Data,Mat): file = open(self.BasePath + Data["MultilayerSetup"] + ".json",mode='r') - mlsetup = json.loads(file.read())["Chunks"]["0"]["Properties"] + mlsetup = json.loads(file.read())["Data"]["RootChunk"]["Properties"] file.close() xllay = mlsetup.get("layers") if xllay is None: @@ -291,12 +291,12 @@ def create(self,Data,Mat): LayerIndex = 0 CurMat = Mat.node_tree for x in (xllay): - MatTile = x.get("matTile") + MatTile = x["Properties"].get("matTile") if MatTile is None: MatTile = x.get("MatTile") - MbTile = x.get("mbTile") + MbTile = x["Properties"].get("mbTile") if MbTile is None: - MbTile = x.get("MbTile") + MbTile = x["Properties"].get("MbTile") MbScale = 1 if MatTile != None: @@ -304,33 +304,34 @@ def create(self,Data,Mat): if MbTile != None: MbScale = float(MbTile) - Microblend = x.get("microblend") + Microblend = x["Properties"]["microblend"].get("DepotPath") if Microblend is None: Microblend = x.get("Microblend") - MicroblendContrast = x.get("microblendContrast") + MicroblendContrast = x["Properties"].get("microblendContrast") if MicroblendContrast is None: MicroblendContrast = x.get("Microblend",1) - microblendNormalStrength = x.get("microblendNormalStrength") + microblendNormalStrength = x["Properties"].get("microblendNormalStrength") if microblendNormalStrength is None: microblendNormalStrength = x.get("MicroblendNormalStrength") - opacity = x.get("opacity") + opacity = x["Properties"].get("opacity") if opacity is None: opacity = x.get("Opacity") - material = x.get("material") + + material = x["Properties"]["material"].get("DepotPath") if material is None: material = x.get("Material") - colorScale = x.get("colorScale") + colorScale = x["Properties"].get("colorScale") if colorScale is None: colorScale = x.get("ColorScale") - normalStrength = x.get("normalStrength") + normalStrength = x["Properties"].get("normalStrength") if normalStrength is None: normalStrength = x.get("NormalStrength") #roughLevelsIn = x["roughLevelsIn"] - roughLevelsOut = x.get("roughLevelsOut") + roughLevelsOut = x["Properties"].get("roughLevelsOut") if roughLevelsOut is None: roughLevelsOut = x.get("RoughLevelsOut") #metalLevelsIn = x["metalLevelsIn"] - metalLevelsOut = x.get("metalLevelsOut") + metalLevelsOut = x["Properties"].get("metalLevelsOut") if metalLevelsOut is None: metalLevelsOut = x.get("MetalLevelsOut") @@ -338,7 +339,7 @@ def create(self,Data,Mat): MBI = imageFromPath(self.BasePath+Microblend,self.image_format,True) file = open(self.BasePath + material + ".json",mode='r') - mltemplate = json.loads(file.read())["Chunks"]["0"]["Properties"] + mltemplate = json.loads(file.read())["Data"]["RootChunk"]["Properties"] file.close() OverrideTable = self.createOverrideTable(mltemplate)#get override info for colors and what not diff --git a/i_scene_cp77_gltf/material_types/skin.py b/i_scene_cp77_gltf/material_types/skin.py index 9edf1f1..a2313b9 100644 --- a/i_scene_cp77_gltf/material_types/skin.py +++ b/i_scene_cp77_gltf/material_types/skin.py @@ -11,13 +11,13 @@ def create(self,Data,Mat): #SSS/s sVcol = CurMat.nodes.new("ShaderNodeVertexColor") - sVcol.location = (-800,250) + sVcol.location = (-1400,250) sSepRGB = CurMat.nodes.new("ShaderNodeSeparateRGB") - sSepRGB.location = (-600,250) + sSepRGB.location = (-1200,250) sMultiply = CurMat.nodes.new("ShaderNodeMath") - sMultiply.location = (-400,250) + sMultiply.location = (-800,250) sMultiply.operation = 'MULTIPLY' sMultiply.inputs[1].default_value = (0.05) @@ -25,11 +25,6 @@ def create(self,Data,Mat): CurMat.links.new(sSepRGB.outputs[1],sMultiply.inputs[0]) CurMat.links.new(sMultiply.outputs[0],CurMat.nodes['Principled BSDF'].inputs['Subsurface']) CurMat.nodes['Principled BSDF'].inputs['Subsurface Color'].default_value = (0.8, 0.14908, 0.0825199, 1) - -#NORMAL/n - if "Normal" in Data: - nMap = CreateShaderNodeNormalMap(CurMat, self.BasePath + Data["Normal"], -200,-250, "Normal",self.image_format) - CurMat.links.new(nMap.outputs[0],CurMat.nodes['Principled BSDF'].inputs['Normal']) #Albedo/a mixRGB = CurMat.nodes.new("ShaderNodeMixRGB") @@ -52,43 +47,159 @@ def create(self,Data,Mat): CurMat.links.new(mixRGB.outputs[0],CurMat.nodes['Principled BSDF'].inputs['Base Color']) +#ROUGHNES+MASK/rm - Sep = CurMat.nodes.new("ShaderNodeSeparateRGB") - Sep.location = (-500,50) - Sep.hide = True if "Roughness" in Data: - rImgNode = CreateShaderNodeTexImage(CurMat,self.BasePath + Data["Roughness"], -800,50, "Roughness",self.image_format,True) - CurMat.links.new(rImgNode.outputs[0],Sep.inputs[0]) - CurMat.links.new(Sep.outputs[0],CurMat.nodes['Principled BSDF'].inputs['Roughness']) + rImgNode = CreateShaderNodeTexImage(CurMat,self.BasePath + Data["Roughness"], -1600,50, "Roughness",self.image_format,True) + + rmSep = CurMat.nodes.new("ShaderNodeSeparateRGB") + rmSep.location = (-1300,50) + rmSep.hide = True + + rmSub = CurMat.nodes.new("ShaderNodeMath") + rmSub.location = (-1100,0) + rmSub.hide = True + rmSub.operation = 'SUBTRACT' + rmSub.inputs[1].default_value = (0.5) + + rmMul = CurMat.nodes.new("ShaderNodeMath") + rmMul.location = (-900,-100) + rmMul.hide = True + rmMul.operation = 'MULTIPLY' + +#NORMAL/n + nMDCoordinates = CurMat.nodes.new("ShaderNodeTexCoord") + nMDCoordinates.hide = True + nMDCoordinates.location = (-2000,-850) + + nVecMulAspectA = CurMat.nodes.new("ShaderNodeVectorMath") + nVecMulAspectA.hide = True + nVecMulAspectA.location = (-1800,-1000) + nVecMulAspectA.operation = "MULTIPLY" + nVecMulAspectA.inputs[1].default_value = (1, 2, 1) + + nVecMulAspectB = CurMat.nodes.new("ShaderNodeVectorMath") + nVecMulAspectB.hide = True + nVecMulAspectB.location = (-1800,-1150) + nVecMulAspectB.operation = "MULTIPLY" + nVecMulAspectB.inputs[1].default_value = (1, 2, 1) + + nVecMulA = CurMat.nodes.new("ShaderNodeVectorMath") + nVecMulA.hide = True + nVecMulA.location = (-1600,-850) + nVecMulA.operation = "MULTIPLY" + + nVecMulB = CurMat.nodes.new("ShaderNodeVectorMath") + nVecMulB.hide = True + nVecMulB.location = (-1600,-1150) + nVecMulB.operation = "MULTIPLY" + + nVecModA = CurMat.nodes.new("ShaderNodeVectorMath") + nVecModA.hide = True + nVecModA.location = (-1400,-850) + nVecModA.operation = "MODULO" + nVecModA.inputs[1].default_value = (0.5, 1, 1) + + nVecModB = CurMat.nodes.new("ShaderNodeVectorMath") + nVecModB.hide = True + nVecModB.location = (-1400,-1150) + nVecModB.operation = "MODULO" + nVecModB.inputs[1].default_value = (0.5, 1, 1) + + nVecAdd = CurMat.nodes.new("ShaderNodeVectorMath") + nVecAdd.hide = True + nVecAdd.location = (-1200,-1150) + nVecAdd.operation = "ADD" + nVecAdd.inputs[1].default_value = (0.5, 0, 0) + + nOverlay1 = CurMat.nodes.new("ShaderNodeMixRGB") + nOverlay1.hide = True + nOverlay1.location = (-1000,-300) + nOverlay1.blend_type ='OVERLAY' + + nOverlay2 = CurMat.nodes.new("ShaderNodeMixRGB") + nOverlay2.hide = True + nOverlay2.location = (-700,-300) + nOverlay2.blend_type ='OVERLAY' + + mdOverlay = CurMat.nodes.new("ShaderNodeMixRGB") + mdOverlay.hide = True + mdOverlay.location = (-700,-450) + mdOverlay.blend_type ='OVERLAY' + mdOverlay.inputs[0].default_value = (1) + + nNormalMap = CurMat.nodes.new("ShaderNodeNormalMap") + nNormalMap.location = (-300, -300) + nNormalMap.hide = True + + nRebuildNormal = CreateRebildNormalGroup(CurMat) + nRebuildNormal.hide = True + nRebuildNormal.location = (-500,-300) + if "Normal" in Data: + nMap = CreateShaderNodeTexImage(CurMat, self.BasePath + Data["Normal"], -1800,-300, "Normal",self.image_format,True) + if "DetailNormal" in Data: - ndMap = CreateShaderNodeNormalMap(CurMat, self.BasePath + Data["DetailNormal"], -550,-250, "DetailNormal",self.image_format) - if "DetailNormalInfluence" in Data: - ndInfluence = CreateShaderNodeValue(CurMat, Data["DetailNormalInfluence"],-1200,-550,"DetailNormalInfluence") - CurMat.links.new(ndInfluence.outputs[0],ndMap.inputs[0]) - - if "Detailmap_Squash" in Data: - ndSqImgNode = CreateShaderNodeNormalMap(CurMat, self.BasePath + Data["Detailmap_Squash"], -1500,50, "Detailmap_Squash",self.image_format) - - if "Detailmap_Stretch" in Data: - ndStImg = CreateShaderNodeNormalMap(CurMat, self.BasePath + Data["Detailmap_Stretch"], -1500,0, "Detailmap_Stretch",self.image_format) + dnMap = CreateShaderNodeTexImage(CurMat, self.BasePath + Data["DetailNormal"], -1800,-450, "DetailNormal",self.image_format,True) + + if "DetailNormalInfluence" in Data: + nDNInfluence = CreateShaderNodeValue(CurMat, Data["DetailNormalInfluence"],-1250,-200,"DetailNormalInfluence") if "MicroDetail" in Data: - mdMap = CreateShaderNodeNormalMap(CurMat, self.BasePath + Data["MicroDetail"], -1200,-700, "MicroDetail",self.image_format) + mdMapA = CreateShaderNodeTexImage(CurMat, self.BasePath + Data["MicroDetail"], -1100,-450, "MicroDetail",self.image_format,True) + mdMapB = CreateShaderNodeTexImage(CurMat, self.BasePath + Data["MicroDetail"], -1100,-650, "MicroDetail",self.image_format,True) - mdMappingNode = CurMat.nodes.new("ShaderNodeMapping") - mdMappingNode.label = "MicroDetailUVMapping" - mdMappingNode.location = (-1400,-700) if "MicroDetailUVScale01" in Data: - mdMappingNode.inputs[3].default_value[0] = float(Data["MicroDetailUVScale01"]) + mdScale01 = CreateShaderNodeValue(CurMat, Data["MicroDetailUVScale01"],-2000,-1000,"MicroDetailUVScale01") + if "MicroDetailUVScale02" in Data: - mdMappingNode.inputs[3].default_value[1] = float(Data["MicroDetailUVScale02"]) + mdScale02 = CreateShaderNodeValue(CurMat, Data["MicroDetailUVScale02"],-2000,-1150,"MicroDetailUVScale02") if "MicroDetailInfluence" in Data: - mdInfluence = CreateShaderNodeValue(CurMat, Data["MicroDetailInfluence"],-1200,-650,"MicroDetailInfluence") + mdInfluence = CreateShaderNodeValue(CurMat, Data["MicroDetailInfluence"],-1250,-100,"MicroDetailInfluence") + if "Detailmap_Squash" in Data: + ndSqImgNode = CreateShaderNodeTexImage(CurMat, self.BasePath + Data["Detailmap_Squash"], -2000,50, "Detailmap_Squash",self.image_format,True) + + if "Detailmap_Stretch" in Data: + ndStImg = CreateShaderNodeTexImage(CurMat, self.BasePath + Data["Detailmap_Stretch"], -2000,0, "Detailmap_Stretch",self.image_format,True) + + CurMat.links.new(rImgNode.outputs[0],rmSep.inputs[0]) + CurMat.links.new(rmSep.outputs[0],CurMat.nodes['Principled BSDF'].inputs['Roughness']) + CurMat.links.new(rmSep.outputs[2],rmSub.inputs[0]) + CurMat.links.new(rmSub.outputs[0],rmMul.inputs[0]) + CurMat.links.new(rmMul.outputs[0],nOverlay2.inputs[0]) + CurMat.links.new(mdInfluence.outputs[0],rmMul.inputs[1]) + + CurMat.links.new(nMap.outputs[0],nOverlay1.inputs[1]) + CurMat.links.new(dnMap.outputs[0],nOverlay1.inputs[2]) + CurMat.links.new(nDNInfluence.outputs[0],nOverlay1.inputs[0]) + + CurMat.links.new(nMDCoordinates.outputs["UV"],nVecMulA.inputs[0]) + CurMat.links.new(nMDCoordinates.outputs["UV"],nVecMulB.inputs[0]) + CurMat.links.new(mdScale01.outputs[0],nVecMulAspectA.inputs[0]) + CurMat.links.new(mdScale02.outputs[0],nVecMulAspectB.inputs[0]) + CurMat.links.new(nVecMulAspectA.outputs[0],nVecMulA.inputs[1]) + CurMat.links.new(nVecMulAspectB.outputs[0],nVecMulB.inputs[1]) + CurMat.links.new(nVecMulA.outputs[0],nVecModA.inputs[0]) + CurMat.links.new(nVecMulB.outputs[0],nVecModB.inputs[0]) + CurMat.links.new(nVecModA.outputs[0],mdMapA.inputs[0]) + CurMat.links.new(nVecModB.outputs[0],nVecAdd.inputs[0]) + CurMat.links.new(nVecAdd.outputs[0],mdMapB.inputs[0]) + CurMat.links.new(mdMapA.outputs[0],mdOverlay.inputs[1]) + CurMat.links.new(mdMapB.outputs[0],mdOverlay.inputs[2]) + + CurMat.links.new(nOverlay1.outputs[0],nOverlay2.inputs[1]) + CurMat.links.new(mdOverlay.outputs[0],nOverlay2.inputs[2]) + + CurMat.links.new(nOverlay2.outputs[0],nRebuildNormal.inputs[0]) + CurMat.links.new(nRebuildNormal.outputs[0],nNormalMap.inputs[1]) + + CurMat.links.new(nNormalMap.outputs[0],CurMat.nodes['Principled BSDF'].inputs['Normal']) + +#OTHER if "BloodColor" in Data: - bfColor = CreateShaderNodeRGB(CurMat, Data["BloodColor"],-1500,300,"BloodColor") + bfColor = CreateShaderNodeRGB(CurMat, Data["BloodColor"],-2000,300,"BloodColor") if "Bloodflow" in Data: - bfImgNode = CreateShaderNodeTexImage(CurMat,self.BasePath + Data["Bloodflow"], -1500,350, "Bloodflow",self.image_format) \ No newline at end of file + bfImgNode = CreateShaderNodeTexImage(CurMat,self.BasePath + Data["Bloodflow"], -2000,350, "Bloodflow",self.image_format) \ No newline at end of file diff --git a/i_scene_cp77_gltf/material_types/vehicledestrblendshape.py b/i_scene_cp77_gltf/material_types/vehicledestrblendshape.py index 55042b7..0b30cad 100644 --- a/i_scene_cp77_gltf/material_types/vehicledestrblendshape.py +++ b/i_scene_cp77_gltf/material_types/vehicledestrblendshape.py @@ -8,10 +8,10 @@ def __init__(self, BasePath,image_format): self.BasePath = str(BasePath) self.image_format = image_format def createBaseMaterial(self,matTemplateObj,name): - CT = imageFromPath(self.BasePath + matTemplateObj["colorTexture"],self.image_format) - NT = imageFromPath(self.BasePath + matTemplateObj["normalTexture"],self.image_format,isNormal = True) - RT = imageFromPath(self.BasePath + matTemplateObj["roughnessTexture"],self.image_format,isNormal = True) - MT = imageFromPath(self.BasePath + matTemplateObj["metalnessTexture"],self.image_format,isNormal = True) + CT = imageFromPath(self.BasePath + matTemplateObj["colorTexture"]["DepotPath"],self.image_format) + NT = imageFromPath(self.BasePath + matTemplateObj["normalTexture"]["DepotPath"],self.image_format,isNormal = True) + RT = imageFromPath(self.BasePath + matTemplateObj["roughnessTexture"]["DepotPath"],self.image_format,isNormal = True) + MT = imageFromPath(self.BasePath + matTemplateObj["metalnessTexture"]["DepotPath"],self.image_format,isNormal = True) TileMult = float(matTemplateObj.get("tilingMultiplier",1)) @@ -95,7 +95,7 @@ def createBaseMaterial(self,matTemplateObj,name): return def createOverrideTable(self,matTemplateObj): - OverList = matTemplateObj.get("overrides") + OverList = matTemplateObj["overrides"].get("Properties") if OverList is None: OverList = matTemplateObj.get("Overrides") Output = {} @@ -104,27 +104,27 @@ def createOverrideTable(self,matTemplateObj): Output["RoughLevelsOut"] = {} Output["MetalLevelsOut"] = {} for x in OverList["colorScale"]: - tmpName = x["n"] - tmpR = float(x["v"][0]) - tmpG = float(x["v"][1]) - tmpB = float(x["v"][2]) + tmpName = x["Properties"]["n"] + tmpR = float(x["Properties"]["v"]["Elements"][0]) + tmpG = float(x["Properties"]["v"]["Elements"][1]) + tmpB = float(x["Properties"]["v"]["Elements"][2]) Output["ColorScale"][tmpName] = (tmpR,tmpG,tmpB,1) for x in OverList["normalStrength"]: - tmpName = x["n"] + tmpName = x["Properties"]["n"] tmpStrength = 0 if x.get("v") is not None: - tmpStrength = float(x["v"]) + tmpStrength = float(x["Properties"]["v"]) Output["NormalStrength"][tmpName] = tmpStrength for x in OverList["roughLevelsOut"]: - tmpName = x["n"] - tmpStrength0 = float(x["v"][0]) - tmpStrength1 = float(x["v"][1]) + tmpName = x["Properties"]["n"] + tmpStrength0 = float(x["Properties"]["v"]["Elements"][0]) + tmpStrength1 = float(x["Properties"]["v"]["Elements"][1]) Output["RoughLevelsOut"][tmpName] = [(tmpStrength0,tmpStrength0,tmpStrength0,1),(tmpStrength1,tmpStrength1,tmpStrength1,1)] for x in OverList["metalLevelsOut"]: - tmpName = x["n"] + tmpName = x["Properties"]["n"] if x.get("v") is not None: - tmpStrength0 = float(x["v"][0]) - tmpStrength1 = float(x["v"][1]) + tmpStrength0 = float(x["Properties"]["v"]["Elements"][0]) + tmpStrength1 = float(x["Properties"]["v"]["Elements"][1]) else: tmpStrength0 = 0 tmpStrength1 = 1 @@ -281,7 +281,7 @@ def createLayerMaterial(self,LayerName,LayerCount,CurMat,mlmaskpath,normalimgpat def create(self,Data,Mat): file = open(self.BasePath + Data["MultilayerSetup"] + ".json",mode='r') - mlsetup = json.loads(file.read())["Chunks"]["0"]["Properties"] + mlsetup = json.loads(file.read())["Data"]["RootChunk"]["Properties"] file.close() xllay = mlsetup.get("layers") if xllay is None: @@ -291,12 +291,12 @@ def create(self,Data,Mat): LayerIndex = 0 CurMat = Mat.node_tree for x in (xllay): - MatTile = x.get("matTile") + MatTile = x["Properties"].get("matTile") if MatTile is None: MatTile = x.get("MatTile") - MbTile = x.get("mbTile") + MbTile = x["Properties"].get("mbTile") if MbTile is None: - MbTile = x.get("MbTile") + MbTile = x["Properties"].get("MbTile") MbScale = 1 if MatTile != None: @@ -304,33 +304,34 @@ def create(self,Data,Mat): if MbTile != None: MbScale = float(MbTile) - Microblend = x.get("microblend") + Microblend = x["Properties"]["microblend"].get("DepotPath") if Microblend is None: Microblend = x.get("Microblend") - MicroblendContrast = x.get("microblendContrast") + MicroblendContrast = x["Properties"].get("microblendContrast") if MicroblendContrast is None: MicroblendContrast = x.get("Microblend",1) - microblendNormalStrength = x.get("microblendNormalStrength") + microblendNormalStrength = x["Properties"].get("microblendNormalStrength") if microblendNormalStrength is None: microblendNormalStrength = x.get("MicroblendNormalStrength") - opacity = x.get("opacity") + opacity = x["Properties"].get("opacity") if opacity is None: opacity = x.get("Opacity") - material = x.get("material") + + material = x["Properties"]["material"].get("DepotPath") if material is None: material = x.get("Material") - colorScale = x.get("colorScale") + colorScale = x["Properties"].get("colorScale") if colorScale is None: colorScale = x.get("ColorScale") - normalStrength = x.get("normalStrength") + normalStrength = x["Properties"].get("normalStrength") if normalStrength is None: normalStrength = x.get("NormalStrength") #roughLevelsIn = x["roughLevelsIn"] - roughLevelsOut = x.get("roughLevelsOut") + roughLevelsOut = x["Properties"].get("roughLevelsOut") if roughLevelsOut is None: roughLevelsOut = x.get("RoughLevelsOut") #metalLevelsIn = x["metalLevelsIn"] - metalLevelsOut = x.get("metalLevelsOut") + metalLevelsOut = x["Properties"].get("metalLevelsOut") if metalLevelsOut is None: metalLevelsOut = x.get("MetalLevelsOut") @@ -338,7 +339,7 @@ def create(self,Data,Mat): MBI = imageFromPath(self.BasePath+Microblend,self.image_format,True) file = open(self.BasePath + material + ".json",mode='r') - mltemplate = json.loads(file.read())["Chunks"]["0"]["Properties"] + mltemplate = json.loads(file.read())["Data"]["RootChunk"]["Properties"] file.close() OverrideTable = self.createOverrideTable(mltemplate)#get override info for colors and what not diff --git a/i_scene_cp77_gltf/material_types/vehiclemeshdecal.py b/i_scene_cp77_gltf/material_types/vehiclemeshdecal.py index ed584df..57aed38 100644 --- a/i_scene_cp77_gltf/material_types/vehiclemeshdecal.py +++ b/i_scene_cp77_gltf/material_types/vehiclemeshdecal.py @@ -68,7 +68,7 @@ def create(self,Data,Mat): dirtOpacVal = CreateShaderNodeValue(CurMat, Data["DirtOpacity"], -1200,350, "DirtOpacity") if "DamageInfluence" in Data: - dmgInfVal = CreateShaderNodeValue(CurMat, Data["DamageInfluence"], -1200, 550, "DamageInfluence") + dmgInfVal = CreateShaderNodeValue(CurMat, Data["DamageInfluence"]["Value"], -1200, 550, "DamageInfluence") if "UseGradientMap" in Data: gradMapVal = CreateShaderNodeValue(CurMat, Data["UseGradientMap"], -1200, 750, "UseGradientMap") \ No newline at end of file