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 Guide Data modifier. In this tutorial we will be using Vray to render out the pass, however, any renderer which supports hair texture coordinates and 3dsmax's built-in Vertex Color map will yield similar results.

 

Setting up Object Space Color rendering 

  1. Set the active production renderer to VRay. This will ensure that VRayOrnatrixMod is added to the top of the modifier stack when the hair is created. Otherwise, add the VRayOrnatrixMod manually.
  2. Select the hair object inside the scene and add the Generate Guide Data modifier on top of the modifier stack
  3. In the added Generate Guide Data modifier:
    • Set Target Data to Texture Coordinates
    • Set Channel Type to Per-Vertex
  4. Create a new Standard material in Material Editor
    • Set the Diffuse part of the material to a new Vertex Colors map
    • Set the Self Illumination of the material to 100%
  5. Assign the material to the hair object
  6. Render the hair using VRay

As a result you should see the object 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 Guide Data modifier 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 

  • If using VrayOrnatrixMod make sure to turn off the generate w coord option, or else it will override the pass' Z coordinates
  • VrayOrnatrixMod doesn't support using more than one texture coordinate channel. As such you must use the 0 channel in both the Vertex Color texture and Generate Guide Data modifier.
  • When storing values in Generate Guide Data modifier, 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 Guide Data modifier 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.