Jump to content
z3r0

Load Images from Directory and Map to Objects (randomly)

Recommended Posts

Hi,

I'm trying to load multiple images from a directory and map them to multiple copies/instances of a cube (cube attached to points on a grid) which I later want to attach to particles

or animate.

The images would need to map to only one face of the cube and not repeat.

I'm trying to avoid manually mapping each image to each cube as I don't know the exact number of images in the folder.

I found these that might help:

Image sequence and sprites

TV copy

For example look at the image grid here:

(Jump to 2:51)

Each image would need to be manually added to each square. Now if I could automatically load them from a directory (or image sequence)

to each corresponding slot I would save lots of time.

Each slot would be a cube (instanced on grid), would love to attach each instance to particles and animate.

Any ideas on how to approach?

Thanks!

Edited by z3r0

Share this post


Link to post
Share on other sites

Have a look at this:

The example hip file there shows you how to override material parameters on a per-point/instance basis. Which is most likely what you want / need for your random textures.

Remember, to make things really easy for yourself, keep your texture names consistent, for example:

- name all your images numerically, like: 0.exr, 1.exr, 2.exr, etc.

This will allow you to override, say, a texture parameter on your shader with something like:

/my/random/pics/$PT.exr

Obviously, the texture name expression will become a little more involved but the above is just to get you started.

HTH.

CheerZ,

Van Aarde.

Edited by nanocell
  • Like 1

Share this post


Link to post
Share on other sites

Here is a quick example I came up with. Using the Material SOP override mentioned above with local variables.

Hope this helps.

randomTextures.hip

  • Like 2

Share this post


Link to post
Share on other sites

Great find Van!

This will definitely help, I'll post progress as soon as I can!

-z3r0

Have a look at this:

The example hip file there shows you how to override material parameters on a per-point/instance basis. Which is most likely what you want / need for your random textures.

Remember, to make things really easy for yourself, keep your texture names consistent, for example:

- name all your images numerically, like: 0.exr, 1.exr, 2.exr, etc.

This will allow you to override, say, a texture parameter on your shader with something like:

/my/random/pics/$PT.exr

Obviously, the texture name expression will become a little more involved but the above is just to get you started.

HTH.

CheerZ,

Van Aarde.

Share this post


Link to post
Share on other sites

Thanks Ryan!

I plan at looking at this tomorrow, I'll post updates!

-z3r0

Here is a quick example I came up with. Using the Material SOP override mentioned above with local variables.

Hope this helps.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×