Flow Field Object

A flow field (sometimes termed a velocity field) uses an array of vectors to control the movement of particles within it. It is especially useful for such things as chaotic movement, fluid movement, movement controlled by procedural formulas, noise-controlled movement and so on.

A flow field is an area of 3D space divided up into a grid of smaller cubes or cells. Each cell contains a parameter which is a velocity vector - that is, a direction and speed of movement. When a particle enters a cell, its direction is transformed to match that of the vector in the cell. As it moves through the field it will enter other cells containing velocity vectors that change its movement again. This will continue until the particle leaves the field.

You can see from this that the crucial factor in a velocity field is the arrangement of the vectors. These could be completely random or they could force the particle to follow a path such as a sine wave. The Flow Field object offers a number of ways to set these vectors.

The Flow Field object looks like this in the viewport:

The yellow box is the volume enclosed by the field and the short lines inside it are the vectors (the vector display can be turned off if desired).

Interface

The object's interface includes these sections:

For the buttons at the bottom of the interface and the 'Groups Affected', 'Mapping' and 'Falloff' tabs, please see the 'Common interface elements' page.

Parameters

General quicktab

Enabled

Uncheck this switch to disable the object.

Cell Size

The size in scene units of the individual cells. Each cell is a cube and this will not change, whatever the size or resolution: the cell is the same dimensions on each side.

Size

The size of the Flow Field box in screen units. You can also change the size by dragging one of the resizing handles of the object in the viewport.

Note that as you increase or decrease the size the number of cells along that axis will change.

Flow

This drop-down menu specifies how the flow vectors are generated. It has nine options:

Default

The default arrangement of the flow vectors when the object is first created is for all vectors to point along the positive Z-axis of the object.

None

There are no flow vectors, so the flow field has no effect. This can be used as a convenient way to disable the flow field effect temporarily, without completely disabling the object in the Object Manger.

Random

The flow vectors point in randomly-generated directions.

Shader

This mode uses a shader to arrange the particles. See 'Shader mode settings' below.

Target Object modes

The following modes all require a target object. When one of these modes is selected, options appear which are described below.

Target

In this mode the vectors point towards the axis of the target object which you specify. Any object can be used.

Along Spline

This option requires a spline object. Here the flow vectors will point in a direction which is at a tangent to the nearest point in the spline.

To Spline

This option also requires a spline object but differs from 'Along Spline' in that the vectors point towards the nearest point in the spline.

Surface Tangent

This option requires a polygon object. The vectors point along a tangent to the surface normal.

Surface Normal

This option requires a polygon object. The vectors point in the same direction as the normal of the nearest polygon.

Note: if you use the 'Surface Tangent' or 'Surface Normal' modes and you use a target object with a lot of polygons, each time you change something such as the grid size the vectors have to be recalculated. In these two modes, this will take some time - it may look as if Cinema has frozen but if you wait a few seconds, it will finish updating the vectors. Once the recalculation has been done, the vectors won't need to be updated again unless you change the grid or the target object.

Particles

In this mode he flow field will track the movement of a stream of particles through it, and for each cell, the vector will be altered to point towards the nearest particle.

Field

This setting determines what the flow field does to the particle. It has three options:

Direction

The flow field will alter the particle direction but not its speed. The rate of changing direction will depend on the 'Strength' parameter.

Velocity

The flow field will alter the particle direction and its speed, up to a maximum speed which is set in the 'Speed' parameter. The rate of changing direction and speed will depend on the 'Strength' parameter.

Acceleration

The flow field will alter the particle speed, and the speed will continue to increase while the particle remains in the flow field box. The rate of speed increase is set in the 'Acceleration' parameter and the direction will only change if the 'Acceleration' parameter is greater than zero. The rate of changing direction and speed will also depend on the 'Strength' parameter.

Strength

When a particle enters a cell, its direction will change to that of the vector in the cell. But this will result in an abrupt change of direction which may be undesirable. This parameter controls how quickly the direction changes; low values cause a slow change and a smoother curve but with low values the particle may leave the cell and enter another before the change in direction is completed.

