Skip to content

Commit

Permalink
blender: Fix incompatibilities with Blender 4
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
e-rk committed Dec 10, 2023
1 parent 9b79d68 commit b088679
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions speedtools/blender/io_nfs4_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@
logger.setLevel(logging.INFO)
logger.addHandler(logging.StreamHandler())

major_version, _, _ = bpy.app.version


bl_info = {
"name": "Import NFS4 Track",
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit b088679

Please sign in to comment.