New layer: "Duplicate"

Yoyobuae came up with the following suggestion on IRC last night:

[code]19:27 < Yoyobuae> i could benefit a lot from a “Duplication Layer” =)
19:27 so that one particle layer could be beneath it
19:27 and it gets automatically duplicated
19:28 since each particle is essentially the same, except
for random parameters

19:30 < dooglus> That’s a good idea, the duplication layer, with just
a single parameter saying how many dups to make.

19:30 < Yoyobuae> yup
19:30 and also a “Count” convert type

19:31 < dooglus> What would it do?

19:31 < genete> dooglus: I would like to discuss about a possible
duplicate layer…

19:31 < Yoyobuae> so you can have a parameter increase like, 1, 2, 3,
4, etc with each duplication

19:32 < dooglus> Ok, so it’s maybe called Index then.

19:32 < Yoyobuae> yeah that makes more sense =)

19:33 < genete> dooglus: if you make a duplicate layer I’ll send you a
ton of spanish wine! :slight_smile:
19:34 dooglus: A duplicate layer would simplify my life a lot
19:35 also consider that the preview number of duplicated
layers can be lower than the final render amount of
duplicated layers
19:35 for example you want to have 1000 layers at final
render and only want to see 10 during edition
19:35 so you need two parameters

19:36 < Yoyobuae> yeah, in 3D studio max (3d animation app), when you
apply a duplicate transform only 1% of the
duplicates show on the preview

19:55 < dooglus> This duplicate layer will rerender everything under
it over and over? Even contents of encapsulations?
And what if they’re nested? Can the Index convert
type select which dup layer’s index it uses?

19:56 < genete> the duplicate layer makes sense only if you add
something “random” to the sucesive copies of the
replicated layers/canvases
19:57 render them over and over themselves at the same
position seems to be a little silly, isn’t it?

19:57 < Yoyobuae> it would be nice to have the ability to have an
index as a parameter too
19:59 the thing is that the index could also be used in
manual duplication
19:59 to save some work

20:00 < genete> how do access to the index of the duplicated layer?
remember that in fact you only see one layer and the
duplicated are internally created, not accesible.

20:01 < Yoyobuae> the index could be a convert type, similar to random
20:02 except that it allows a value incremented progresively

20:03 < genete> ok. It is fine. What would represent the original
value of the converted type? the initial value?

20:04 < Yoyobuae> if A has an index param, then its duplicate has that
value plus an step
20:04 A has the original value, and its duplicates the
incremented ones

20:04 < genete> that step can be also a parameter? not neccesary to be
1.0. It could be any value… :slight_smile:

20:05 < Yoyobuae> yup =)

20:05 < genete> other parameter needed
20:05 :slight_smile:
20:05 -1.0 for example
20:05 or 0.001
20:05 or 3.141597
20:06 or 45 DEG
20:06 woah!
20:06 WE could make simmetrical flowers!
20:06 make on petal and place a duplicate layer over it! he he

20:07 < Yoyobuae> yeah, that’s what im going for

20:07 < genete> or repeated textures!
20:08 I think dooglus should think carefully on it before
create that layer. It seems to be the big step!
20:09 I suggest discuss it on the wiki. It is easier to
read.

20:09 < Yoyobuae> i also doubt dooglus can do much in his cellphone, =)
20:10 let just be patient =)
[/code]
I think it’s important to be able to nest these duplications (duplicate a petal 6 times to make the head of a flower; duplicate a flower 20 times to make a field of flowers - we’ll have 120 petals).

So we need to be able to independently address the two different “Index” parameters - which petal are we (0 through 5 - needed for the ‘rotate’ layer) and which flower are we (0 through 19 - needed to position and scale the individual flowers).

I’m thinking that having each “Duplicate” layer create a new exported variable would be one way to handle this. The exported variable would cycle in value from 0 to (dups-1) for each duplicated layer, which can be scaled as required using the various valuenode convert types.

I think that having a parameter in the Duplicate layer representing the index is enough. Then anything could be linked to that parameter as needed.

One interesting thing is that if you have an object above the Duplicate layer (not affected by it) which has a parameter linked to the index it won’t do nothing. That object doesn’t get duplicated at all, so index for it will be the same always.

