Skip to content

Commit

Permalink
Locate Principled BSDF by type not name (#731)
Browse files Browse the repository at this point in the history
  • Loading branch information
carson-katri authored Nov 6, 2023
1 parent 1d18097 commit 62fde86
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion operators/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,8 @@ def step_progress_update(self, context):
material = bpy.data.materials.new(name="diffused-material")
material.use_nodes = True
image_texture_node = material.node_tree.nodes.new("ShaderNodeTexImage")
material.node_tree.links.new(image_texture_node.outputs[0], material.node_tree.nodes['Principled BSDF'].inputs[0])
principled_node = next((n for n in material.node_tree.nodes if n.type == 'BSDF_PRINCIPLED'))
material.node_tree.links.new(image_texture_node.outputs[0], principled_node.inputs[0])
uv_map_node = material.node_tree.nodes.new("ShaderNodeUVMap")
uv_map_node.uv_map = bpy.context.selected_objects[0].data.uv_layers.active.name if context.scene.dream_textures_project_bake else "Projected UVs"
material.node_tree.links.new(uv_map_node.outputs[0], image_texture_node.inputs[0])
Expand Down

0 comments on commit 62fde86

Please sign in to comment.