Access hair child strands (animation nodes)
Problem Definition

Animation Nodes provides a set of nodes that returns some information about particle systems, however, non of which provides any information regarding hair children, and this is a known limitation in blender.

To get around this, we shall replicate the children system in blender's particle system using Animation Nodes.

Inputs

Our input is a list of poly splines that represents the hair returned by the Hair Data Node :





Each of the following section will concern with on particular aspect about children, any section can be ignored if it has no need for you. We shall attempt to replicate all children options.

Children Generation

Given a single spline that represents a single hair, the simplest of things we can do to generate some children would be as following. We can make copies of that spline, move them around in random directions and return them. Animation Node have a particular node that does exactly that, the Replicate Spline Node:



Notice that the used transformations acts as offsets to the original spline locations, this is due to the fact that splines are described in global space, something we have defined in the Hair Data Node. So it is sufficient to use the output of the random vector node directly.

Tangent Based Offsets

The previouse simple method imposes certain effect that you might consider faulty, since the hair can move freely in any direction, it might move away from the surface and be considered detached from the mesh. A solution is to restrict the motion to the two axis that are perpendicular to the tangent. There are many ways which we can do this, the simplest of which would be to project the random vectors on the plane with normal equal to the tangent at the start of the splines:



Notice that the magnitude of the random vector may change based on the angle they make with the normal of the plane, so you might want to renormalize the random vectors accordingly. A more efficient method to do that same thing would be to compute two perpendicular vector that are perpendicular to the tangent, Animation Nodes already gives us one of those vectors, the Normal vector (Though it can still be computed by taking the cross product between the tangent and some arbitrary unit vector), if we take the cross product between the tangent and the normal, we will get a cotangent that is perpendicular to both vectors, if we define the random vectors as a linear combination between the normal and the cotangent, we will get similar results to the projection method:



Remember that a linear combination between two vectors is the sum of the vectors multiplied by some scalar, in this case, random scalars. This works because both vectors are linearly independent from the tangent, this guarantee there won't be an offset along the tangent direction.

Surface Normal Based Offsets

Using the tangent of the first bit of the hair spline may not achieve the result we are looking for, this is due to the fact that if the angle between the tangent and the surface normal at that point is high enough, the offset will still be away from the surface and subsequently it will look detached ! So a possible fix is to use the surface normal at that point instead, to get the surface normal at the tip of the hair, we can use the BVH Find Nearest Surface Point Node:



This, I think, is the method blender uses because it gives very similar if not identical results to the children hairs. It should be noted that this method is more expensive than other methods because it required BVH operations which are costly for large data sets.

Advanced Point To Point Offsets

To really get fine control over the output spline, we will take it a step deeper and edit the individual points of of the spline. We will first evaluate some points on the spline, get their locations, normals and cotangents, to get the cotangent, we use the cross product as we learned before. Then we create a loop that has two iterators which are some random values that we will use as scalars in the linear combination just as before, inside the loop, we perform the linear combination and create a poly spline from the result and return them:



Now that we have a good base children hair, we can go ahead and add some effects to it.

Clump Effect

A clump effect is making the hair closer to each other at the tip or the root of the hair, since we are actually offsetting the children's points, all we have to do is to scale down the offset factor based on the location along the hair, for instance, if we were to clump the hair at its root, will will multiply the scalars of the linear combination by some small value for points near the root and leave the scalars of the points at the tip as this, in other words, we will multiply all the scalars by values ranging from zero to one where zero is at the root and one is at the tip:



The added nodes are highlighted in blue. If I want the clumping to happen at the tip, I simply have to invert the values of the interval:



Let us take it a step further and control the clump factor using an interpolation curve, all we have to do is to evaluate the interpolation at the values we used before:



Which gives the effect:



Randomize Hair Points

Adding noise to the hair is as easy as adding the random vectors on the hair points, so I will leave this one to you.

Hair Trimming

We can trim hair using the Trim Spline Node:



We can also input random values from the trim node:



Which results:



Hair Noise

We can use Animation Node's noise functions to offset hair points and making it look a bit noisy:



Noise can be evaluated three times to construct a vector noise which can be add on the final point locations instead of the offset factor.

Curl Kink

Curl king is shaping the hair as a helix. This can be done by adding a vector defined by the parametric equation of the circle ($x = cos(t), y = \sin(t)$) where the parameter $t$ is a scalar multiple of the index of the point along each hair, this is exactly the equation of the helix except we are using the normal and contangent as the fundamental vectors of the space where is the normal helix equation is defined in terms of the $x$ and $y$ fundamental vectors:



Which results:



Notice that we can optimize the node tree by putting the interpolation and kink computations outside the loop since it is constant for all hair strands:



Radial Kink

Radial kink is making the hair oscillate as a sine wave radially around the base hair, so it is as simple as adding a sine wave by the factor we generated from the interpolation:





I have shown most of the effects achievable through hair children system in blender, there are millions of other ways to control the children, I think I have showed the workflow and you will be able to do whatever you want yourself. Finally, here is a sample blend file for a combination of effects to play with and explore: