N-Lattice Fern Setup

It is advised to read the N-Lattice User Guide first before continuing on this tutorial.

As most foliage systems natively work with lattice geometry, Carbon N-Lattice is making it even easier to integrate Carbon into existing workflows for all types of plants and foliage applications.

Having the option to use lattice guides with different resolutions makes this new feature so versatile that it can be used to simulate a large variety of plants, ranging from thousands of low-resolution leaves on a tree to a few dozen high-resolution fern leaves.

For the remainder of this tutorial, we will demonstrate how to use the Carbon N-Lattice to set up and simulate a fern that is exposed to wind.

Base Lattice

The base lattice for a fern leaf should be rather detailed. For this tutorial, a 8 x 25 point resolution is sufficient.

Use an Edge Flip node allows to quickly fix any triangulation issues where certain triangles have two outside edges.

_images/tutorial_n-lattice_fern_lattice.png

Detailed fern lattice.

The next step is to set up the lattice shaft, which marks which points are welded to a rigid shaft.

Having chosen all relevant points for the shaft and placed them in a group, a simple Attribute Create node suffices to set the shaft attribute on the geometry.

_images/tutorial_n-lattice_fern_shaft.png

Creating the shaft attribute from a point group.

Individual Lattices

This process, where the base lattice is deformed and placed on the ground, or any other relevant underlying objects, varies strongly from application to application. For fur it might be a dog, for hair a human head, for feathers a bird, for leaves a tree, etc.

In case of a fern, each individual leaf could be sculpted to specific targets if the plant was the center of a scene, while on the other hand, they might all remain the same and any visual differences might only be added at the render stage.

For this tutorial, variations of the lattice are created procedurally and they are automatically placed in a circular fashion.

Taper

As a first step, the rectangular lattice is deformed to receive the general shape of a fern leaf.

The deformation is done by using the Taper operation in two Twist nodes, which taper the top and bottom of the rectangular lattice to achieve a rounder look.

Not only is this a visual improvement, but also helps to avoid over-constraining the vertices that are welded to the rigid shaft with near neighbor collisions. This will heavily reduce the risks of conflicting constraints and jittering at the base.

At this point in time, the lattices are not deformed further or placed individually. This will be done in a ForEach node later.

_images/tutorial_n-lattice_fern_taper.png

Using Twist nodes to taper the top and bottom of the lattice.

Copy

Next, create a Sphere node and delete the bottom half of the points. The remaining points will be used to place and orientate the fern leaves within the hemispherical space.

_images/tutorial_n-lattice_fern_hemisphere.png

Hemisphere for placing and orienting fern leaves.

Connecting these points and the tapered lattice to a Copy node creates one tapered lattice per point. At this step, ensure that each lattice is placed at the origin by reversing the translation term coming in from the points ($TX,$TY,$TZ) and also adding half the height of the leaf (0.5). It is important that all leaves are equal and spawned at origin at this step, as otherwise it would be very hard to properly deform and place each leaf in the final stage where a ForEach node is added.

_images/tutorial_n-lattice_fern_copy.png

Spawning one lattice per point in the hemisphere geometry.

Framing

Before placing and orienting the individual leaves, we need to create the framing information, that is the information for how to orient each fern leaf. A Copy node inside a ForEach later uses this framing information, specifically an up and N vector to lay out the leaves. Simply using the normal vectors on the sphere will not work in this case, as the leaves need not only stand in the correct up direction, but also have to be rotated correctly.

In terms of how to create the framing information, use a Attribute Wrangle node to create the up vector from the normal. After that, override the normal. This is simply the cross product of the up vector and the y-axis. At this point, also set all point y coordinates to 0 to ensure that all fern leaves are spawned on the floor/ground.

_images/tutorial_n-lattice_fern_framing.png

Creating framing information and setting y-coordinates to 0.

Place and Deform

