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.
By default the Flow Field object looks like this in the viewport:
The yellow box is the volume enclosed by the field and the arrows inside it are the vectors (the vector display can be turned off if desired).
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.
- Shader mode settings
- Target mode settings
- Spline/polygon object mode settings
- Particles mode settings
Uncheck this switch to disable the object.
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.
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.
This drop-down menu specifies how the flow vectors are generated. It has nine options:
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.
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.
The flow vectors point in randomly-generated directions.
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.
In this mode the vectors point towards the axis of the target object which you specify. Any object can be used.
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.
This option also requires a spline object but differs from 'Along Spline' in that the vectors point towards the nearest point in the spline.
This option requires a polygon object. The vectors point along a tangent to the 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.
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.
This setting determines what the flow field does to the particle. It has three options:
The flow field will alter the particle direction but not its speed. The rate of changing direction will depend on the 'Strength' parameter.
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.
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.
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.
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.
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:
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.
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!
Color To Direction
This drop-down menu addresses the problem of converting a colour into a direction vector. The colour from the shader is sampled and produces a result from 0 to 1 for each colour component (red, green or blue).
We use the convention that red represents movement along the X-axis, green along the Y-axis, and blue along the Z-axis. The direction can either be positive or negative, but colour values are always positive, so to obtain vectors which can point along either the positive or negative axes, the colour is remapped from a range of 0 to 1 to a range of -1 to 1. This means that a colour with red set to 100% will result in a direction along the positive X-axis, while no red at all is movement along the negative X-axis. For example, a noise shader whose colours are set to red and black would result in vectors pointing along the X-axis (positive or negative) but not along the Y- or Z-axes since there is no green or blue in those colours..
If you set 'Color To Direction' to its default value of 'Red, Green and Blue' each colour component is remapped to give a value between -1 and 1; these values are combined to give the final direction of the vector. If you change the menu to 'Red Only' the red component is remapped, but the blue and green components remain at their sampled values - and these are always positive values.
With a colour such as a yellow-green (in RGB terms it could be 0.75, 1.0, 0.0) and assuming both colours are mapped, then the red value will be mapped to the range -1 to 1. In this case the X-axis component of the direction vector will be +0.5 and the Y-axis component will be 1.0.
If you leave red unmapped by changing this menu to 'Green Only', red will have a greater effect on the X-axis component because its unmapped value is +0.75. To remove any contribution at all from the red colour, you can check the switch 'Zero Non-Mapped Colours' which would cause the red component to be zeroed.
In that case the red component will no longer have any effect and the vectors will all point along the positive Y-axis with no direction along the X-axis at all. You can zero unmapped colours with any of the combinations of colours in the menu with the exception of 'Red, Green and Blue' since in that case all the colours are mapped and there are no unmapped colours to zero.
With a single colour it is easy to predict how the vectors will be aligned but a mixture of red and green would be more difficult to predict, and with a bitmap it would be very hard to know what the vectors will look like.
Here is an example of a noise shader set to red and black (the shader is not animated):
Important: remember that the shader only affects the flow field vectors. What direction the particle moves in will be influenced by the vector but also by other factors, not least of which is the direction the particle was moving in when it entered the flow field.
Zero Non-Mapped Colors
If this switch is checked, there will be no contribution to the vector from any colour which is not mapped, as determined by the 'Color To Direction' parameter. If it is unchecked any non-mapped colour will contribute to the direction vector using its raw value. Note that such values, if non-zero, will always be positive.
Brightness To Strength
If checked, this switch causes each vector in the flow field to be assigned a strength depending on the overall brightness of the sampled colour.
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.
If this switch is checked the 'Color To Direction', 'Zero Non-Mapped Colors' and 'Brightness To Strength' settings are ignored and the Flow Field will behave exactly as it did in the initial release version. This switch is only here to maintain compatibiity with older scenes using the Shader mode.
It can sometimes happen that making changes to the shader 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 if this happens 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.
Move Flow Field to Target
If the target object is a small object, when you add it to the 'Target' link field, it may be that the field is reduced in size so that the target is no longer within the field boundaries at all. You can avoid this by checking this switch. If it is checked, then after resizing the Flow Field, the field will be moved so that it is centred on the target object.
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.
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:
The cell strength is at maximum in all cases, regardless of distance from the target object.
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.
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:
The strength of effect is not altered by the particle distance from the target.
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.
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.
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.
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:
Drag the splines of polygon objects (depending on the selected 'Flow' option) into this list. You can use multiple objects.
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.
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.
The spline used to derive the cell strength depending on how far a cell is from the object.
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:
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.
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.
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.
This drop-down menu controls how the flow field vectors are influenced by the particles. It has two options:
The flow field will depend on the particle direction but its strength is not affected by particle speed.
The flow field will depend on the particle direction and its strength is affected by particle speed.
This setting is used to smooth out abrupt changes in vector direction as the particle move in the flow field.
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.
If this switch is unchecked the vectors will not be shown in the viewport.
When checked, the vector display will show vectors which are all the same size. In this case vector strength is shown by the colour from the 'Color' parameter. If this is unchecked, the size of the vectors will be dependent on the strength of the vector.
The shape used for the vectors. There are three choices: arrows (the default), dots or lines.
Use this control to alter the opacity of the vectors. This is useful if the vectors are obscuring other details.
This gradient is used to colour the vectors according to their strength. The weakest vectors use the colour from the left-hand end of the gradient, while the strongest ones use the colour from the right-hand end.
If all vectors have the same strength then the colour from the right-hand end of the gradient is used.
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.
Important: as with all other particle modifiers, the Flow Field will only have an effect on the particle if the particle is within the falloff zone. Therefore, if you set the falloff to anything other than 'Infinite', the action wil not be triggered unless the particle is within the falloff when it leaves the Flow Field box.
Actions on Escape
Drag any actions to be triggered on leaving the box into this list.
Click this button to create a new action and add it to the list.
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.
Note that due to the different coordinate system used in Unreal, the vectors are rotated to conform with the Unreal system on export. You can reload the .FGA file into the Flow Field, and the vector rotation will be reversed on import.
Please remember that this feature only exports a single .FGA file which is a snapshot of the vectors as they are when exported. If you are using an animated object or shader, which will change the vectors as the scene plays, you will not retain the animation on export; only the current state of the vectors is exported.
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.
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.