# Emission direction

By default, Vellum constraint and solver nodes don’t provide dedicated parameters to determine an exact emission direction. Particles only follow the solver’s built-in forces gravity and, if active, wind. Let’s say, for example, you want to emit particles along a source object’s normals or make the fluid move upwards in a 60° angle. Such tasks require a custom function to set the particles' initial direction at creation time.

If you want to change the particles' trajectories, you can add POP forces. Houdini provides preconfigured POP nodes, but it’s also possible to assemble custom forces through a POP VOP DOP. One of the most common forces is POP Drag DOP. This force mimics air friction and helps to decelerate fast moving fluids and keep the particles together. Another very useful node is the POP Attract DOP. Here you can direct particles towards a goal position. Typical examples for POP VOP forces are Curl Noise VOP or Turbulent Noise VOP to randomly displace particles and create interesting structures.

## Initial direction ¶

The introduction already mentioned two common problems: it’s not obvious how to emit particles along an object’s normals or specify a certain angle for emission. In both cases, speed is the key. The task is to modify the particles' velocity, so they move in a certain direction. In the image below you can see the normals of a basic Sphere SOP. The idea is to use the normals as a “guide” for the particles by converting those normals into velocity. Normals and velocity consists of XYZ components and together they form a vector. In the example setup below, particles are scattered across a sphere’s surface and then accelerated along the normals.

### Basic fluid setup ¶

1. On obj level, press ⇥ Tab to invoke the TAB menu. From there create a Geometry OBJ and double click it to dive into the node.

2. Set Uniform Scale to `0.5`.

3. Increase Rows to `52` and Columns to `96` to get a smoother surface.

4. Click the Display Normals icon to make the normals visible. If the normals are too long, move the mouse cursor over the viewport and press D. This hotkey opens the Display Options. Click the Guides tab and set Scale Normal to `0.05`.

5. Add a Scatter SOP and connect its input with the Sphere SOP’s output.

6. In the Scatter node, increase Force Total Count to `10000` to get enough particles. Now, create the Vellum fluid network.

1. Connect the first input with the Sphere’s output to transfer the particles.

2. Turn off Create Points from Volume to cover the surface.

3. Set Particle Size to `0.005` or smaller to see the individual fluid particles.

4. Add two Null SOPs and connect them to the first (Geometry) and second (Constraints) output of the Vellum Configure.

5. Rename the first output’s Null to `GEO` (geometry), the second to `CON` (constraints).

6. Connect the Vellum Configure node’s third output to the third input (Collision Geometry) of the solver.

Note, that the other two inputs remain empty, although they're mandatory. The connection will be established through another node inside the solver. You might notice that all normals point in negative Z direction. What you're seeing now are the particle normals. 1. Double click the Vellum Solver to dive into it.

2. From the TAB menu, add a Vellum Source DOP.

3. Connect it to the `SOURCE` Output DOP.

4. Go to SOP Path and type `/obj/geo1/GEO`.

5. For Constraint SOP Path, enter `/obj/geo1/CON`. Now, geometry and constraints are connected to the solver. The reason for this detour is that you now have access to the Emission Type parameter.

6. From the Emission Type dropdown choose Each Substep.

7. Return to geo1 level and click the Vellum Solver to access its parameters.

8. In the Solver tab, increase Substeps to `5` - the standard value for fluids.

9. Decrease Constraint Iterations to `20` to make the fluid less rigid.

10. Fluids don’t need Smoothing Iterations and you can set them to `0`.

11. Open the Forces tab and change Gravity to `0,0,0`.

### Introducing the normals ¶

When you simulate, you can see that only a few particles randomly move. To make the particles follow the Sphere’s normals, two more nodes are required.

1. Return to geo1 level and open the TAB menu. Add two Point Wrangle SOPs.

2. Place the first Wrangle between Sphere and Scatter to connect it.

