I want to generate a grid of Objects based on an Image Texture.
- I want to read the pixel data from an image
- I want to generate an Object for every pixel (e.g. a plane) and colorize the object based on the pixel color
I want to use one single material for all objects and only change its color value.
Is this possible with python? Or is there another way? How can I store color data in an object?
The Final Look should be something like this:
My code so far...
import bpy
cubeSize = 0.5
image = bpy.data.images["vangogh.jpg"]
width = image.size[0]
height = image.size[1]
for x in range(width):
for y in range(height):
plane = bpy.ops.mesh.primitive_plane_add(size=cubeSize, location=(x*cubeSize, y*cubeSize, 0.0))
index = x + y * width
r = image.pixels[index]
g = image.pixels[index+1]
b = image.pixels[index+2]