show images dynamic

   1292   3   1
User Avatar
Member
10 posts
Joined: March 2017
Offline
there are so many images I want to show by procedural. for example hundred of human face I want to hang on the wall.

how to do that? create a material one bye one then apply a texture?
User Avatar
Member
359 posts
Joined: April 2017
Offline
You can override any input of a material using the s@shop_materialoverride primitive string attribute. This would allow you to use a single material for every one of these objects, but vary just the diffuse texture, or any other input.

For example, let's say you have a hundred images, named "image1" through "image100". In a Primitive Wrangle:

int i = int(rand(@ptnum)*100);
string path = sprintf("/path/to/my/images/image%g", i);
string input = "basecolor_texture"; // this changes based on what material input you're overriding
s@shop_materialoverride = sprintf("'{%g':\"%g\",}", input, path);

That'll randomly override "basecolor_texture" of the assigned shader (that input name is specific to the Principled Shader, but you could change it to anything else) for each primitive.

That VEX code is a bit ugly with the dictionary in there, but it does work. It's the same string you get when overriding inputs via a Material SOP, but this gives you a little more flexibility without having to use even uglier HScript expressions to choose the path. If you need to double-check the syntax, use the Material SOP to create a "local override" and then check your Geometry Spreadsheet to see what the string attribute is supposed to look like.

You could also use Material Stylesheets [www.sidefx.com] to override the same input, per-primitive. You'd still have to create a string attribute per-primitive that had the image path you want to override with.

I also wrote a utility as part of the MOPs Plus [motionoperators.com] plugin that allows you to use a spreadsheet of sorts to quickly input file paths and assign them to material parameters. That's probably the easiest way to do what you want. If you don't mind doing things the manual way, though, I recommend just creating that override attribute or using stylesheets.
MOPs (Motion Operators for Houdini): http://www.motionoperators.com [www.motionoperators.com]
User Avatar
Member
10 posts
Joined: March 2017
Offline
toadstorm
You can override any input of a material using the s@shop_materialoverride primitive string attribute. This would allow you to use a single material for every one of these objects, but vary just the diffuse texture, or any other input.

For example, let's say you have a hundred images, named "image1" through "image100". In a Primitive Wrangle:

int i = int(rand(@ptnum)*100);
string path = sprintf("/path/to/my/images/image%g", i);
string input = "basecolor_texture"; // this changes based on what material input you're overriding
s@shop_materialoverride = sprintf("'{%g':\"%g\",}", input, path);

That'll randomly override "basecolor_texture" of the assigned shader (that input name is specific to the Principled Shader, but you could change it to anything else) for each primitive.

That VEX code is a bit ugly with the dictionary in there, but it does work. It's the same string you get when overriding inputs via a Material SOP, but this gives you a little more flexibility without having to use even uglier HScript expressions to choose the path. If you need to double-check the syntax, use the Material SOP to create a "local override" and then check your Geometry Spreadsheet to see what the string attribute is supposed to look like.

You could also use Material Stylesheets [www.sidefx.com] to override the same input, per-primitive. You'd still have to create a string attribute per-primitive that had the image path you want to override with.

I also wrote a utility as part of the MOPs Plus [motionoperators.com] plugin that allows you to use a spreadsheet of sorts to quickly input file paths and assign them to material parameters. That's probably the easiest way to do what you want. If you don't mind doing things the manual way, though, I recommend just creating that override attribute or using stylesheets.


thanks a lot.. you Show me the way!
User Avatar
Member
7759 posts
Joined: Sept. 2011
Offline
Depending on how much resolution you need, you could also try a mosaic texture. Combine all the pictures into a grid in one texture. And then offset the uv coordinates in the meshes to correspond to each tile.
  • Quick Links