### Author Topic: FX map problem  (Read 6487 times)

#### Steve Peters

I'm trying to set up an fx map the will randomly switch between two input images. I know to do this requires creating an empty function in the pattern selection for the quadrant node. This function must return an int which designates the pattern. The pattern is slot 0 = empty, slot 1 = image 1, slot 2 should be image 2, but it jumps to the built in patterns. Am I missing something?

#### Gaetan Lassagne

Hi,

You're right, if you use the next values it will move forward in the patterns.
It's a tricky point because you have to use high values to switch between input images: 256, 257, 258, etc.

I've modified the documentation to make this information more visible.

An important point: it will work in Substance Designer, but not once you've exported the file (to sbsar), so it's limited to the editor.
If you need random in an external application, you can also use blend nodes before the image entry of the fxmap. Let me know if you need more feedback about this point.

EDIT: we've added a "Multi Switch" filter in the library which can be connected to the "image entry 1" input of a FxMap. You can expose the "Input Selection" parameter to dynamically change the input.
Last Edit: April 23, 2014, 10:21:42 am
gaetan.lassagne@allegorithmic.com

Hi. I'm doing something similar and this is how I got it to work:

In the Fx-Map set up 4 quadrants, each with a different input pattern (I'm randomly switching between 4 images)

then set up a switch between the last two quadrants on random(0,1) > 0.75
connect that up to a switch between the second quadrant and the previous switch on random(0,1) > 0.5
connect that up to yet another switch between the first quadrant and the previous switch on random(0,1) > 0.25 and set it as output.
Inherit random on everything.

I got this to work, but there's something I wanted on top of that and didn't work: I wanted to mix up random amounts of each image, so I put an iterate node on top of that..... but it does so in order: first it puts all the first quadrant images that will go in, then the 2nd, then the 3rd, then the 4th and last. They look ordered. Is there a way I could get them not in order?
Thanks. I'm just trying out this tool and it seems very powerful.

#### gelbuilding

Last Edit: May 02, 2014, 11:47:31 am

Hi, thanks
I had seen the videos, not the forum thread.
Unfortunately they do not address the bit where I'm stuck: overlapping images. I get the randomization right, but I get them sorted in groups.

Watching the videos again made me think though, and I could change my current switching-node approach like so:
connect each source quadrant into a new quadrant, scale so they occupy the same space as in the source, then randomly set alpha to transparent in all but one of them, then loop on that.
Since it will be evaluating the same quadrant always, there should be no sorting issues!
I'll try it tonight and update here with results.
Thanks!

Ok, I got it to work but it's not pretty!
(edit: not really, sorting error persists sometimes)

I did the quadrants trick. Offset/scale each quadrant at the source so they will end up taking all of the texture, put a function in color/luminosity that will set alpha to 1 or 0 depending on a random number (only 1 if it falls on that quadrant's "bucket": 0 to 0.25, 0.25 to 0.5, 0.5 to 0.75, 0.75 to 1).

First issue was the images have their alpha halved on the higher octave (parent quadrant). I cheated by setting their alpha to 2 instead of 1. It worked.

Then again I ran into another undocumented issue: behaviour of random.
First, it doesn't say anywhere if it generates [0,n] or [0,n).
Also, turns out the random number being generated in each color/luminosity function is different, thus I can't use it to choose one quadrant! This means my object count will be randomly off between 100% and 400%
With this setup, however, the sorting problem goes away only if I set a scale variable I've exposed to between .75 and 1, which makes no sense O_O

would posting the file do any good?
Last Edit: May 03, 2014, 06:38:29 am

#### gelbuilding

always better to post file for help

have you seen this? there is a good example.

http://support.allegorithmic.com/documentation/display/SD42/Fx-Map+%3A+using+vector+maps?src=search
Last Edit: May 03, 2014, 08:36:36 am

There's an FX-Map with 4 inputs, inside it has two blocks which are my two approaches. The iterator at the top is the output, I've framed and commented the blocks. The one with wrong object count shows properly unsorted objects at a certain scale (scale is an exported substance parameter), but not at others, and I can't tell why. The one with the correct count is always sorted (and should be random instead).
I'll appreciate any help.
Thanks!

#### gelbuilding

All the maps are missing.

#### gelbuilding

This was posted a while back though i cannot seem to find it on the forum.
Luckily i saved the file, lol.

I hope this will help.