First of all thank you for all the help you’ve given me so far…
This question is made of 2 parts:
I’ve created a twinkling star animation. What I’d like to do is create a night sky by placing many copies of this object in random locations (I was hoping to use the duplicate layer).
The method I tried didn’t quite work (I converted the origin of the star object to random with animation speed set to 0). Is there a way to achieve this without manually copy/pasting the star object.
The animated object is encapsulated with a time loop. What I’d like to do is randomise a property of this time loop such that all the duplicate stars twinkle at different times.
Is this possible?
Thank you again
Yes it is possible
First of all you have to create your star animation at the origin (0,0): nothing, rising star, bright, nothing
Once created the animation you have to make it (only one layer) appear randomly and cycled in different places. To do this you have to encapsulate your stuff and do this:
Convert the Origin parameter of the Paste Canvas to composite (x,y). Then each composite element has to be converted to random from real value. This will provide the following parameters:
Link: don’t modify, this is the central value and should be 0.
Radius: Set this parameter to the half wide(height) of your blinking star field. If you’re thinking on pixels you have to divide the value in pixels by 60 before enter it. The parameters is in Units (one Unit = 60 pixels)
Seed: don’t need to modify.
Animation Speed: It is the number of times per second the new value is given. Keep this parameter in mind, it defines the animation speed. Say your star animation longs 0.5 seconds, then this value should be 1/0.5=2.0 (two times per second)
Interpolation: set this value to 0 and it will produce a jump between each star position.
Loop Time: it is at your option to change it or not. You can enter EOT (end of time) to make it not loop.
Set the same sub parameters for both x,y vector components. If you want a radial random animation don’t convert to composite first.
Supposedly you have now a blinking star randomly placed two times per second.
Now you want N stars blinking randomly but at different times each one. Now it enters the Duplicate Layer. The duplicate layer renders N times the layers below and provide an index value on each render. Where do you want to use the index value? You want to use it on the OffSet time of the Paste Canvas Layer. But first we have to do some calculations:
Say you want to have N starts visible each time. If the star life time is 0.5 seconds you have to create a new star each 0,5/N seconds. So 0,5/N is your index multiplier. So,
- Create a Duplicate layer over the Paste Canvas layer.
- Set its “To” sub parameter to be N-1. Set its “From” sub parameter to be 0
- Take the Paste Canvas Layer’s Offset parameter and convert it to Scale. Connect the “Link” Scale sub parameter to the already existing Index1 value node. Set the “Scale” sub parameter to be 0,5*N (in seconds)
If everything goes fine, you should have N randomly placed blinking stars.
I’ve not tested it but I hope it works. If you want to thank me the effort of this tutorial, please write it down at the wiki and share the benefit with all the community.
Thanks for your help. Unfortunately it didn’t work. What I found was all the stars appears in the same location. Not sure what I may have done wrong. I’ve attached the file I’m working on.
starscape.sifz (2.5 KB)
At the moment I don’t have Synfig installed in this computer (not mine) and tomorrow I’ll start a trip of 7 days. Maybe someone else can take a look to your file.
Review the Radius parameter of the random convert type. Maybe it is the reason.
I don’t think you’ve linked the value exported from the duplicate layer. This means that all 20 versions are using the same values. You need to have a value in the random formula that’s dependent on the index from the duplicate layer.
convert the seed value of the origin of the inline canvas below the duplicate layer to ‘Add’, then expand the it to show LHS & RHS & scalar. Then connect the Scalar to Index 1. LHS will be the base random number and the scalar will multiply it by the index from the duplicate layer. This will give us a random number (-> origin) for each star drawn by the duplicate layer. In fact, it will probably give us too big a number, so change the index in the duplicate layer to be from 0 to 1 in steps of 0.05.
starscape1.sifz (2.55 KB)
This might make for an interesting monthly challenge…
But what if I really want a set of stars randomly positioned at fixed locations instead of randomly changing where they are?
I thought I had a solution:
However, the random seed seems to be linearly related with the first (and only) result of the random generation process in each star replica! That completely destroys the appearance of randomness I was looking for.
Alternatively, being able to arbitrarily fix the position of each star replica could suffice, so I have been searching for a conditional expression among the Convert AST nodes… but no way! I mean: Synfig has convert nodes for (A+B)*C and other operations, but expressing something like “if index2==0 then 133 elif index2==1 then -307 elif … else 77” seems impossible to me in Synfig.
Is there a solution I haven’t find out?
Found! The conditional node is named SWITCH in Synfig.
OK, now I have a version where stars are placed using nested SWITCH nodes (find it attached, just in case you are curious). Five starts with just one spline object (representing a ray of light) and a couple of DUPLICATE layers (for rays in a star and for stars in the sky). Currently, they all shine once, simultaneously from 10f to 20f. I still have to make each star shine repeatedly and in an independent way from the others.
My impressions so far:
Layer duplication, connection of index properties, and CONVERT as a way to assign expressions to properties is a set of tools providing a very powerful mechanism for applying the DRY principle to working with Synfig.
The GUI for creating CONVERT expressions is very uncomfortable. I have created the nested SWITCH nodes outside Synfig Studio, using copy & paste & modify instead, with Xemacs. Not ideal either. The ability to write a formula instead, as in Excel, would be helpful. I think I could write a CONVERT expression language and a compiler for that language if someone offered to integrate it with the GUI. I have never collaborated in a software projet before, so I’m still not 100% sure of what I’m writing just now.
I still regret the random approach to star fixed placement didn’t work. Returning the random seed (or something linearly related with it) as the first element in the pseudo-random sequence makes no sense to me. I think it should be fixed in order to get more randomness appearance.
I don’t understand why the two first parameters in the SWITCH node are initially linked. Is there a reason?
PS: I have just corrected a typo. I wrote “de DRY principle”!
estrella04.sif (27.8 KB)