### Author Topic: FXmap function  (Read 8304 times)

#### lebulb

Hello,
is it possible to achieve this (gif), with a single quadrant?
(with function in the pattern offset)

#### Cyrille Damez

Yes. You'll need two functions :
• one in the iterate node to set the number of iterations and save it in a variable
• one in the pattern offset that computes how much to shift each pattern based on the number of iterations and on the float variable \$number that gives you the current iteration number.

#### lebulb

Great! it works.
Thank you.

I thought the \$number was the iteration number... it's clearer now

EDIT : Why \$number is not a integer variable, if is the current iteration number?
Last Edit: September 27, 2014, 03:08:20 am

#### lebulb

Hi!

I try to make a random integer on a iteration but it dont work.
I dont understand, because it work with a simple float number (Float > To Integer)

Also, is it normal that a FXmap node does not switch to 16 bit when the Imput Image 1 is in 16 bit?
Its only with the background?

#### lebulb

Nobody for my random Integer?

I try to make a complexe Generator Pattern and i need this functionality.
Maybe my method is wrong? I have tried many things.
How to convert a decimal number by an integer otherwise.
But it sounds like a bug. Can you confirm?

#### Wes McDermott

Nobody for my random Integer?

I try to make a complexe Generator Pattern and i need this functionality.
Maybe my method is wrong? I have tried many things.
How to convert a decimal number by an integer otherwise.
But it sounds like a bug. Can you confirm?

Hi,

I'm sorry, but I'm not sure. I will check with the devs and post back.

Cheers,

Wes

Head of Substance Demo Art Team

#### Vincent Gault

why don't you plug the integer to the random directly and set the random as output ?

#### lebulb

Because random node doesn't accept integer value.

Thx Wes!

#### Vincent Gault

and if you multiply your random by 100 before to convert to integer ?

#### lebulb

Thx Vincent
I tried, but I have an inconsistent result as with my other tests.

Logically, it should work with my first method,
I really think there is a problem

EDIT : To be more specific,
I use the node polygon_2 and I would have a random number of sides
Last Edit: December 12, 2014, 06:03:29 pm

#### Cyrille Damez

If you want to draw random integers ranging from 0 to an input integer i (i included) you need to do:

input int -> add 1 -> cast to float ->random->floor->cast to int

If i is a constant (e.g. 100) you can directly plug the constant float 101.0 in the random.
The "floor" may be optional. I don't remember if the cast from float to int rounds to the nearest integer, rounds to zero or truncates the decimals.

Quote
Also, is it normal that a FXmap node does not switch to 16 bit when the Imput Image 1 is in 16 bit?
Yes, the primary input is the background.
Last Edit: December 12, 2014, 06:50:56 pm

#### lebulb

Hi Cyrille, once again, thank you very much.
In fact, I made a small mistake in the explanation of my problem.
Indeed, it works on an iteration.

What I was trying to do, its a variable integer, in the sides of polygon2 node,
(which is a integer) and here, it does not work at all.

I had also used the floor node but it change nothing to the result.
I put the .sbs in attachment.
Last Edit: December 12, 2014, 09:23:02 pm

#### Cyrille Damez

It's working as intended.

The Random node outputs a pseudo-random (*) series of number in an iteration (or quadrant hierarchy), but always outputs the same series unless you change its random seed (so that you get the same predictable noises every time you render). If you use Random outside an iteration, it will always give you the same pseudo-random series comprised of only 1 number, which obviously does not look very random.

So in case you really want to create a substance that draws only one polygon with a different number of faces every time you draw it, you need to expose the number of faces as an input to the substance and draw a random number in the application that uses it.

(*) There is no such thing as random in a computer, unless you use custom hardware such as described here :
http://en.wikipedia.org/wiki/Hardware_random_number_generator

#### lebulb

Hi Cyrille, thank a lot again.
Sorry for the delay, i finished the year with a big charette +.+

you're right for the random Integer, my analysis was wrong.
I understand the concept, but by changing the Random Seed, i should have this kind of thing :

but i get that  :

Perhaps then, its the polygon_2 which does not work well.
(or me, which has still not understood something )

I use this function (random Integer [3-7]) in the Sides Instance Parameter (polygon_2):

Last Edit: January 03, 2015, 03:47:55 am