Inside the ForEach network, gradually apply all deformations to the leaves that are required. In this tutorial, scale them individually, then bend them in two different directions, and finally place and orient them with a Copy node.

_images/tutorial_n-lattice_fern_for_each.png

ForEach network and nodes’ parameters.

The Point node is important as it ensures that each leaf is placed exactly on the ground. This operation cannot be incorporated easily into the copy1 node, as the transform translates along the up vector, which is not pointing upwards, but along the normal of the original sphere that the point belonged to.

For this scenario, all fern leaves are spawned in their final orientation, and scaled using Growth Lead-In.

Altogether, the final SOP-Network setup is shown below:

_images/tutorial_n-lattice_fern_sop_setup.png

Final SOP Network setup.

Simulation Setup

The simulation consists of a floor and a fern, which grows at first, and once it has stopped growing, some wind starts blowing.

In the dopnet, to set up the simulation, first create a Carbon Simulation node, then attach a Carbon Flow, which takes its input from a SOP Vector Field as second input. The first input is a merge node, which takes inputs from a Carbon Collider and Carbon N-Lattice node.

The rest of this section focuses on how to set up the Carbon N-Lattice node. For more information on how to set up a basic Carbon Simulation with a Carbon Collider, please refer to Avatar Cloth.

_images/tutorial_n-lattice_fern_dop_setup.png

DOP Network Setup.

For the first step to setting up the Carbon N-Lattice node, stay in the N-Lattice tab and set the N-Lattice SOP Path.

Note

As we are not animating the lattice geometry, make sure to untick Animated Geometry as it decreases solver speed when left ticked.

The Groom SOP Path can be left empty as it is only needed when swinging lattices, which is not the case in this tutorial.

Next, set the Root Offset to at least the Collider Outer Fatness. This offsets each lattice along its shaft vector to ensure that it will not intersect with the collider at startup.

Growth Lead-In can be left at 30 to use the automated growing process.

Make sure to select Groom Angles to avoid any angular override. Swing Lead-In and Angle Limit are disabled automatically as no Groom SOP Path is set.

For the Spring parameters, set the Swing Stiffness rather low to allow the leaves to swing in the wind, but set Twist Stiffness high to prevent the leaves from rotating too much.

Note

As we are not animating Angles or Springs, unticking Animated Angles and Animated Springs slightly improves performance by disabling the matching parameters’ evaluations and updates.

Finally, set low values for the friction terms to avoid the leaves from sticking to each other and make sure to set all Aerodynamics parameters properly to achieve a pleasing result. For more information about friction or aerodynamics, please refer to Friction and Aerodynamics.

_images/tutorial_n-lattice_fern_parameters.png

N-Lattice parameters.

Now, switch to the Lattice tab and set the correct Lattice Grid SOP Path.

Next, set the Lattice Width, which refers to the number of points on the base of the grid. In this case, the width is 8.

Warning

It is important to set the correct value for this parameter so that the lattices’ position and center of mass can be correctly calculated. Using an acceptable but wrong value (such as the grid height instead of width) will not give an error but still yield a visual result that will simulate incorrectly.

After setting Outer Fatness and Mass, it is recommended to add a Welding Radius to allow the lattices to slightly move in place. This is very helpful to avoid overconstrained situations around the shaft which can result in corruptions and jiggling.

Note

Please refer to Plumage Setup for a detailed description of the recommended steps to take when setting up welding radius and stiffness.

After that, set all soft properties. Detailed information about how each parameter influences the simulation can be found in Avatar Cloth.

For this tutorial, the main focus for the soft part of the lattice is on preventing too much bending by reducing the Bend Limit while increasing the Bend Stiffness.

Additionally, set Viscous Damping to 5 to prevent jittering and other fast motions.

_images/tutorial_n-lattice_fern_lattice_parameters.png

Lattice parameters.

The final simulation can be seen below.

_images/tutorial_n-lattice_fern.gif

Final simulation.