Direct Image Texture to Material Output Connector
This Blender script automatically connects the existing image texture node in a material directly to the material output for selected mesh objects. Simply select the objects you want to modify and run the script in Blender's scripting editor.

Broken button... I'll fix it eventually...
import bpy
# Iterate through selected objects
for obj in bpy.context.selected_objects:
if obj.type == 'MESH' and obj.data.materials: # Ensure the object is a mesh with materials
for material in obj.data.materials:
if material and material.use_nodes: # Ensure the material uses nodes
node_tree = material.node_tree
nodes = node_tree.nodes
# Find the existing image texture node and material output node
image_texture_node = None
material_output_node = None
for node in nodes:
if node.type == 'TEX_IMAGE':
image_texture_node = node
elif node.type == 'OUTPUT_MATERIAL':
material_output_node = node
# If both image texture and material output nodes are found, connect them
if image_texture_node and material_output_node:
# Remove existing links to the material output node
for link in list(node_tree.links):
if link.to_node == material_output_node:
node_tree.links.remove(link)
# Connect the Color output of the Image Texture to the Surface input of the Material Output
node_tree.links.new(image_texture_node.outputs['Color'], material_output_node.inputs['Surface'])
print("Image Texture node connected directly to Material Output for selected objects successfully.")
Description
Long Description:
This script is designed to streamline the process of connecting image texture nodes directly to the material output in Blender's shader editor. It operates on selected mesh objects with materials that use node-based workflows.
When executed, the script performs the following steps:
Object and Material Validation: It checks if the selected objects are meshes and if they have materials that use nodes.
Node Detection: It identifies the image texture node (
TEX_IMAGE
) and the material output node (OUTPUT_MATERIAL
) within each material's node tree.Connection Cleanup: Removes any existing links to the material output node to ensure a clean configuration.
Direct Connection: Links the
Color
output of the image texture node to theSurface
input of the material output node.
How to Use:
Open Blender and ensure the objects you want to modify are selected in the viewport.
Navigate to the Scripting workspace.
Create a new script or paste the provided code into an existing script file.
Press the "Run Script" button to execute it.
The script processes all selected objects, and if they meet the criteria, it modifies their materials to directly connect the image texture node to the material output. This setup is particularly useful for simplifying materials or preparing assets for workflows that only require the base texture.