Circle Packer Object
This object implements a circle-packing routine which will pack as many particles into a defined space without them overlapping. This enables images such as this to be produced (a simulated Ishihara test for colour-blindness):
The object uses an emitter which generates the particles, then resizes them to fit into the space available at the particle's position. If there is insufficient space the particle is deleted. Also see the notes on using this object below.
The object's interface contains the following sections:
The emitter to use. When you drop an emitter into this field, the following changes are automatically made to it:
- the particle speed and speed variation are set to zero
- subframe emission is turned off
- the maximum number of particles is set to the value in the 'Max. Particles' parameter
- the particle display type is set to filled circle, with 12 segments
You can change any of these if desired, but the packing effect is best seen with circles of some kind - filled, outline, or sphere. You can change between those from the 'Display Mode' drop-down menu. If you want to change the maximum number of particles, you can do so in the emitter or with the 'Max Particles' parameter.
Click this button to create an emitter and add it to the 'Emitter' field.
The particle display mode used in the editor. The menu offers the choices of circle, filled circle, or sphere. These are exactly the same as the options in the emitter's Display tab; this menu can be used instead, for convenience.
Get Max. Radius From
This determines where the maximum particle radius will be obtained from. The default is 'This Object' meaning that the maximum radius is controlled by the 'Max. Radius' setting; in this case, the initial radius given to the particle by the emitter is ignored.
The other option is 'Particle'. The maximum possible radius is then determined by the particle's initial radius setting. The circle packer may reduce that radius to make the particle fit, but it will never increase the radius. With this option you can (for example) set the initial radius from a texture and the circle packer will try to keep the radius as close to that value as possible.
If you set this menu to 'Particle' you have additional options which can be seen by clicking the small black arrow next to the text 'Get Max. Radius From'. These options allow you to alter the radius of the generated particle before the Circle Packer fits them into place.
The options are shown here:
The way this works is as follows:
- a value is obtained from the spline control depending on the particle's current radius (see 'Scale Range Min.' and 'Scale Range Max.' below)
- the value from the spline will always be between 0 and 1
- this is then used to multiply the 'Scale Multiplier' value which in turn is multiplied with the particle's radius
You can use these controls to alter the radius of particles depending on their existing radius. For example, suppose you are emitting particles from a texture where the brightest particles have a radius of 5 and the darkest a radius of 1. You'd really like the brightest (i.e. largest) to be much larger in proportion, so you would increase the multiplier to a suitable value, then adjust the spline so that only the largest particles were affected by the multiplier.
The spline which affects the value of the 'Scale Multiplier' depending on the existing particle radius.
Scale Range Max., Scale Range Min.
The existing particle radius values between which the spline will apply. The particle radius is first checked to see if it falls in the range bounded by the 'Scale Range Max.' and 'Scale Range Min.' settings. If it is less than 'Scale Range Min.' the value at the extreme left of the spline is taken. If the radius is greater than 'Scale Range Max.' the value at the extreme right of the spline is used. For values within the range, the value at the appropriate point along the spline is taken.
A value which is multiplied with the value from the spline and then multiplied with the particle's current radius to give a final radius value.
The maximum particle radius to set. Only available if 'Get Max. Radius From' is set to 'This Object'.
The minimum particle radius. The circle packer will try to fit the particle into the position at which it is generated and if necessary will reduce the radius until it fits. However, if the final radius is less than this value, the particle will not fit and will be deleted.
Normally a new particle will be touching at least one other existing particle. You can set a slight gap between them by altering this value - this can sometimes look nicer than the particles touching. It is recommended that this value is kept small (e.g. 0.25 screen units) for best results.
The seed for a random value generator used in the 'Color Variation' setting.
By default this is set to zero, so the particles will retain their original colour. Increasing this value will add some variation into the colour; the Ishihara image shown at the top of this page was generated by emitting from a bitmap with only two colours but with 15% colour variation.
The Circle Packer can scale particles up and down, and the change in radius is controlled by spline controls so allowing the changes to ease in and out. The available controls are as follows.
If checked, the circle packer will set the initial particle radius to zero then scale it up over time to the maximum possible value for that particle. The time taken to scale up to its maximum is determined by the 'Scale Time Up' setting.
Scale Time Up
The time taken for a particle radius to be scaled up to its maximum radius, if 'Scale Up' is checked. Note that a setting of zero will cause the particle to be scaled up to its maximum radius immediately.
By increasing this value above zero there will be some variation in the rate at which particles scale up. So if 'Scale Time Up' is set to 30 frames and 'Variation' to 10%, the actual scale time for each particle will be somewhere in the range 27 to 33 frames.
Scale Up Over Time
This spline controls how the particle radius scales up. The default spline will scale up the radius from zero to the maximum for the particle, over the time set by the 'Scale Time Up' and 'Variation' settings.
Note that if you flip the spline, the particles will start at the maximum radius and scale down to zero. However, they are not deleted when the radius is zero so if you do this you may end up with a lot of invisible particles. In addition, they are not removed from the internal list of circles maintained by the Circle Packer so new particles will not be generated to replace them.
Also note that if you set the spline to a straight line at the top of the control, the particles will not scale up at all, but will immediately take their maximum radius, which is identical to not checking the 'Scale Up' switch in the first place.
If checked, the circle packer will scale the particle radius down over time to zero. The time taken to scale down to zero is determined by the 'Scale Time Down' setting.
Delay Before Scale and Variation
This is the time which must pass between the particle reaching its maximum radius and starting to scale down. The default is zero, so the particle will start to scale down as soon as the maximum radius is reached. If 'Scale Up' is unchecked, the particles are created with their maximum radius, so will start to scale down as soon as they are created. The variation setting adds some individual variation in the delay for each particle.
Scale Time Down
The time taken for a particle radius to be scaled down to zero, if 'Scale Down' is checked. Note that a setting of zero will cause the particle to be scaled to zero radius immediately.
By increasing this value above zero there will be some variation in the rate at which particles scale down. So if 'Scale Time Down' is set to 30 frames and 'Variation' to 10%, the actual scale time for each particle will be somewhere in the range 27 to 33 frames.
Scale Down Over Time
This spline controls how the particle radius scales down. The default spline will scale down the radius to zero, over the time set by the 'Scale Time Down' and 'Variation' settings.
Note that if you set the spline to a straight line at the top of the control, the particles will not scale down at all, which is identical to not checking the 'Scale Down' switch in the first place.
Kill Particles With Zero Radius
When scaling down, you may end up with particles which have a radius of zero; they still exist, but you cannot see them. In addition, they are not removed from the internal list of 'occupied' circles maintained by the Circle Packer, so no new particles are generated to replace them. To avoid this, check this switch. Particles with zero radius are then deleted and new ones will be generated to replace them.
Notes on using this object
You can use any emitter mode but some work better than others. The rectangular, circle, and ellipse emitters pack the particles into the space defined by the emitter boundary. If you use a sphere or box emitter, the particles are packed into the volume defined by the emitter.
You can use the circle packer when emitting from an object, so you can use all the modes available there, but polygon centre and points modes are not very useful. Best results are obtained with polygon area or texture emission.
Number of particles
Be aware that the object will delete any particles which can't be fitted into the space at the point where they are generated. This has an effect on the number of generated particles, which becomes more and more apparent as the space becomes filled. For example, if you have a birth rate of 1000 and a frame rate of 25 frames per second, you would normally expect to see 1000 particles after 25 frames. But the circle packer may (almost certainly will) have to delete some of them, so you may end up with far fewer. For this reason, to pack a space in reasonable time may require that you increase the birth rate substantially.
You can use any modifier with these particles but of course anything which changes the particle scale or speed will destroy the pattern created.
Rendering the result
You can render the result by using the X-Particles material in the usual way, which will render the particles as spheres - which is ideal for this purpose. Or you can use geometry from a Generator or Sprite object. If you do that, the best results will be obtained if you use a sphere as the object to be generated (or you can generate a circle spline if desired). If you use anything non-circular some of the generated objects will overlap.