The value in this parameter will depend on a number of things including particle speed, cell size, and how desirable it is that the particle fully completes its change of direction before leaving the cell.

Speed

Only available if 'Field' is set to 'Velocity'. It is the maximum speed the particle will reach. If this value is lower than the particle's current speed, it will slow down to that speed.

Acceleration

Only available if 'Field' is set to 'Acceleration'. It is the rate of speed change while the particle remains within the flow field box.

Negative values are possible and has the effect that the particle speed will slow to zero then accelerate again but with a reversed direction.

Shader mode settings

If 'Flow' is set to 'Shader' then these additional options appear:

Shader

Use this link to specify a shader to use here. By far the most useful are shaders that can be animated, such as Noise, but you can use any shader.

When using the shader mode, it is important to understand how the shader affects the particle flow. For the shader to alter the flow of a stream of particles in a natural-looking way, it cannot just move the particles randomly in any direction; that would achieve very little. So the Flow Field object assumes that the normal direction of flow is along the positive Z-axis of the object, and the shader will then alter the movement of the particle while maintaining that general direction.

What this means is that for best results you should ensure that when the particle stream enters the object it is flowing, or mainly flowing, along the object's positive Z-axis. If it is not then the stream will tend to change so that it does flow along the positive Z-axis of the object. But what if you want the particles to move along (for example) the 3D world Y axis? Simply rotate the Flow Field object so that its Z-axis is aligned with the world Y-axis and move/rotate the emitter so that the particle stream is generally flowing along the object's Z-axis.

The following screenshots will show the effect of rotating the object and emitter:

1. Emitter and object aligned with their Z-axes along the 3D world positive Z-axis

2. Emitter Z-axis aligned along 3D world positive Z-axis but object rotated so that its Z-axis aligns to the world Y-axis

3. Both emitter and object rotated to align their Z-axes along the world Y-axis

The parameters of the shader can have very significant effects on the result. For a Noise shader, for example, changing the noise type, octaves, space, scale, animation speed, cycles, high and low clipping, brightness and contrast will all markedly affect the flow!

Animate Flow

If you are using an animated shader, such as animated noise or have keyframed a parameter of a shader, and you want the flow vectors to change as the shader changes (which really is the point of using an animated shader) check this switch. If it is unchecked the flow vectors will not change even if the shader does. The switch has no effect if the shader is not animated, but it will cause the flow vectors to be re-calculated each frame, which may slow the simulation considerably. For this reason the switch is unchecked by default.

Resample Shader

Unless 'Animate Flow' is checked, the vectors are only recalculated when the animation is rewound to the first frame. In this case, if you make some changes to the shader, this won't alter the flow vectors until you rewind the scene. If it is already at the start, you would need to advance at least one frame, then rewind, to update the vectors.

This is inconvenient, so instead you can click this button at any time to force the Flow Field object to update the vectors from the shader.

Settings when using a target object

If 'Flow' is set to one of the modes requiring a target object, these options are shown:

Drag the object to be used as the target into this field. As soon as you do, you will see the vectors change to point to the object, and if you move it around the vectors re-orientate to point to it. The object can be anything, a null object is fine, and once you have arranged the vectors to your liking you can delete the object. Or you can leave it in place and animate its position and the vectors will constantly re-orientate themselves.

Resize When Adding Target

If this option is checked, which it is by default, when you drag an object into the 'Target Object' field, the flow field box will automatically resize itself to accommodate the object.

For obvious reasons, if the object has a size of zero (for example a Null object or a Light object) the size remains unchanged.

Note that since many splines are two-dimensional, if this option is checked and the target object is a spline, you may see one of the box dimensions set to zero and possibly no flow vectors. In that case you will need to resize the box along the relevant axis manually.

Border

If 'Resize When Adding Target' is checked, the box will be resized to the exact dimensions of the target object. This means that you may not see any flow vectors around the outside of the object since there may be no free space to hold them. This setting will apply a border of free space around the object. Once you have set a value here, it will be added to the dimensions of any object dragged into the 'Target Object' field or if you click the 'Resize Flow Field' button, but not if you resize the box manually.

