Thanks to dooglus recent convert types (Random, Time Loop and Reciprocal) and the modification he did with the Duplicate layer command now it is possible to create particles simulation in Synfig. To be able to use that convert types and improved features you should use svn r1240 or higher.
All you need is download the following file and use it as the original of you new animation or as an Imported canvas in an existing animation.
If you import the file you would like to change its parameters. To do that, just export the canvas (right click -> Export) and you can access to the ValueBase Nodes at Library Panel once you open the exported canvas using the Canvas Dialog. Also you can pick up the particle template layer and place it at your own animation canvas level. It will keep the linked parameters to the imported canvas. It would allow interact with the Z depth of the particles easily.
- 1 Structure of the particle template
- 2 Parameters of the particle template
- 3 Examples
Structure of the particle template
If you open the particle template file you'll find a inline canvas called "particles". Inside it there are 40 inline canvases called "particle template" and one "Inline Canvas". The last one is only used to hold the background and the green circle.
Each one of those "particle template" Inline canvases hold each particle. Inside of each "particle template" there is a Circle Layer that is the particle itself. The "particle template" only transform its origin properly and the Time Offset of the layer(s) that holds.
You can expand the Origin parameter of the "particle template" Inline canvas and see how complex it is. I'm not going to explain how it is done and hope you don't want me to do it. But if you're so curious you can ask at the Talk area of this page and I'll do all my best.
Same happen with the Time Offset parameter of the "partile template" Inline Canvas.
Parameters of the particle template
The particle itself
In the template, the particle is a circle. You can place there what ever you want. A bunch of layers, an exported canvas or an image sequence. There is only one restriction: They have to be inside one "particle template" Inline Canvas layer.
Number of particles
The number of particles is not a ValueBase Node. In fact the number of particles is the number of times you duplicate one single "particle template" Inline canvas. So you really only need one "particle template" layer to start your own particle set. Notice that the particle-template-v1.0.sifz file have 40 "particle template" layers. All they come from the duplication of a single one. Also each one can be used as a seed for new particles. You can use any of them for your own animation. So, you can pickup one of them and copy to your canvas from the imported particle template file, or use it directly just deleting the other 39 and starting a new particle set.
I strongly recommend that the experiments were done with a small amount of particles (50-100). Later at final render you can duplicate the particles as many times you need and make the render. Command line render is recommended.
NOTE: When a particle template is duplicated the random stuff of the particle is randomized so each particle is always different form its predecessor.
Parameters of animation
Each single particle position follows a parabolic shot trajectory with damping forces. The equations that governs those movements are here. Beyond the parameters that defines the movement equation there are some other that allow control other particular aspects of particles simulation.
lifetime parameter is the amount of time (seconds) that the particle is moved by the parabolic shot. Each particle repeats a loop where it is suffering a translation by the "particle template" inline canvas of a lifetime duration. Each particle has the same cycle length (lifetime) but different frequency, so you see each particle shot a different moments. In other words: lifetime is the amount of time that the particle is flying. This parameter can be changed but cannot be animated. If you animate it you'll find strange behaviours. You can animate but to work properly it should be constant for a period almost the double of its value.
Regarding to the lifetime parameter there is something important that must be said. In the sample file the circle inside the particle template layer has its own animation. Its color changes from black at time 0f to red at time 2s and to yellow at frame 4s. That's not casual. As well as the lifetime is set to 4s in the sample file I've set the particle own animation to start at 0f and end at 4s. That means that animation from 4s and beyond is never shown with a lifetime of 4s. Take that in consideration when create your own particle animation.
When I coded the equations inside Synfig using a complex convert combination I realized that I cannot use the animation time as the equation time. It means that the equations uses its own timing that is different from the timing of the animation. It allows to make free floating particles. If I depend on a Time Offset parameter of other external Inline Canvas to make the random shots for each particle then the free floating thing don't work properly. So, the time that is used by the equations is the animation time but scaled by timerate:
t = timerate*T
t = equation time. T = animation time timerate = equation time versus animation time rate.
Current value for timerate is 1.0. You can change it and animate it. It would produce fancy effects because the particles are played slower or faster. It is useful if you find a good combination of the equaiton parameters that gives you a beautiful particles shape but you need them to be animated at lower or higher speed without change the animation speed of your animation. Use it in combination with lifetime to obtain cool effects. lifetime should be changed reciprocally to the timerate to maintain same particles shape but at different speed.
particles off makes the particles stop shooting. For long lifetimes and short on/off periods it is not working properly. Nowadays I've not found a way to make it work properly. Its defect value is unchecked fo the particles are on from the beginning.
To use it you should place two waipoints one frame separated each other, every time you want to set the particle on or off. In this way:
on-------particles are on -------on|off -------particles are off ------off|on-------
X0, Y0, X0spread and Y0spread
Each particle have one shooting start position denoted (X0,Y0). That pair of ValueBase Nodes can be modified and animated by the user. The green circle's centre mentioned before is link to those pair of values so modifying the green circle's centre you modify the shooting position.
To allow particles be shot randomly from an area near X0,Y0 you can use Xspread and Yspread ValueBase Nodes. The shooting point for each layer for each new shot is calculated based on the current X0,Y0 values and the current Xspread and Yspread values. Xspread and Yspread act as the Radius sub-param of a random convert type.
V0, alpha, V0spread, alphaspread
Each particle have also a shooting start velocity. For convenience I've set the velocity as a radial composite: V0, alpha, where Vo is the modulus of the velocity and alpha is the angle with the horizontal. Usually there is no sense to give to V0 a negative value (change its angle) but you can do if you want.
To allow the particles have random initial velocities, both parameters can be random by its corresponding ValueBase Nodes: V0spread and alphaspread. Here applies same explanation than for X0 and Y0. Look the diagram to see what means alphaspread.
All the possible particles initial velocity must be inside that arc shown in the diagram that covers +/- alphaspread around alpha (15 DEG and 45 DEG respectively in that case).
You can change all those parameters as well as animate them.
b (the damping coefficient)
b is the reduced damping coefficient. It is the c/m where c is the damping coefficient and m the particle mass. As well as the equation is m reduced you should introduce only the b ValueBase Node. You can modify and animate that parameter, but take account that would produce strange (or cool) effects (like attractions or repulsions) if the changes are quicker than the lifetime.
b (c/m) is a parameter that represent a force proportional to the velocity and inverse to its direction. b is limited. You can set it to 0.0 but Synfig would set it as 0.000001. That means that practically it is 0 but it cannot be 0.0 in the current equations. If not, a division by ZERO would be produced. Also it is now limited by a value of 20.0. Maybe you want to allow it to bigger value. Ask me and I'll change it.
G and beta
G is the gravity force and beta its angle respect the horizontal. You can change and animate them freely. You can use the gravity force like some kind of wind force for some types of particles. Also it is needed for rain and snow simulation or simply for a fountain drop. You can set G to 0.0 and it would allow create other kind of particles.
In the sample diagram you can see that the particles are going down after a while. It is due to the sample values of G and beta are G=1.0 and beta=270 DEG.