Author Topic: Randomizing graphs using iterated FX maps without making them output garbage  (Read 2649 times)

I'm trying to make a pattern with randomly selected input parameters. The problem is that random values are being selected for every new iteration node value in every subgraph (I think?) resulting in problems like the attached image.

Simple things like selecting a random number of bricks, random bevel size etc. should be easy but I've been pulling my hair out for days trying to get this to function as expected. Is there any way at all to tell these pattern generators "Take this random value and just keep using the some one until you're done" without rewriting their internals?

You need to call random just once and assign the result to a variable  then read that variable in your iterated nodes. In order to do it just once, you can do it for example in a custom function attached to the number of iteration of the "Iterate Node". You can use the "sequence" node to chain several "Random"->"Set Variable" before you return the function result, like this (if you'll pardon the ASCII art...) :
Code: [Select]
[Random]-[Set A]\
                [Sequence]\
[Random]-[Set B]/         [Sequence]\
          [Random]-[Set C]/         [Sequence]
               [number of iteration]/       

Wow that's....insanely ugly. Is this use case really so uncommon as to need quite such a kludge? There's no way around manually doing that inside every FX-map?

I appreciate the solution though and will report back after trying it.

After checking back on my substance I realize that this solution unfortunately doesn't apply.

For example: I'm using the built in brick generator and want to randomize the number of bricks so that they can be 1x1, 2x2, 3x3, or 4x4. If I randomly choose an appropriate Integer2 to pass to the brick_generator graph, then the glitchy output happens. This is really surprising to me as I would think scoping would prevent new randoms from being provided by the parent graph.

If I instead generate the random values right inside the FX-Map's iterate node (inside the Tile graph), then the brick_generator graph has no knowledge of what value was chosen there and many of the other moving parts will fail.

Is there really no way to pass a randomly generated parameter to a graph and have that graph run to completion with the value you passed it?

Sorry, I did not understand your use case the first time. I thought you wanted to *modify* the brick_generator.
In theory, what you tried in the first place (creating a function that outputs a random int2 for the "Bricks" input of the Brick Generator) should work. It seems you have found a bug in the Substance cooker (our "compiler") : the damn thing seems to inline the graph inputs functions instead of assigning the results to local variables. I have added it in our bug tracker.




Awesome, thank you so much! I'm imminently starting a project that will use Substance Designer extremely heavily for procedural textures, so having this fixed will be a godsend.