home about gallery publications education links forum contact


..::flocking birds::..

This type of effect is perfect for Particle Flow; 3ds max 6’s new particle system. Not only can we control the motion and placement of the birds a lot precisely, but we can also introduce operators to make the particles move away from each other to avoid colliding, use negative values in the same type of operator to control attraction and stronger repulsion to avoid the predator particle.

Flocking birds appear very graceful and fluidic, creating complex patterns and shapes in the sky. The main reason for this is because they are avoiding a predatory bird which is flying through the formation trying to make one of them its lunch. To control the same type of effect using particles we have to understand what is going through the bird’s mind. There are two main things – keep X distance away from your neighbour, and, if a predator comes close, get the hell out of the way. Simply adhering to these two rules can create the fluidic motion we desire. If one bird suddenly moves out of the way of the predator, all its neighbours are going to move as well, and their neighbours and so on, with the strength of the neighbour’s influential motion diminishing as it “travels” through the flock. Once the danger has passed, the birds naturally flock back together, maintaining the first rule.

In our particle system, we should design two main particle systems – one for the flock and the other for the predator(s). As we’re just concentrating on the technical and not the aesthetic aspects of this effect, I’ll leave the design and texturing of the birds to you! These two particle systems interact with each other using Keep Apart operators which are set up with positive and negative values. As a positive value repels particles, negative values cause them to be attracted to one another. Therefore, to control the flock, and to keep its formation, we will have to use two of these operators. The first has a large influential field so that no matter how far away the birds get from the main flock, they always find their way back. The second is a positive value around that prevents the birds from colliding with one another once they have moved back into the flock, with a small influential field to keep them away from one another and to prevent collisions. Finally, there is another Keep Apart operator that controls the avoidance of the predator particle – the influence field can be designed and tweaked, depending on how soon you want the birds to react and how great the neighbouring bird influence falloff should be. By simply amending the settings in the operator slightly, it can create some dramatic effects.

The predator system is pretty much a cut down version of the original. Depending on the number of predators in the scene, you may wish to include another Keep Apart operator so that the predators do not collide with one another, although this would be a very rare occurrence. More than one predator creates a more dramatic effect, but this can disperse the flock more than is desired, so the entire effect may be lost. My suggestion is to use no more than two predators – both can have different behaviours, so you may wish to use more than one predatory particle system to drive each species of predator, as one may be more agile than the other, be slightly larger or can fly faster. Dropping in these random elements can make the effect more believable. This / these system(s) are attracted to the flock using another(!) Keep Apart operator which pulls them into the flock. As the acceleration setting isn’t all that high, the predator will pass right through the flock and out the other side, before turning around and passing back through the flock. If there’s more than one predator then they should be randomly distributed around the scene so that they don’t all converge on the flock at the same time, as this won’t look very effective.

Due to the amount of particles and the influence we need in the Keep Apart operators to create the desired effect, the resulting motion can get a bit chaotic. Therefore, to get the birds to settle down again after their displacement, a Drag Space Warp is introduced to the system to calm the motion down a little. Finally, it should be noted that the amount of particles in the scene should be relatively high to drive the flock and to make it look effective.

Enlarge Screenshot
Open up the Flocking Birds Start.max file, and create a Particle Flow system in the Top Viewport. Set the Logo Size to about 2000, the Icon Type to Sphere and the Diameter to 5000. Set the Quantity Multipliers to 100% and label the system “Flock”. Create another system the same way, with a Diameter of 10000 and label it Predator. Set both system’s Integration Steps to Frame for Viewport and Render.
Enlarge Screenshot
Add a Drag Space Warp and set the Time Off to 1000 and X Y and Z Linear Damping to 5%. Press 6 to open Particle Flow. In the Birth Operator, set the Emit Start and Emit End to -50 and Amount to 300. Remove the Speed operator and add a Shape Instance Operator to the event to replace the existing Shape operator and use the Bird Mesh object as the particle type. Set the particle’s scale to 200% with 25% variation.
Enlarge Screenshot
In the existing Rotation operator, set the Orientation Matrix to Speed Space Follow with Y orientation set to -90 to get the birds facing the right way when traveling. Add a Material Static operator and drag the Black Boid material from the Materials Editor to the slot in this operator.
Enlarge Screenshot
In the Predator system, set the Birth’s Emit Start and End to 0 with Amount set to 1 or 2. Set the Position Icon’s Location to Surface and the Rotation operator as in the other one. Replace the Shape operator as before with the Instanced bird, but set its scale to 400%. Instance copy the material from the other event to this event and remove the Speed operator.
Enlarge Screenshot
Add a Keep Apart operator to the Flock system and label it Maintain Flock. Set the Force to -1000 and the Accel Limit to 10000. Enable Relative to Particle Size and set the Core to 1000 and Falloff to 5000. Add another Keep Apart operator and label it Keep Distance. Set the Force to 1000 and Accel Limit to 20000. Enable Relative to Particle Size and set the Core and Falloff to 300%.
Enlarge Screenshot
Add another Keep Apart operator and label it Avoid Predator. Set the Force to 1000 and the Accel Limit to 100000. Set the Relative to Particle Size and Falloff to 1000 and enable Selected Particle Systems with the Predator system selected. Add a Force operator and add the Drag Space Warp. Add a Keep Apart to the Predator system and label it Hunt Prey. Set the Force to -10, Accel Limit to 2000, Absolute Size Core Radius to 2000 and Falloff Zone to 5000. Enable Selected Particle Systems and use the Flock system.
Enlarge Screenshot
The fluidic motion of the flocking birds can be easily simulated using 3ds max 6’s Particle Flow using a relatively basic particle system setup.
Download the max file!
Zip file to accompany.

..::tips::..

However, the Keep Apart operator can cause problems with excessive interaction – your particles may suddenly disappear (they actually fly off to the far reaches of the scene). This can be seen with high numbers of particles in the scene. If this occurs, try reducing the amount of particles and render off the flock in two passes, using a different seed for distribution each time.

Try creating animated birds in the flock. Currently the instanced particle geometry is static – create copies of the bird mesh and deform them to create morph targets in the original bird object. Use Out of Range to repeat the animation automatically and let the shape operator know that the source geometry is animated. Also, create gaps in the animation to give the impression that the birds are soaring!

Add extra elements to the scene for the birds to interact with, for example a telegraph pole and line, tree or building for them to converge on. Also, try setting the system so that they are orientated around the correct way – due to the way the current system is set up, some birds may be flying upside down which may look a little odd from a close distance!

The same kind of particle system can create a nice school of fish or even a space battle / dogfight scene! – simply increase the number of predators and remove the flocking system for alike systems and set it to non-alike systems, so that they fly in towards each other, then break off at the last minute. Try creating a scripted test to check the distance between these particles and to fire off particle spawning to create bullet fire and rockets for instant carnage!

Initially published: 3D World magazine, Issue 47, January 2004.

Copyright © Pete Draper, January 2004. Reproduction without permission prohibited.

www.xenomorphic.co.uk