I'm trying to do as the title says:
I have several hundred models that have image textures that we're imported into the Base Color node. These textures have transparency and I've been able to fix the transparency issue by linking the base color node alpha to BSDF alpha and setting the blend mode in settings to alpha clip.
I am attempting to make a script that will loop through every material and apply these changes but so far I haven't had any luck in getting anything to work. Each material is nested in a collection that is named after the file for exporting reasons. Each material is setup the exact same way.
I've tried adapting the code from : Using python to batch link image texture alpha to Principled BSDF
As this was the closest I could thing I could find as a starting point.
import bpy
from bpy_extras.node_shader_utils import PrincipledBSDFWrapper
# Run through all materials of the current blend file
for mat in bpy.data.materials:
# If the material has a node tree
if mat.node_tree:
# Link alpha from image texture to alpha on principled bsdf
mat.node_tree.links.new( mat.node_tree.nodes['Principled BSDF'].inputs['Alpha'], mat.node_tree.nodes['Base Color'].outputs['Alpha'] )
Thank you very much for your time and help
HASHED
on the last line toCLIP
if you want to use Alpha Clip instead. $\endgroup$