OpenVDB Mesher

This is an implementation of the OpenVDB Mesher for X-Particles 4. For information about OpenVDB in general, please refer to its reference documentation pages.

For information about using this object, see 'Using the OpenVDB mesher' below.

Interface

The object's interface includes these sections:

For the buttons at the bottom of the interface, please see the 'Common interface elements' page.

Parameters

General quicktab

Mode

The mesher can operate in three different modes. These are as follows:

Mesh

This generates a spherical mesh around each point, which may then be merged with other spheres to form a larger surface. The actual result will depend on the options chosen for the source objects - see below for more details.

Spheres

In this mode, instead of creating a surface, the mesher will first generate the mesh - which will not be displayed - and then fill that mesh with spheres. The parameters in this section allow you to control the sphere generation. As with the 'Mesh' option, the result depends on the source object options.

When you select this mode, another set or parameters becomes available, as described below.

Fog

This mode generates an OpenVDB volume. You can render this with an Explosia FX object. Additional controls become available when this option is selected.

Voxel Size (Editor)

The voxel size when the mesher is shown in the viewport during scene editing. Generally speaking, this should be kept as large as possible for maximum speed in the viewport. As the voxel size is lowered the resolution of the mesh increases and any animation in the viewport will be slower.

Voxel Size (Render)

The voxel size when the mesh is rendered. This is generally lower than the voxel size in the editor for higher resolution and better results.

See the discussion below concerning voxel size and scale factor when selecting values for these options.

Half Width

Much of the time, you can leave this alone. It controls the width of the 'narrow band' of voxels included in the surface (see the discussion below). Reducing it can reduce the number of polygons generated and make the mesh appear a little sharper, but if you make it too small, you may start to see artefacts and holes appearing in the mesh.

Point Radius

This setting only has an effect if the 'Mesh Mode' for a polygon object is set to 'Points' or if the source object is a spline or X-Particles emitter or a null object (because these only have points and no polygon surface, so the 'Mesh Mode' setting is not relevant). It has no effect on polygon objects if 'Mesh Mode' is set to 'Surface'. It controls the size of the spheres generated around each point or particle.

Min Point Radius, Max Point Radius

As with 'Point Radius' these settings are only effective if the 'Mesh Mode' for a polygon object is set to 'Surface' or if the source object is a spline or X-Particles emitter, when the 'Mesh Mode' is not relevant. They are the limits on the size of the virtual sphere generated around each particle by the mesher (see the discussion below for full details). If the sphere size is outside these limits, it will not be included in the mesh. For the most part you can leave the default values as they are, but if you need to exclude very small or very large particles, you can alter these limits.

Grain Size

If set to higher than zero, the mesher is threaded. In practice the value in this setting makes little or no difference to the mesher speed in the current version.

Render Only

If this switch is checked, no mesh will be visible in the viewport and will only be seen when the scene is rendered to the viewport or picture viewer.

Mesh Adaptivity

This parameter is only available if 'Mode' is set to 'Mesh'. By increasing it you can reduce the number of polygons in the mesh but the mesh may look less rounded and not as attractive.

Sources

This is a list of source objects the mesher will use. These objects can be:

  • an editable polygon object
  • a polygon primitive object (Cube, Cone, etc.)
  • an editable spline
  • a spline primitive
  • an X-Particles Trail object
  • an X-Particles emitter
  • a Cinema 4D Null object

Multiple source objects can be used simultaneously. You can prevent any object from being meshed by unchecking the switch next to each object in the list.

Drag the objects you want to use into this list. When you select an object in the list, additional controls are presented. For a polygon object the basic controls are these:

Mesh Mode

This drop-down menu is only available for polygon objects and polygon primitives. It has two options:

Surface

The mesher will generate a contiguous surface from the object's vertices.

Points

The mesher will generate small spheres around each vertex.

Note that for splines and emitters, this menu is unavailable and the mesher always treats such objects in 'Points' mode.

If you select 'Points' mode, more controls are provided:

Point Type

There are two options in this menu:

Spheres

A sphere is generated around each point (or particle).

Trails

This is used if the source object is an X-Particles emitter.

These are NOT the same as the splines generated by the X-Particles Trail object! Each trail is a tapering mesh which forms behind the particle and whose length is dependent on the particle speed. If you use an object such as a Cube as a source for the mesher, the vertices of the object have no speed so only spheres are produced. This is the case even if the object is animated, since the vertex speed is zero in relation to the object.

Selecting this option shows two more controls:

Trails Delta

When 'Mesh Mode' is set to 'Trails' the particle effectively gains a tapered tail behind it. This is built by the mesher as a series of spheres with decreasing radius. This setting controls how far apart the spheres are drawn. The farther they are apart, the less they are unioned together so increasing this value may result in the trail being drawn as a series of unconnected spheres.

You can increase this value as much as you like, but as you reduce it the number of computations required significantly increases, and if the value is too small, Cinema may appear as if it has frozen. To prevent this you cannot set the value to be less than 0.1.

Velocity Factor

When 'Mesh Mode' is set to 'Trails' the particle effectively gains a tapered tail behind it. The length of the tail depends on the particle speed, which leads to a problem: how do you obtain short trails without reducing particle speed (or long trails without increasing speed)?

This factor is simply a scale applied to the velocity. It does not change particle speed but the value passed to the mesher is altered by multiplying by this value. Reduce it for shorter trails and increase it for longer ones.

CSG Mode

This is the method used by the emitter to control how multiple meshes are joined. The options are:

Union

The meshes from each source object are joined together to form one mesh.

Intersection

The volume where the objects overlap is meshed.

Difference

The volume where the object do not overlap is meshed.

Fill With Spheres parameters

If you select 'Fill With Spheres' in the 'Mode' drop-down menu, several new parameters appear:

