From b08867968d15ce3ec59d49caae047ad07dcc4e18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Ku=C5=BAnia?= Date: Sun, 10 Dec 2023 14:30:00 +0100 Subject: [PATCH] blender: Fix incompatibilities with Blender 4 The Principled BSDF node was updated and some inputs, such as Specular and Sheet Tint are no longer present. Instead, there is IOR Level, which is set to 0 to achieve in-game look. --- speedtools/blender/io_nfs4_import.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/speedtools/blender/io_nfs4_import.py b/speedtools/blender/io_nfs4_import.py index 350c896..0967c94 100644 --- a/speedtools/blender/io_nfs4_import.py +++ b/speedtools/blender/io_nfs4_import.py @@ -45,6 +45,8 @@ logger.setLevel(logging.INFO) logger.addHandler(logging.StreamHandler()) +major_version, _, _ = bpy.app.version + bl_info = { "name": "Import NFS4 Track", @@ -136,9 +138,13 @@ def _make_material(self, ext_resource: ExtendedResource) -> bpy.types.Material: image_texture.image = image # type: ignore[attr-defined] image_texture.extension = "EXTEND" # type: ignore[attr-defined] bsdf = node_tree.nodes["Principled BSDF"] - bsdf.inputs["Specular"].default_value = 0 # type: ignore[attr-defined] + if major_version == 3: + bsdf.inputs["Specular"].default_value = 0 # type: ignore[attr-defined] + bsdf.inputs["Sheen Tint"].default_value = 0 # type: ignore[attr-defined] + else: + # IOR Level + bsdf.inputs[12].default_value = 0 # type: ignore[attr-defined] bsdf.inputs["Roughness"].default_value = 1 # type: ignore[attr-defined] - bsdf.inputs["Sheen Tint"].default_value = 0 # type: ignore[attr-defined] self._link_texture_to_shader(node_tree=node_tree, texture=image_texture, shader=bsdf) output_socket = self._set_blend_mode( node_tree=node_tree,