Position Reference Pass 

When doing compositing it is often useful to have a separate render pass which captures the relative object space positions of hairs, which do not change as the hair is deformed and moved during animation. This means that at some time each strand point gets its own unique color and this color remains the same for the duration of an animated sequence. This approach is called position reference (or Pref) pass.

Ornatrix enables creating PRef passes through its Generate Strand Data node. In this tutorial we will be using Arnold to render out the pass, however, any renderer which supports data channel export will yield similar results.


Setting up Object Space Color rendering 

  1. Select the hair shape inside the scene and add the Generate Strand Data operator on top of the operator stack
  2. In the added Generate Strand Data node:
    • Set New Channel Name to "Pref"
    • Set Channel Type to Per-Vertex
    • Set Sample Value Count to 3, to export XYZ values in three consecutive scalar channels
    • Set Generation Method to World Space Position
    • Uncheck Use Target Value Range option (this is only needed if you want actual vector world positions, otherwise values will be compressed to be between 0 and 1 range which is useful for RGB non-vector renders)
  3. Export the generated "Pref" channel
    • In the hair shape's Rendered Export drop down change name field to "Pref", type to "color", press the + button
    • Select and move the Pref_1, Pref_2, and Pref_3 channels from the left field to the right in the same order
    • Press Confirm
  4. Set up the hair material
    • Open Hypershade and drag the Arnold hair material (e.g. aiStandardHair1) assigned to the hair into the node editor
    • Add Utility -> User Data -> aiUserDataVector node
    • Change the created node's Attribute value to "Pref"
    • Connect "aiUserDataVector" node to Emission Color slot of aiStandardHair1 node
    • Add Utility -> User Data -> aiUserDataFloat node
    • Change the Default Value of the created node to 1
    • Connect the output of the created node into the Emission slot of aiStandardHair1 node
  5. Render the scene

As a result you should see the world space coordinates of each hair being rendered as colors. This is what we're looking for, however, we're still missing one detail.


Capturing current Object Space values 

We need to "remember" the current object-space values for all hairs to make sure that they remain consistent if the hair moves during animation. Otherwise, the colors of the hair will change on each frame to reflect its new object space position. To do this:

  1. Scroll to the frame at which you want to capture the hair object space coordinates, for example frame 0 (or first frame of your animation)
  2. In the Generate Strand Data node click on the Store Values checkbox
  3. Perform a scene render

Now the values will be stored with your scene. As the hair moves it will retain the colors which were assigned to it on the first frame, allowing a proper Pref pass for compositing. Note that if you modify the hair count or order you will need to uncheck and re-check the Store Values parameter to ensure that the values are re-cached.


Notes and limitations 

  • When storing values in Generate Guide Data operator, if it is applied on top of hair then the rendered version of hair may not have the correct values. To fix this use either one of these approaches:
    • Before checking the Store Values option set the render hair count in Hair from Guides modifier to 100%. You can decrease the hair count after the values are stored.
    • Place the Generate Strand Data operator below Hair from Guides modifier, to generate the position data on guides instead of hair and have the hair interpolate these positions. This will yield less precise results but should be acceptable in most cases.
Missing Something? Let us know if this page needs more information about the topic.