One thing worries me a bit though, sometimes one might want to duplicate things manually. For example to customize the shape of each petal in your example. But Duplicate layers are meant to keep the duplicate objects hidden from the user (until rendering time that is), which it makes impossible to customize individual objects (but stopping your PC from grinding into a halt, a fair trade off :slight_smile: ).

In those cases, having index implemented as a valuenode convert type instead would make things easier. It would work similar to how Random works, but each time it is duplicated the index is incremented instead.

But this only works well with one level of nesting. With more levels, the upper level duplications will also affect the inner indexes, because duplication affect every index it duplicates. For example:

-Index A=0 (this is an object with a param Index convert type)
Duplicating 2 times:
-Index A=0
-Index A=1 (duplicated)
-Index A=2 (duplicated)
Adding another nesting level:
-Index B=0 (added)
–Index A=0
–Index A=1
–Index A=2
Duplicating once:
-Index B=0
–Index A=0
–Index A=1
–Index A=2
-Index B=1 (duplicated)
–Index A=1 (duplicated)
–Index A=2 (duplicated)
–Index A=3 (duplicated)
Note how the Index A increments at the same time Index B does. A workaround for this is to subtract Index A minus Index B. This would allow unlimited nested indexing levels, but the user then has to link the nested indexes correctly.

I like the idea of a Index convert type better. It works quite similar to how Random does. Random and Indexes parameters then would be independent of the Duplicate layer. The duplicate layer only takes care of duplicating.

Also, manual duplication and Duplicate layers could be used interchangeably. They work the same, except that Duplicate layers delay the process until rendering.

Hi!,
I think that it is more simple than you can think. Continuing with the flower example:
Online Canvas
-Duplicate layer (amount =5)
-Online Canvas (x=indexA 2, y=0)
–Duplicate layer (amount=8 )
–Petal (canvas)
—Rotate (angle=45
indexB) (0,45, 90, 135, 180, 125, 270, 315)
—Petal

The first duplicate would duplicate also the indexB, so we finally we would have following petals duplications:

indexA=0 (indexB=0,1,2,3,4,5,6,7)
indexA=1 (indexB=0,1,2,3,4,5,6,7)
indexA=2 (indexB=0,1,2,3,4,5,6,7)
indexA=3 (indexB=0,1,2,3,4,5,6,7)
indexA=4 (indexB=0,1,2,3,4,5,6,7)

Total 40 petals.

Regarding to Yoyobuae comments I think that it is better to have a convert type that can be used by the Duplicate layer as the index. For example:

Convert type: Index

Sub-params:

link Increment

Link can be Real, Integer, Angle, Time, (anything more?) and can be an animated value.
Increment is a value of the same type than link that can also be animated. It represents how much should you add to Link for each new duplicated layer

When Duplicate layer find that parameter then it would return this:

Link + index*Increment
where index is 0 for the original layer, 1 for the next, 2 for the next, and so on.
Until it reaches the Amount-1 value of the Duplicate Layer

What we can do is that nested convert types means to use a higher parent index.
For example:

Positionx (Index)
Link (index)

  • Link = 0.0 (Real)
  • Increment = 1.0 (Real)
    Increment =1.0 (Real)

Positiony (Index)
Link =0.0 (Real)
Increment =1.0 (Real)

Then if those parameters are over two Duplicate Layers then it would produce:

x=0.0 y=0.0; x=1.0 y=0.0; x=2.0 y=0.0…
x=0.0 y=1.0; x=1.0 y=1.0; x=2.0 y=1.0…
x=0.0 y=2.0; x=1.0 y=2.0; x=2.0 y=2.0…

-G

Glad to find you, DOOGLUS! So it seems you are THE ONE who best understands duplications, indexes & randomness in Synfig. :slight_smile:

Have you finally solved how to position the flowers in a random-like way? I have tried to pose the problem here: [url]How to get different fixed random values in a parameter for each replica of a Duplicate layer]. And I have searched “random” in the GitHub repository, but I understand almost nothing. Well, I understand you are not completely happy with randomness in Synfig.

Bye!