How to get different fixed random values in a parameter for each replica of a Duplicate layer

I’ve got a Duplicate layer that generates a number of replicas of the layers under it. There’s a parameter in one of these layers which I want to give a different fixed value in each replica. I want those different values to look “random”. How can I achieve it?

My first approach consisted in using the corresponding exported Index value as the seed of a RANDOM conversion node and never changing the first “random” number produced. However, it seems that that first number is the very seed (or something linearly related to it), so any randomness appearance is lost.

What can I do?

PS: I first included this question in a thread with a different main topic, [url]Howto use duplicate layer on object with random origin]. Now I think it deserves its own thread.

Can you elaborate a little bit more the question?
“fixed random” seems to be contradictory to me.

I’ll try.

Forget about animating a parameter. I don’t want a pseudorandom generator for giving different values to the same parameter of the same object instance over time. Convert > Random seems good for this thing I’m not interested in.

Instead, I want to put a number of instances of the same object in different pseudorandom positions. For instance, five stars in the sky. I could make the star an exported canvas and connect it to five different group layers with different manually chosen transformations. But, instead, I prefer to use a duplicate layer to get five instances out of the star. Can I?

Well, of course I can get five instances with a duplicate layer, the key question is: How can I give a different position to each replica? Using Convert and the index parameter associated to the duplicate layer, I suppose, but I want to give a randomness appearance to the final result. So simple linear formulas do not suffice.

One long way: nested Convert > Switch nodes to choose different position values for different index values. Positions must be chosen manually. And nesting management is very uncomfortable. It works, but it’s not a general acceptable solution.

What I’m searching for: a short way to make position values be chosen from a random generator (or more). I was trying to use Convert > Random. I was trying to convince it not to change over time and to give me a different pseudorandom value for each index value. I can’t see how to change the “random sequence over time” behaviour of Convert > Random into a “random sequence over index values” one. But I expected that using a different random generator (and taking just one value from it) for each replica (i. e. “for each value of the index”) would suffice. It wouldn’t. I mean, I have tried to use the index value as the seed for each random generator, but the first value returned by each generator seems to be the seed itself (or something linearly related to it). I would need the next pseudorandom value, not the seed itself.

I understand that: you want to put N duplicates of a shape in N positions. But You don’t want that those positions will change randomly in time as the duplicate layer do by defect.

If I’m correct, the best way is set the “velocity” value of the random type to zero (0). In that way, the position, won’t change randomly in time.

Now, I’m trying to guess. You have now N duplicates in N(x,y) positions, BUT YOU DON’T KNOW those positions. So, if you want to animate one, or several, or all of those duplicates with, for example, a movement for each one, you won’t be capable of doing it.
In that case, I don’t see a simple way to do it.

:bulb: I mean, If you know python, and how the XML format works with a sif file, You can make an script that, given an object, you can copy and change the position of that object. However, synfig is limited (In my opinion) about the scripts in python.

:bulb: A way to know the values of a parameter is converting the value of that parameter in string type, then copy that string type and pass it to… and then… and, after many changes of variables… and later… and then… it’s too much :confused: , :cry: .

IIRC I did this video exactly with that technique explained by hulf (setting the animation velocity to zero)

Hulf2012, Genete, thank you very much for your responses!

That’s exactly what I want. However, “change in time” is not a default behaviour of DUPLICATE, but of CONVERT RANDOM (as far as I understand).

My main problem doesn’t consist in avoiding changes, but in getting a first random value for each position… looking really random.

Please take a look at the attached file. Ubicar manages the star replica positions. It only tries to choose X-value randomly. CONVERT RANDOM Speed was set to zero. CONVERT RANDOM Seed was connected to the replica index value. But I don’t get random X-values.

This is the experiment I made and what made me begin asking about this issue.

I don’t think animation will be a problem–at least, homogeneously animating all the replicas. Anyway, it’s not my main problem now.

May I see the SIF source file?

Thanks again.
xxx.sifz (2.33 KB)

Yeah, that’s a problem from the random seed and its time dependence. It is a bug that initial “random” position isn’t so random.

I haven’t the file. It is an old animation. I’m sorry.

Bug reported:

Here is the solution:
Fixed-random.sifz (1.35 KB)
The file uses a reverse Offset time to the whole duplicated (and randomly animated) stuff what freezes the objects in a place where it looks more “random”. Changing the inner subparameter Offset time of the outer Group’s OffSet parameter would give you different random shapes.

The trick: convert OffSet time to Linear and set the rate to -1s.

With the new version after current 1.01 it would be automatic with the new Group parameter called Time Speed.

Hello fprat, genete,

With your sample file I can see better what you mean. You get “constellations” instead of random stars.
In my version the random conversion is applied to the vector (x,y). And the seed is also converted to “escale” (multiplication),

The “scalar” variable is linked to he index of “ubicar”.

Now, some values of the “link” variable gives you better results than others. But I get more “constelations” than “random” stars, and it seems more close to each other, even changing the “radio” parameter of the random conversion.

I’ve seen the Genete example. I think it’s another way to do it.

Many questions grows from these. Like, how a random value is calculated?
I think that get a real random value it’s not easy, whatever program language you use:

… And I wish synfig had a comment layer, or an explanation layer, when you can put “this layer control the parameter of this other”.

xxx_v2.sifz (2.29 KB)

Interesting to see that scaling the random by the index seed instead of summing the index produce more random shape with zero velocity.

I don’t fully understand all interactions between time manipulations in nested group layers, but I see what you have done: beginning with t>0 and freezing time by artificially compensating its natural advance (exactly 1 unit decrease for each 1 unit advance).

OTOH, I’m not sure whether your approach will prevent animating the randomly placed replicas or not. Now we are PLACING replicas and not trying to RANDOMLY ANIMATE them, but I’d like to keep the door open for possible non-random animations.

Finally, I see in your example that Random can generate vectors, not only scalar values.



I see how you manipulate the index to get the seed. And that this seed is converted by Random in a 2D tuple. It’s a clever use of the available tools!

However, it would be better if Synfig provided us with a better Random tool. I mean that seed-to-returned-value transformation is the place where randomness appearance should be provided, instead of making the user manipulate the seed for that purpose.

Unfortunately, good pseudo-random number generation it’s not easy, as you has pointed out, and incorporating it to Synfig would probably be hard.

Regarding comment layers… don’t you see comments more as layer attributes than as layers themselves?

Hulf2012 is not exactly scaling the random value, but scaling the index to get a “scaled seed” (seed, not random value).

On the other hand, Hulf2012’s file has two main differences wrt mine: the seed calculation and the 1D-to-2D involved in generating a vectorial value. I’m not sure about the relative influence of each of those two features in the final appearance of randomness.