Author Topic: [Automation Toolkit] Multi-Material Switch - parameters not passed  (Read 3567 times)

Hello,

I'm working on a code driven way to texture props and crowds characters according to set Color ID Maps with random variations of e.g. wood, fabric or metal materials. I want to choose randomly from a pool of e.g. different wooden materials to texture parts of the meshes.

Now for that I need a Multi-Material Switch node as I want to switch randomly between different e.g. wooden materials to texture one color on the Color ID Map.

I know that there is a Multi-Material Switch from the community (https://share.allegorithmic.com/libraries/1154) but there's a very big problem with that one:

When I try to access the exposed parameter of the Multi-Material Switch (what selection it has) and randomize it, the maps just come out all transparent. It seems like the node doesn't pass the parameters to randomize and I don't know why. It works if I use the built in Material Switch, which unfortunately only lets you switch between two materials. The Multi-Color/ Grayscale Switch also works fine for images.

In Substance Designer everything works perfectly but as soon as I try to access the exposed parameters via code they are not accessible. I'll attatch a sample setup that I would need, maybe one of you has a good idea how to solve this.

EDIT: If I just replace one of the Multi-Material Switch nodes with a shipped Material Switch node this one set renders out perfectly, with randomization etc. The others still don't.



Last Edit: August 25, 2017, 03:44:03 pm

Yes, this is due to a known design problem with the Substance Cooker (the component which compiles substances graphs). The cause is that if you expose a graph parameter and then apply a function to drive that parameter, the result of that function is not computed once and for all, but instead the function is called every single time the parameter is used inside the graph. This works ok if the exposed parameter is used only once or if the function gives the same result every single time but if its result is random, strange things are likely to happen.
Last Edit: August 25, 2017, 05:30:33 pm

Yes, this is due to a known design problem with the Substance Cooker (the component which compiles substances graphs). The cause is that if you expose a graph parameter and then apply a function to drive that parameter, the result of that function is not computed once and for all, but instead the function is called every single time the parameter is used inside the graph. This works ok if the exposed parameter is used only once or if the function gives the same result every single time but if its result is random, strange things are likely to happen.


Okay, but is there any way you could imagine to work around that?

I still don't understand why the built in Material Switch, and the Multi-Color/Grayscale Switch work fine but this Multi-Material Switch doesn't. Maybe there is something else I overlooked?

Quote
Okay, but is there any way you could imagine to work around that?

Not really, but I am unsure I really understand what you are trying to achieve by assigning a random number to your material switches. Even if the issue with the cooker was fixed, I don't think the result would be what you want: if you apply that substance to several different objects, it will always make the same "random" choice of materials, unless you change the random seed for each model, but in that case you might as well simply draw a random number in your script, rather than in the substance itself.
Please see my explanations at the end of this thread : https://forum.allegorithmic.com/index.php/topic,2633.msg

Quote
I still don't understand why the built in Material Switch, and the Multi-Color/Grayscale Switch work fine but this Multi-Material Switch doesn't.

The issue only appears if the parameter which you want to assign the random number to is used multiple times in the node graph. The "single" material switch probably only needs to use it once.
Last Edit: August 28, 2017, 02:25:29 pm