If you're using array modifiers and therefore have just one object, then use Texture Coordinate node like so:
![](https://cdn.statically.io/img/i.sstatic.net/ePlqG.png)
Now use "Separate XYZ" and "Math: Less Than" nodes to discover the width of your setup: (of course you could calculate it instead)
![](https://cdn.statically.io/img/i.sstatic.net/7HIm1.png)
Repeat the same for the y coordinate.
Put reciprocals of found values in the scale of the "Mapping" node. In my example the width is 58.88, so I type 1 / 58.88
as x scale and Blender calculates the reciprocal for me: 0.018
. Then do the same with y scale.
![](https://cdn.statically.io/img/i.sstatic.net/GzVxo.png)
The chairs are painted "too well"; to make each chair have only a single color, snap the coordinates to the nearest chair using Vector Math: Snap node:
![](https://cdn.statically.io/img/i.sstatic.net/As1C2.png)
I have 20 rows, therefore I put 1 / 20
(= 0.05
) into the y field, and I have 50 chairs in a row, therefore I set x to 1/50
(= 0.02
).
Each chair's color depends on a single sample from the texture, so for the best effect use 2D software scale your texture to have the same number of pixels as the number of chairs:
![](https://cdn.statically.io/img/i.sstatic.net/ja0sI.png)
Alternative 1 - UV coordinates
You can ignore spacing and allow yourself to move stuff around (by modifiers or by applying the modifiers and moving manually) by using the UV offsets in the Array modifiers - keep in mind, if you don't use planes but something more complex like a chair, you need to unwrap it as in Moonbot's answer (but unwrap a single chair, not all chairs at once).
![](https://cdn.statically.io/img/i.sstatic.net/gDzuy.png)
You can now move stuff around:
![](https://cdn.statically.io/img/i.sstatic.net/yxbEs.png)
Alternative 2 - Object coordinates
If you have multiple objects, use Object coordinate, and specify the Object field:
to the object with the lowest x and y coordinates:
- subtract the current object's coordinate, to snap to the centers of chairs;
- add x:1; y:1, because object coordinate system starts at
-1
, and you want to start at 0
;
- multiply by the relative spacing you used in array modifiers to get the width together with spacing (object coordinate defines a range between bounding box boundaries);
- when calculating the reciprocals, I'm using
.5
as dividend instead of 1
to avoid adding another node dividing by 2
; the reason to divide by two is that the base object coordinate system is in range -1..1
, we added 1 so it's now 0..2
, either way it's twice bigger than normalized range.
![](https://cdn.statically.io/img/i.sstatic.net/lOudm.png)
This setup is also spill-safe:
![](https://cdn.statically.io/img/i.sstatic.net/K7p03.gif)