Cuibo Cui

popple

About Me

Expertise
Not Specified
Location
Not Specified
Website

Connect

Recent Forum Posts

how to partition by primitives April 15, 2021, 12:30 a.m.

how to access data of upstream to build work items

for example `nprims` of upstream to build `nprims` number of work items

show images dynamic April 11, 2021, 6:01 a.m.

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!

show images dynamic April 9, 2021, 4:49 a.m.

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?