copy stamping

   1853   2   1
User Avatar
Member
2 posts
Joined: Feb. 2013
Offline
Hi all,

I am fairly new to houdini so it could be that the solution to my problem is really simple.

I want to create a 3D matrix of different pictures and then move among them with the camera. I created a simple grid object I want to copy with the copy sop. As I only have 32 different images as textures and I will need at least 200 pictures I thought I would assign the 32 textures to my “main” grids and then randlomy assign the same 32 textures to the remaining 160+ grids. I want to have similar sized grids regardless of the original resolution of the images, I only care about the image aspect ratio as I don't want to distort any of them. Unfortunately I could not find any better way to get this info from a material itself so I imported all the 32 images into a comp and named them IMG_1 to IMG_32 and assigned these to 32 materials.

And here comes the problem: In the copy sop I turned on stamp inputs and created a variable called img_material. As I can't give it a string value I chose to use clamp(rand(24242), 1, 32) so I will have a random number between 1 and 32. I want to calculate the sizex and sizey of the grid based on the aspect of the randomly selected image. I could however use this expression for the materials: /shop/image_`stamp(“../copy1”, “img_material”, 1) + 1`

Here is one example I tried which does not work. I was trying different versions, simplified ones for at least 3 hours straight but nothing worked so far I also tried the evals() function with no luck either.

if(ch('/img/comp1/IMG_'`stamp(“../copy1”, “img_material”, 1) + 1`'/size1') > ch('/img/comp1/IMG_'`stamp(“../copy1”, “img_material”, 1) + 1`'/size2'), 1, ch('/img/comp1/IMG_'`stamp(“../copy1”, “img_material”, 1) + 1`'/size1') / ch('/img/comp1/IMG_'`stamp(“../copy1”, “img_material”, 1) + 1`'/size2'))

I would really appreciate it if someone could help me solve this problem.
User Avatar
Member
258 posts
Joined:
Offline
There are several ways on can go about something like this but the easiest is to copy stamp a switch node and use an expression in the copy stamp like

myDifferentTexture = int(rand($PT) * 10) << the number ten will iterate through 10 different inputs into the switch node, adjust as necessary)

Then reference that attribute with the stamp function in the switch node:

stamp(“../copy1”, “myDifferentTexture”, 0)

You could stamp the file input but if you want to control the uv's and aspect ratio this might be the easiest.
User Avatar
Member
2 posts
Joined: Feb. 2013
Offline
Thanks! I'll try your approach.
  • Quick Links