Skip to content

Commit

Permalink
[F3D] Quick BSDF converter fix (Fast-64#465)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lilaa3 authored Sep 23, 2024
1 parent ddd6969 commit 7cdb920
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions fast64_internal/f3d_material_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,16 +186,16 @@ def convertAllBSDFtoF3D(objs, renameUV):
def convertBSDFtoF3D(obj, index, material, materialDict):
if not material.use_nodes:
newMaterial = createF3DMat(obj, preset="Shaded Solid", index=index)
f3dMat = newMaterial.f3d_mat if newMaterial.mat_ver > 3 else newMaterial
f3dMat.default_light_color = material.diffuse_color
with bpy.context.temp_override(material=newMaterial):
newMaterial.f3d_mat.default_light_color = material.diffuse_color
updateMatWithName(newMaterial, material, materialDict)

elif "Principled BSDF" in material.node_tree.nodes:
tex0Node = material.node_tree.nodes["Principled BSDF"].inputs["Base Color"]
if len(tex0Node.links) == 0:
newMaterial = createF3DMat(obj, preset=getDefaultMaterialPreset("Shaded Solid"), index=index)
f3dMat = newMaterial.f3d_mat if newMaterial.mat_ver > 3 else newMaterial
f3dMat.default_light_color = tex0Node.default_value
with bpy.context.temp_override(material=newMaterial):
newMaterial.f3d_mat.default_light_color = tex0Node.default_value
updateMatWithName(newMaterial, material, materialDict)
else:
if isinstance(tex0Node.links[0].from_node, bpy.types.ShaderNodeTexImage):
Expand All @@ -213,8 +213,8 @@ def convertBSDFtoF3D(obj, index, material, materialDict):
else:
presetName = getDefaultMaterialPreset("Shaded Texture")
newMaterial = createF3DMat(obj, preset=presetName, index=index)
f3dMat = newMaterial.f3d_mat if newMaterial.mat_ver > 3 else newMaterial
f3dMat.tex0.tex = tex0Node.links[0].from_node.image
with bpy.context.temp_override(material=newMaterial):
newMaterial.f3d_mat.tex0.tex = tex0Node.links[0].from_node.image
updateMatWithName(newMaterial, material, materialDict)
else:
print("Principled BSDF material does not have an Image Node attached to its Base Color.")
Expand Down

0 comments on commit 7cdb920

Please sign in to comment.