I am trying to add the content of a image to the surface of a mesh on Blender 2.80, but the better I have achieved was to apply the image color to surface. I am using cycles renderer.
I have this function so far, it takes the path to the image and the mesh object as arguments.
def add_texture(texture_path, obj):
mat = bpy.data.materials.new(name='texture')
mat.use_nodes = True
nodes = mat.node_tree.nodes
texImage = nodes.new('ShaderNodeTexImage')
texImage.image = bpy.data.images.load(texture_path)
# What to link here?
# mat.node_tree.links.new()
# Assign it to object
if obj.data.materials:
obj.data.materials[0] = mat
else:
obj.data.materials.append(mat)
I created a material added the image as a texture, It seems that I have to link some attribute of the texture to the material, but I cannot find what I have to do exactly.
Any ideas on how to apply the image content to the mesh surface?
Principled
? Would this be the linkmat.node_tree.links.new(texImage.Outputs[0], principled.Inputs[0]['Base Color'])
$\endgroup$