How to have a different vector for different objects with the same material?

I have a picture frame model with the actual pictures in one image texture, how would I have a different vector for different instances of this picture frame so they have different pictures?

Hi @ilovefishing223,

Welcome to the community :slight_smile:

I’m not sure whether you require that the pictures be randomly assigned to each instance of the frame, but assuming that is the case . . .

  1. The image I’m using to represent your picture ‘gallery’

  1. Align the UV of the mesh geometry that is the actual picture to fit exactly the first image in ‘gallery’ . The columns and rows must be straight and aligned, and fit into the 1x1 of the UV space to keep the math simple.

  2. The material uses the position of each frame instance, extracts the x and z coordinates ( the frames are stacked up and down to Z is this axis) and uses this to drive the randomness value of a 1D white noise texture. This produces a pseudo-random number between 0 and 1.

  3. This 0 to 1 number is then remapped to a value between 1 and 4 for the X uv space, ( which is the number of ‘pictures’ across the gallery), and between 1 and 5 for the Y uv space ( number of images vertically in the gallery)

  4. After the mapping range, the number is ‘truncated’ to remove anything after the decimal point in the maths, ie it gives a whole number . . . either between 1 and 4 ( X value ) or 1 and 5 ( Y value ).

  5. Because the uv space is a square of unit 1, each horizontal image is 0.25 of this width, and each vertical image is 0.2. So multiplying the number from step 4 ( above) with these numbers gives a perfect offset for each image in the gallery.

  6. This offset is then added to the existing uv location space.

and my blend file :slight_smile: . . . ( you’ll need to also download the image in step 1 for the material to work. ) And I’ve not inculded my HDRI bg image. Any will do for this demo.

Pictures_01.blend1 (1.0 MB)

Cheers,
Dj.

1 Like

Welcome :tada:

…if i understand you correctly then you want to select a random subimage from a grid of images like so (for a 2x2 image… changeable by the input value…)

But i’m 5 minutes too late…

(selection changes if moved)

1 Like

. . . sorry @Okidoki . . . I could say ‘better luck next time’, but you’re usually so quick to respond I shall consider myself 5 minutes too early in this case :grin:

anyway, to add to my original, and should the OP want to be able to select what pictures goes in which frame . . .

Here’s a setup that uses a custom property, called Pic-Number, which allows the user to select from the ‘gallery’ ( in this case 1 to 20 . . . top left to bottom right ) which image to display in the frame.

However, I’ve additionally added a second Custom Property called OverRide Random selection which specifically enables whether the pictures uses a chosen number or is the original random one.
This has to use a fancy maths trick in lieu of a boolean switch.

Here’s the new blend file . . .
Pictures_02.blend (1.1 MB)

Dj.

2 Likes

Hi, if you want to control the exact image displayed in a given frame, you can create a custom integer property on your objects, and reference it from within the material nodetree with the attribute node set to object.

Works perfectly, thanks a ton!

1 Like

There are others by far quicker… but thanks :blush:

1 Like