Skip to content

Commit

Permalink
Fix for metallic and specular utility for Blender 3
Browse files Browse the repository at this point in the history
  • Loading branch information
Naxela committed Dec 2, 2021
1 parent 54a2f84 commit 080b05a
Showing 1 changed file with 42 additions and 18 deletions.
60 changes: 42 additions & 18 deletions addon/operators/tlm.py
Expand Up @@ -1092,11 +1092,15 @@ def execute(self, context):

if node.type == "BSDF_PRINCIPLED":

node.inputs[5].default_value = 0.0
for inp in node.inputs:

if node.inputs[5].links and bpy.context.scene.TLM_SceneProperties.tlm_remove_met_spec_link:
if inp.name == "Specular":

mat.node_tree.links.remove(node.inputs[5].links[0])
inp.default_value = 0.0

if inp.links and bpy.context.scene.TLM_SceneProperties.tlm_remove_met_spec_link:

mat.node_tree.links.remove(inp.links[0])

elif bpy.context.scene.TLM_SceneProperties.tlm_utility_set == "Selection":
for obj in bpy.context.selected_objects:
Expand All @@ -1110,11 +1114,15 @@ def execute(self, context):

if node.type == "BSDF_PRINCIPLED":

node.inputs[5].default_value = 0.0
for inp in node.inputs:

if inp.name == "Specular":

if node.inputs[5].links and bpy.context.scene.TLM_SceneProperties.tlm_remove_met_spec_link:
inp.default_value = 0.0

mat.node_tree.links.remove(node.inputs[5].links[0])
if inp.links and bpy.context.scene.TLM_SceneProperties.tlm_remove_met_spec_link:

mat.node_tree.links.remove(inp.links[0])

else: #Enabled
for obj in bpy.context.scene.objects:
Expand All @@ -1129,11 +1137,15 @@ def execute(self, context):

if node.type == "BSDF_PRINCIPLED":

node.inputs[5].default_value = 0.0
for inp in node.inputs:

if inp.name == "Specular":

inp.default_value = 0.0

if node.inputs[5].links and bpy.context.scene.TLM_SceneProperties.tlm_remove_met_spec_link:
if inp.links and bpy.context.scene.TLM_SceneProperties.tlm_remove_met_spec_link:

mat.node_tree.links.remove(node.inputs[5].links[0])
mat.node_tree.links.remove(inp.links[0])

return{'FINISHED'}

Expand All @@ -1157,11 +1169,15 @@ def execute(self, context):

if node.type == "BSDF_PRINCIPLED":

node.inputs[4].default_value = 0.0
for inp in node.inputs:

if node.inputs[4].links and bpy.context.scene.TLM_SceneProperties.tlm_remove_met_spec_link:
if inp.name == "Metallic":

mat.node_tree.links.remove(node.inputs[4].links[0])
inp.default_value = 0.0

if inp.links and bpy.context.scene.TLM_SceneProperties.tlm_remove_met_spec_link:

mat.node_tree.links.remove(inp.links[0])

elif bpy.context.scene.TLM_SceneProperties.tlm_utility_set == "Selection":
for obj in bpy.context.selected_objects:
Expand All @@ -1175,11 +1191,15 @@ def execute(self, context):

if node.type == "BSDF_PRINCIPLED":

node.inputs[4].default_value = 0.0
for inp in node.inputs:

if inp.name == "Metallic":

if node.inputs[4].links and bpy.context.scene.TLM_SceneProperties.tlm_remove_met_spec_link:
inp.default_value = 0.0

mat.node_tree.links.remove(node.inputs[4].links[0])
if inp.links and bpy.context.scene.TLM_SceneProperties.tlm_remove_met_spec_link:

mat.node_tree.links.remove(inp.links[0])

else: #Enabled
for obj in bpy.context.scene.objects:
Expand All @@ -1194,11 +1214,15 @@ def execute(self, context):

if node.type == "BSDF_PRINCIPLED":

node.inputs[4].default_value = 0.0
for inp in node.inputs:

if inp.name == "Metallic":

inp.default_value = 0.0

if node.inputs[4].links and bpy.context.scene.TLM_SceneProperties.tlm_remove_met_spec_link:
if inp.links and bpy.context.scene.TLM_SceneProperties.tlm_remove_met_spec_link:

mat.node_tree.links.remove(node.inputs[4].links[0])
mat.node_tree.links.remove(inp.links[0])

return{'FINISHED'}

Expand Down

0 comments on commit 080b05a

Please sign in to comment.