Resize Flow Field

Once an object has been dragged into the 'Target Object' field, what happens if you resize that object? Unfortunately Cinema does not inform the Flow Field object that a linked object has been resized, so it has no way of knowing that the linked object's size has changed. Therefore, if you do alter the size of the linked object, and you want to update the size of the flow field, click this button.

Cell Strength

Target mode offers several ways to alter the strength of the effect applied by each vector. The main 'Strength' setting will affect all cells in the object in the same way, but you can vary the individual cell strength with this drop-down menu. The options are:

Constant

The cell strength is at maximum in all cases, regardless of distance from the target object.

By Distance

With this option, the maximum distance of any cell from the target object is calculated and then each cell is assigned an individual strength value depending on how far the cell (note, not the particle) is from the target. The closest cells to the target then have the greatest strength while those which are farthest away have the weakest.

The value obtained for each cell is then adjusted by multiplying by the 'Strength Falloff' and then again by the 'Strength' setting to give the final result.

Strength Falloff

With this drop-down the strength of each vector can be altered depending on how far the particle (not the cell in this case) is from the target. Note that the falloff does not affect the vector direction - they still point towards the target - but to what degree the particles are moved by the vector along that direction. There are four options:

None

The strength of effect is not altered by the particle distance from the target.

Boundary

In this case the effect strength is zero if the particle is outside the boundary (as determined by the 'Falloff Boundary' setting) and at maximum if it is inside the boundary. Note that a strength of zero will mean that the particle direction will not be affected by the vector at all.

Linear

The strength of effect varies linearly with the distance of the particle to the object, being zero outside the boundary and at maximum when the particle is at the target position.

Inverse Square

This is the same as 'Linear' except that the strength decreases by the square of the distance. This causes a very rapid falloff and leads to little or no effect until the particle is very close to the target.

Falloff Boundary

This is the boundary of the effect if 'Strength Falloff' is set to anything other than 'None'. It is show as a yellow sphere in the viewport.

Settings when using one of the spline or polygon object modes

If 'Flow' is set to one of the four modes which use a spline or a polygon object, these options become available:

In 'Surface Tangent' and 'Surface Normal' modes you also have these options:

Objects

Drag the splines of polygon objects (depending on the selected 'Flow' option) into this list. You can use multiple objects.

Falloff

If checked, the falloff 'Distance' and 'Spline' settings become available. If it unchecked the falloff spline has no effect.

Note that this is a separate falloff to the main Falloff tab in the object. The Falloff tab is a conventional Cinema 4D falloff which works in the same way as in any other object.

Distance

Grid cells which are further away than this distance from the object(s) have a strength value derived from the right-hand end of the spline. In the screenshot above, this would give them a strength of zero. The closer the cell is to the object, the more the strength value is shifted to the left of the spline, so again, in the above screenshot, the maximum strength would be in cells which were at zero distance from the object.

Spline

The spline used to derive the cell strength depending on how far a cell is from the object.

Direction

Only available in 'Surface Tangent' and 'Surface Normal' modes. This is a drop-down menu which controls direction of the vectors.

The menu has these options:

Polygon

The vectors are derived from the surface normal of the polygon nearest the cell. They will be tangential to the normal in 'Surface Tangent' mode but point towards the polygon in 'Surface Normal' mode.

Local X, Local Y, and Local Z

The vectors are derived from the surface normal and a vector pointing along the respective axis of the Flow Field object. This has the effect of pointing the vector along that axis while remaining tangential to the surface ('Surface Tangent' mode) or towards it ('Surface Normal' mode). In these modes, rotating the Flow Field object will not affect the direction of the vectors.

World X, World Y, and World Z

As for 'Local X, Local Y and Local Z' but rotating the Flow Field object itself will affect the tangent direction.

Object

In this mode, you can add a separate object to the 'Object' field and the tangents are then derived from the surface normal and the position of this object. This mode behaves like 'Local X, Local Y and Local Z' but the vectors are aligned to point to the object.

Origin

Each vector is derived from the surface normal and the position of the cell the vector is in.

