Setup: Blender 2.82

I have multiple images that i take from a CNN and i want to put on planes

I tried like this:

mat = bpy.data.materials.new(name='test')
mat.use_nodes = True
bsdf = mat.node_tree.nodes["Principled BSDF"]
texImage = mat.node_tree.nodes.new('ShaderNodeTexImage')
texImage.image = bpy.data.images.load(image)
mat.node_tree.links.new(bsdf.inputs['Base Color'], texImage.outputs['Color'])

bpy.ops.mesh.primitive_plane_add(location=(k, y,  l ))
bpy.context.active_object.name = 'plane'
plane = bpy.context.object

if plane.data.materials:
     plane.data.materials[0] = mat

How can the image be loaded from an numpy array of pixels ?

Additionally to this, does the image added to the plane needs to respect some format?

  • 2
    $\begingroup$ That's because it's called ShaderNodeTexImage. $\endgroup$ – Robert Gützkow Apr 9 '20 at 14:58
  • $\begingroup$ Thanks for noticing, i updated the question $\endgroup$ – cUser Apr 9 '20 at 15:14

The only solution is to save the image that you want to put it on the plane and to load the image from there

texImage.image = bpy.data.images.load("path to your image saved previously in code")


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.