5,332
edits
(→Images) |
|||
Line 86: | Line 86: | ||
# Add an image | # Add an image | ||
image_bpy = bpy.data.images.new("my_image", width=width, height=height, alpha=(channels==4), float_buffer=False) | image_bpy = bpy.data.images.new("my_image", width=width, height=height, alpha=(channels==4), float_buffer=False) | ||
image_bpy.pixels = image_np.ravel() | image_bpy.pixels = np.flipud(image_np).ravel() | ||
my_material.node_tree.links.new( | image_tex_node = my_material.node_tree.nodes.new("ShaderNodeTexImage") | ||
image_tex_node.image = image_bpy | |||
my_material.node_tree.links.new(image_tex_node.outputs['Color'], my_bsdf.inputs['Base Color']) | |||
</syntaxhighlight> | </syntaxhighlight> | ||