Using the Attribute Node to access images

I’m experimenting with getting variable images into a single material. Getting values and data from all kinds of properties works just fine but it seems like images cannot be accessed:

Surely there’s also the missing Vector input to consider to project the image in some way but since none of the pixels’ color values seem to be accessed anyway (the output wouldn’t be black then), I don’t believe that matters at this point.

I’ve tried other methods to point at the image as well, such as this:

… or directly accessing pixels from the image. The outcome is always the same though. I’m wondering if what I am attempting is a dead end or actually possible in some way.

It’s a dead end!

The Attribute node can only reference single properties (like floats, colors, vectors,…) from a specific domain (Viewlayer, Object, Instance or Geometry). An image is not a single property, so the Attribute node is not a choice.

However, you can access any pixel from an image using the ImageTexture node, with the correct normalized coordinate as the vector.

For example, you want to access the pixel [200, 400] of a 800x600 image, then you need to use the vector [(200/800), (400/600), 0] => [0.25, 0.666, 0].

1 Like

Too bad, I thought so. Would have been nice to be able to use images per object, not per material.

You can store an integer in your objects (i normally just use the ‘Pass Index’), and in the material, switch between different textures based on that integer (here, with the Attribute node).

Yes, I’ve been considering that as well. I’ll need to try that and see if it’s more convenient for my use case than creating additional materials.

It’s also possible to use a python script to create materials automatically based on some property in the object. And in this case, your property can even be an Image Data-Block.

Creating a script can take its time, but if you need this feature in a regular basis, then it will soon pay itself.

I know, this is actually part of add-on development. :slight_smile:
Need to see what’s best for usability.