3. In the VEXpression field, enter `@N = @N;` (including the trailing semicolon). This VEXpression takes the the Sphere’s normals and stores them in a new `@N` variable. `@N` is a standard geometry attribute like `@P` for position. Houdini recognizes standard variables and their data types. Normals, for example, are vectors. Vectors can be split into their components using `@N.x`, `@N.y` and `@N.z`. This is interesting if you only want to use the normals' Y values, for example, and replace X and Z through your own formulas or fixed values.

4. Turn on the Vellum Configure Grain node’s blue Display/Render flag.

You can now see the particles' normals pointing away from the sphere. The object’s normals are transferred to the particles. ### Velocity from normals ¶

In this step, the normals are used to define a velocity. Since you don’t know how fast the particles will be at creation time, it’s a good idea to introduce a factor to control their speed.

1. Place the second Point Wrangle between Scatter and Vellum Configure to connect it.

2. In the VEXpression field, enter `v@v = set(normalize(@N) * chf("speed_multiplier"));`. Again, don’t forget the semicolon!

The expression introduces a velocity vector `v@v`. `@v` is another standard attribute like `@N`, so the name must not be changed. The `set` command sets the velocity vector. You don’t have to define the XYZ vector components manually, because `@N` is already a vector. The `normalize` function recalculates the normals to values between 0 and 1. This process can be seen as a standardization and returns predictable results. Finally, a custom parameter `speed_multiplier` is introduced. With this value it’s possible to scale the particles' initial speed.

1. Click the icon to expose the custom Speed Multiplier parameter. Enter a value of `0.2`.

2. Turn on the Vellum Solver’s Display/Render flag and click to simulate.

The particles follow the Sphere’s normals and you can make them slower or faster with the custom Speed Multiplier parameter.

Normals are perpendicular to their associated polygons, but you can randomize the normals through another VEXpression. There are endless possibilities and you can combine various VEXpression functions to get interesting results.

• Select the first Attribute Wrangle. In the VEXpression field, add another line and enter `@N = curlnoise(@N);` to create a curly normal field. The `curlnoise` function looks good with spherical objects as shown below. ## Custom emission direction ¶

The normal method can also be used for 2D emitters like grids. This way it’s possible to shoot particles into a certain direction just by rotating the grid. For a smooth particle stream, dive into the Vellum Solver and change the `vellumsource1` node’s Emission Type to Each Substep. To invert emission direction, make the object normals negative: `v@normals = -@N;`. The grid’s Rotate values in the image below are `45,0,30`. Another way is to define a custom initial velocity. Normals aren’t required here and you can therefore delete the two Wrangles if not already done.

1. Add a new Point Wrangle SOP and place it between Scatter and Vellum Configure.

2. If you have a Grid SOP as particle source, replace it through a small Sphere SOP.

3. Velocity is a vector, consisting of XYZ components. For a complete vector, you have to define three values. In the VEXpression field, start with `v@v = set();`. This expression tells Houdini to set an initial velocity. The actual XYZ values are written in the brackets.

4. You can use any valid function. The function can be static, time-dependent, or a combination of both methods. A complete velocity vector could look like this expression: `v@v = chf("speed_multiplier")*set(sin(@Frame/4),0,cos(@Frame/4));`.

## Applying forces ¶

The first decision is whether you want to work with DOP or SOP networks. Both network types accept POP forces to drive the particles, but there’s a difference where to add those forces.

• In the Vellum Solver SOP’s Force tab you can find Gravity and Wind parameters. In SOP networks, double click the Vellum Solver to dive into it. Inside the node you can see an Output DOP named `FORCE`. This is where new forces are linked to.

• The Vellum Solver DOP lacks a Force tab and even standard gravity has to be introduced through a separate downstream node. This applies to all forces in DOP networks.

This example explains how to make particles follow a spiral and can be seen as blueprint for the usage of force in Vellum. The scene uses a SOP setup. In DOP networks, e.g. created through the  Vellum Grain shelf tool, forces are added inside the AutoDopNetwork DOP before or after the solver.

### Particle path ¶

The fluid’s path is created from a deformed spiral.

1. On obj level, press ⇥ Tab to invoke the TAB menu and create a Geometry OBJ. Double click the node to dive into it.

2. Change Height to `5`.

