enter image description here

I have 784 cubes in my scene right now, and I can loop through all 784 of them by using

for i in range(784):

Each cube represents a pixel which is in grayscale color, a value between 0.0 to 1.0. I already have my colors extracted from a 2D grayscale image and now I just want to transfer the corresponding brightness value to the cubes. Basically, do:


and repeat for all 784 cubes. I am currently using blender 2.8 but I don't think this is going to be much different than 2.79.

Any help is appreciated!


1 Answer 1


If you use in bpy.data.objects.active_material.material.diffuse_color you can set the diffuse color, and there are some other properties that may be useful here and here

In my experience, materials are tricky with scripts. You need to remember that materials are separate from the objects, so if the same material is assigned to every cube, changing it for one material will change it for all of them.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .