Randomising crowd textures per model with Solaris and Arnold

   783   1   1
User Avatar
Member
27 posts
Joined: Oct. 2018
Offline
I'm able to randomise skin textures with something like this in a wrangle lop:

int variant = floor(rand(@elemnum+ch("seed")) * 10);

string root = chs("root");

s@primvars:diffuse = sprintf('%s/skin_%s.exr',root,variant);

And then loading the diffuse attribute in a User Data String in my Arnold shader which plugs into an Arnold image vop filename.

That works well but I need to do something similar for the clothes. The clothes have specific textures for each model (with a number of variants per model) so I need to incorporate the asset name when building the texture path. How can I do that and still have a random variant per agent?

Or is this better achieved with a material variation lop? Does that work with Arnold?

If I can solve that i would like to take it one step further... The number of texture variants is not always the same for each model. I've written a python script to scan the folders and count the number of available variants. I can store this on the geometry before I create the agent and then this attribute is available in the shape library in lops. So in my wrangle I would like to:

- get the asset name (from the lop node name)
- find the corresponding "texture_variants" number from the shape library
- create a random variant number based on the number of available variants
- build the texture path and save it as a primvar
- use the primvar in my shader

I'm new to Solaris so any help would be a massive help.
User Avatar
Member
27 posts
Joined: Oct. 2018
Offline
I think I'm close...

I'm now storing the texture path without the variant number on the clothes geometry before I create the agent.

I then use a wrangle lop to create a random "variant" primvar per agent.

I can then assemble the full file path in my shader by using tokens in the Arnold image node:

<attr:texture><attr:variant>.jpg

This works however the randomisation is done per agent not per clothing model on the agent, so if two agents have the same clothing combination and the same (texture) variant attribute then they will have identical clothes and textures. I want to increase randomisation by randomising per clothing model, not agent.

Is this possible?

The only other options I can think of that could maybe work:

- generate a random number in the shader (which I think would work per agent clothing item?..) and then use something like osl to concatenate the texture prefix and the random number to get the full path

Or maybe create a shader per clothing model - we have around 70 clothing models so managing 70 shaders isn't ideal.

Or creating duplicating the clothing models for each texture variant or something but this sounds like a terrible idea...
  • Quick Links