Author Topic: FX-Map iterate on randomly chosen images  (Read 2760 times)


I'm trying to paste 4 input images randomly positioned and rotated in an FX-Map.
I got it working by two different methods, but both have the same issue: the images are sorted in groups. The first image gets pasted x times, then the second y times, etc etc; But they should not be sorted, they should be randomly chosen.
I tried setting "inherit random" to false, but that means the iterator doesn't randomly rotate and translate each image before pasting, so I couldn't even see if it helped sorting.

Any ideas on how to achieve random order of pasting?
Here are my current approaches:

1st: cascading switches
have 4 quadrants, one per input image (A,B,C,D). Connect C and D to left/right of a switch, which uses random(1)>0.5 to decide which side to show. Connect B and the previous switch to a new switch, with same deciding function. Connect A and the previous switch the a new switch, with the same deciding function, then connect that last switch with an iterator.

2st: opacity bins
have 4 quadrants, one per input image (A,B,C,D). Connect them to the inputs of a new empty quadrant, set scale to two and offset such that they are centered in the new quadrant. Set Color function in each source quadrant to rgb=(1,1,1) but set alpha according to a different function in each as so:
A: if random(1)>.75, Alpha=2, else 0
B: if .5> random(1) <=.75, Alpha =2, else 0
C: if .25>random(1)<=.5, Alpha =2, else 0
D: if random(1)<=.25, Alpha = 2, else 0
(this didn't work as expected, random is different in each quadrant and two or more images may be opaque at once, or none at all)
Finally connect the upper quadrant with an iterator.

no suggestions?

perhaps Substance designer is not the right tool for this kind of texture generation?
I reckon rolling my own generator would be much much more work...
Last Edit: May 08, 2014, 08:02:16 am

Hi wadster,

Here is an example showing how to obtain randomness between several inputs. As it's "true" random, you'll have the same probability for each pattern.
Hope it will fit your needs.

Last Edit: May 09, 2014, 11:13:24 am
Lead technical artist

Hi, thanks for the reply

Although that graph looks good at first sight, the black&white and scaling are hiding the issue.
Changing the images to alpha-blended bitmaps and increasing their scale shows that the rightmost pattern is always on top of the others, the leftmost is always below all others, etc.

I have tested many approaches, even tried doing everything on global parameters via SET nodes in a function right below the iterator, to no avail.

I think this is due to the order in which things are evaluated and image buffers are passed, which is hidden.

I have one more approach in mind, which should be more substance-friendly: blending
Do random shapes in separate fx-graphs and also compute an alpha channel, then blend them such that higher alpha is opaque. I gotta think about this one a bit still, but I believe it should work, since it doesn't depend on ordering or anything.
So far it seems that Substances are very powerful, but deviating from standard noise/operator layered textures lands you in a sea of non-information. I figured this would be the weak spot, so I'm trying this partly to decide if I should include it in my workflow.

Thanks for the help!

Ok so now that I worked I have some advice for anyone reading this:

Do not attempt to do all of your effect inside FX-Maps. Even if it *sounds* simpler, you're much better off working with bitmaps.

To get multiple objects repeated and randomly sorted I did this:
Instead of modifying my substance that already worked with a single image, I made a substance that composes two outputs of the previous substance based on their alpha. It was really simple!

So yeah, keep in mind that the sorting issue currently seems to be *unavoidable* (but only within a single FX-Map. Think outside the box!)