3. Turns is `1.8`. This is the number of Turns over the curve’s Height.

4. In the Radius section, change Start Radius to `0.25` to make the spiral thinner.

5. Go to Construction and shift the spiral’s start point by increasing Start Angle to `120` degrees.

6. Divisions per turn should be `100` to get a smoother curve.

The spiral is deformed to get more turbulence.

1. Add an Attribute Noise SOP and connect its input to the upstream Spiral node.

2. Under Attribute Names, delete `Cd` and enter `P` for `position`.

3. Change Amplitude to `0.3` to smooth the spiral and avoid extreme displacement.

4. You can create more structure by decreasing Noise Pattern to `0.7`.

Transform the spiral to set its start to the scene’s origin.

1. Add a Transform SOP. Connect the input with the Attribute Noise node’s output.

2. Set Translate to `-0.1,0.02,0`.

3. For Rotate use `0,45,-90` degrees to tilt the spiral and align it with the X axis.

### Vellum fluid network ¶

1. Create a Sphere SOP and set its Uniform Scale to `0.2`. Check, if the spiral’s starting point is inside the Sphere.

2. Add a Vellum Configure Fluid SOP and connect its first input with the Sphere’s output.

3. Set Particle Size to `0.007` to get enough particles.

4. Expand the Physical Attributes subpane, turn on Surface Tension and enter a value of `25`.

5. Add two Null SOPs and rename them to `GEO` and `CON`.

6. Connect `GEO` to the Vellum Configure node’s first output, `CON` to its second output.

In the next step, configure the solver.

1. Lay down a Vellum Solver SOP. Connect the third input with the third output of the Vellum Configure SOP.

2. Change Solver ▸ Time Scale to `0.25` to make the simulation 4× slower.

3. For the following three parameters (Time Steps, etc.) use the standard values for fluids: `5`, `20`, and `0`.

4. Open the Forces tab and set Gravity to `0,0,0`.

5. Double click the solver to dive into it.

6. Add a Vellum Source DOP and connect it with the `SOURCE` node.

7. For SOP Path, enter `/obj/geo1/GEO`.

8. For Constraint SOP Path, enter `/obj/geo1/CON`. Particles and constraints are now connected to the solver.

9. From the Emission Type dropdown choose Each Substep.

10. Go to Activation and type the following expression: `\$FF<50`. When the current frame is smaller than 50, particles are sourced. Starting with frame 50 the source is inactive.

### Forces ¶

The particles should follow the spiral and wind around it. There should be drops, but also a main body of fluid with enough turbulence to create an interesting look. Start with the curve force.

1. Inside the Vellum Solver, add a POP Curve Force DOP and connect it to the `FORCE` node.

2. For SOP Path, enter `/obj/geo1/transform1`. This is the last node of the spiral’s network.

3. Max Influence Radius is `0.4`. When you change the value you can see that the red tube becomes thinner. The tube marks the area, where particles are influenced by the curve force.

4. Follow Scale is `4`. This force makes the particles move along the curve.

5. Suction Scale is `12` to attract the fluid towards the curve.

6. An Orbit Scale of `3` creates a rotational force around the curve.

It can be tricky to balance these forces. When you increase one force, you normally have to decrease another parameter to avoid overshooting effects. If the particles are too fast, it’s a good idea to decelerate them.

1. Add a POP Drag DOP and place it between curve force and `FORCE`.

2. Air resistance slows down the particles. Here, enter a value of `0.62`.

When you simulate, the fluid follows the spiral, but there’s hardly any turbulence and everything looks smooth. To get more randomness, do the following.

1. Add a POP Force DOP and place it between curve force and drag force.

2. Under Noise ▸ Amplitude, enter `17`. The noise field rips the fluid apart and creates droplets.

Start the final simulation and watch the fluid winding around the curve. There are thinner and thicker areas, the particles are decelerated at the spiral’s turns and you see drops. After approximately 120 frames, the first particles start to leave the spiral. You can limit the simulation to 150 frames.

# Vellum

## Constraints ¶

• Create rigid-body-like Vellum objects through packed spheres.