The object to use when 'Direction' is set to 'Object'.

Settings when using Particles mode

With this mode the same settings as for one of the four spline or polygon object modes are used, but with these two additional options:

In this case, you should add one or more emitters to the 'Objects' list, rather than polygon or spline objects.

The flow field will then track the movement of a stream of particles through it, and for each cell, the vector will be altered to point towards the nearest particle.

Type

This drop-down menu controls how the flow field vectors are influenced by the particles. It has two options:

Direction

The flow field will depend on the particle direction but its strength is not affected by particle speed.

Velocity

The flow field will depend on the particle direction and its strength is affected by particle speed.

Smoothing

This setting is used to smooth out abrupt changes in vector direction as the particle move in the flow field.

Vector Display quicktab

These settings affect how the vectors are shown in the viewport. They are not shown at render time and have no effect on the functionality of the object.

Show Vectors

If this switch is unchecked the vectors will not be shown in the viewport.

Two-Colour Vectors

By default the vectors are drawn in one colour (from the 'Color 1' setting). If this switch is checked they are drawn in two colours. This is useful because the colour from 'Color 1' is used to show the direction of the vector, that is, the direction is from the 'Color 2' end to the 'Color 1' end.

Show Vector Strength

If this is checked, the strength of the vector is shown by the length of the line. The shorter the line, the less is the strength. This is only applicable if 'Flow Vectors' is set to 'Target' since only that mode allows the strength of each cell to be set individually.

Max. Length

The maximum length of the vector line. The parameter is a percentage of the size of the cell as given in the 'Cell Size' setting.

Transparency

Use this control to alter the opacity of the vectors. This is useful if the vectors are obscuring other details.

Color 1, Color 2

The colours that the vector is drawn in.

Actions quicktab

When a particle leaves a Flow Field box, the object will trigger any actions in the 'Actions on Escape' list. You can use this to kill particles which leave the box, for example.

Actions on Escape

Drag any actions to be triggered on leaving the box into this list.

Add Action

Click this button to create a new action and add it to the list.

Import/Export quicktab

These controls allow you to export a flow field as an .fga (Fluid Grid ASCII) file. This can then be imported into the Unreal Engine game development system. You can also import .fga files created elsewhere into the Flow Field object in X-Particles.

You should be aware that the Cartesian coordinates in the Unreal Engine particle system have the Z-axis pointing 'up', unlike Cinema 4D where the Y-axis is the 'up' axis. This will cause particles that in X-Particles moved vertically to move horizontally in Unreal. It is important to remember this when designing your flow field.

Exporting a Flow Field

Export File Name

This is the file to which the flow field will be exported. Select a file in the usual way; if the file doesn't exist, it will be created. When you select an existing file you will be asked to confirm that you want to overwrite it.

The file will not actually be exported until you click the 'Save Flow Field' button.

The file name will stay in this field so that you can make changes to the flow field and re-export it as many times as you like.

Strength Multiplier

This setting will multiply the magnitude of the vectors which gives particles their initial speed when the flow field is used in Unreal. By default it is set to 1, which leaves the vectors unchanged.

Save Flow Field

Click this button to save the flow field to the specified file.

Importing a Flow Field

Load Flow Field...

Click this button to load a flow field from a per-existing file. These normally have the extension .fga. When you do this, the following changes are made:

  • the cell size and solver (box) size are altered to the dimensions given in the .fga file
  • the vectors are created with the directions given in the file but are normalised - the vector magnitude (if any) is not used
  • most of the controls in the 'General' quicktab become unavailable, since changing them would alter the vectors, making it pointless to import the vectors in the first place
  • the 'Loaded .FGA File' field gives the name of the file you loaded, so you can see which file you are using and to preserve the file name when the Cinema 4D file is saved

Loaded .FGA File

The name of the file that was loaded, or '<File Not Loaded>' if you haven't loaded anything yet.

Load Data on Scene Load

If checked, then if the scene file is closed, when it is reopened the data from the .fga file will be loaded automatically.

Clear Imported Data

Click this button to clear the imported data and reset the Flow Field object to its default values.