In this mode, instead of creating a surface, the mesher will first generate the mesh - which will not be displayed - and then fill that mesh with spheres. The parameters in this section allow you to control the sphere generation.

Max. Number of Spheres

This is the maximum number of spheres that will be created, even if there is space to include more.

Min. Sphere Radius, Max. Sphere Radius

The size limits of the spheres. If they are both the same the spheres will be of uniform size.

Segments

The segment count for the generated spheres.

Iterations

This is the number of points in the volume the mesher will look at to place a sphere. The higher this value, the greater the chance of being able to place a sphere, but the mesher will take longer to complete the result.

Allow Overlap

If this switch is checked, the spheres will be allowed to overlap. This produces a cleaner fit of the spheres, but the spheres may (will) overlap one another.

Fog parameters

When you select this option in the 'Mode' drop-down menu, these parameters are available:

EFX Object

Drag an Explosia FX solver into this field. The solver will be used to generate the fog from its smoke channel.

Exterior Band Width, Interior Band Width

The interior and exterior band widths control how many voxels to fill inside and outside the volume respectively. It is recommended that you do not change these settings from the defaults unless you know exactly what you are doing. For example, increasing the exterior band width excessively will try to fill too many voxels with fog data than Cinema 4D can handle and it may appear to freeze.

Filters quicktab

Filters are smoothing routines which can be applied to the mesh. You can apply as many filters as you like, but note that the order the filters are in may affect the final result.

These filters may have very significant effects on the mesh, altering both its size and shape. There is one filter in the list by default, a simple 'Median' filter. You can delete or disable this if you wish.

Use Filters

If this switch is unchecked, no filters are used even if there are some in the list.

Filters

The list of filters. To add a filter, select one from the 'Add Filter' drop-down menu. To delete a filter, click its name in the list to select it, then hit the Delete or Backspace key. Alternatively, right-click the filter to show the context menu and click 'Remove' or 'Remove All'.

To disable a filter temporarily, uncheck the switch to the right of its name; or, right-click it and from the context menu click 'Disable'.

Add Filter

Select the desired filter from this drop-down menu.

Editing a filter

Some, but not all, filters have a value that can be changed. Click the filter to select it and a value field appears:

You can then alter the value.

Using the OpenVDB mesher

The OpenVDB mesher is extremely powerful and the main advantage over the inbuilt X-Particles Skinner is its speed. Typically it will mesh an object like this in under a second:

This was created by taking the vertices of an object which had 147,730 vertices and meshing it in the OpenVDB mesher. This shows the speed that this mesher can achieve.

How the mesher works

The mesher is supplied with three items of data for each particle (or vertex, if the source object is a polygon object or spline). These are the particle position, its radius, and its velocity. For polygon or spline objects, the radius is arbitrarily set to 1 and the velocity to zero, but for particles, the actual values from the particle are used.

With this data, OpenVDB constructs a three-dimensional grid to enclose all the points; each cell in this grid is a voxel. Voxel size can be changed with 'Voxel Size' setting.

Each voxel can be outside the surface to be generated, or inside it, or actually on or near the surface itself. The band of voxels at the surface, which are the 'active' voxels, is a narrow one and its width can be altered by changing the 'Half Width' setting. (This is why, if you read the OpenVDB documentation, this data is referred to as a 'narrow-band level set'.) All other voxels are considered 'inactive' and play no part in forming the surface.

The mesher then constructs a virtual sphere around each particle. The size of this sphere is the particle radius (or 1 if the object is not an emitter). If the spheres overlap they will be unioned, much as two sphere objects might be joined by a Cinema 4D Boolean object. If the sphere is smaller than the 'Min Radius' setting or larger than the 'Max. Radius' setting, it will not be included in the mesh.

Finally, if there are voxels within this sphere that are part of the narrow band, the sphere will be meshed, and the size of the generated polygons will depend on the voxel size.

Effect of changing settings

Knowing how the mesher works, we can predict what the effect of changing settings will be.

Changing the Voxel Size

if we reduce the voxel size, two things will happen. The generated polygons will be smaller and there will be more of them, so reducing voxel size will increase the mesh resolution; increasing it will reduce the resolution. For obvious reasons high-resolution meshes will take longer to generate than low-resolution ones.

The other effect is that the spheres surrounding individual particles may appear to increase in size. What is happening is that since there are more voxels the chance that a voxel falls within the narrow band is increased and more mesh is generated - up to a point. If the voxel size continues to decrease there may be no further visible change though the mesh resolution will continue to increase.

Conversely, if the voxel size is increased the number of voxels in the narrow band falls and the generated mesh will appear to reduce; if the voxel size is too large, there may be no mesh generated at all.

This video shows what happens when a cluster of particles are meshed and the voxel size is reduced from 4 to 2:

You can see that as the voxel size is reduced the mesh becomes smoother, individual blobs are better defined, and some particles which were not meshed at first begin to be meshed as well.

Changing the Half Width

Most of the time you can leave this unchanged. It alters the width of the narrow band of active (surface) voxels so if it is lowered you may see a slightly better definition to the mesh - though it is usually marginal at best. If you make it too small, some voxels which should be in the narrow band are omitted and you will start to see holes and artefacts in the mesh. In this video the half width value is reduced from 1 to 0.05. There are no visible changes until the value reaches about 0.32, when artefacts start to appear, and as the value is reduced still further, holes appear in the mesh:

In summary

The voxel size and/or radius scale you choose will have significant effects on the mesh. In general, for meshing an object with many vertices and great detail, such as the dragon used above, you would choose a small voxel size. But for cumulus clouds you would want the large, blobby appearance you would get with a large voxel size and particle radius. In the end it is a matter of artistic judgement.