> ## Content Index
> Fetch the complete content index at: https://www.keheka.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Converting Pworld to Pref In Nuke
- URL: https://www.keheka.com/converting-pworld-to-pref-in-nuke/
- Published: 2024-05-14T06:56:50.000Z
- Updated: 2024-05-15T07:32:33.000Z
- Description: How to create a position pass that sticks to your animated geometry…
- Author: Kenn Hedin Kalvik
- Tags: Nuke

*How to create a position pass that sticks to your animated geometry…* 

In this article, I’ll show you how to create a **reference/object position** pass using **world position** in Nuke, which you can use to create **position mattes** **that stick to animated and deforming geometry**: 

*A position matte (highlighted in cyan) that sticks to an object which is translating, rotating, and scaling.* 

## Pworld Vs. Pref

[Position data](https://www.xuanprada.com/blog/2014/7/29/p-maps?ref=keheka.com) is incredibly useful for grading CG renders ([among other things](https://www.hiramgifford.com/buddy-system/projectionbuddy?ref=keheka.com)). 

With it, you can create procedural mattes and avoid tons of unnecessary roto. 

For static objects, the common **world position** pass (often called **Pworld** or just **P**) works really well for generating position mattes. However, as soon as an object is animated, the world position pass falls short. Any position mattes you create with it will not stick to the animated object. 

That’s because the world position pass is centred around the world origin, and any animated objects will move *through* the coordinates. So in the position pass, the same parts of the animated object will receive different position values on each frame. 

*An object moving through the (static) world coordinates.* 

Any [position matte gizmo](https://www.nukepedia.com/blink/keyer/apmatte?ref=keheka.com), which by design creates a matte based on the values in the position pass, therefore can’t create a matte which sticks to the animated object using the *world* position. 

However, the gizmo *can* create a matte that sticks to the object – if we instead use another type of position pass which is centred on the object itself, the **reference/object position** pass (often called **Pref** or **Pobject**). 

The coordinates in this pass follow the animated object: 

*Coordinates wrapped around the object and sticking to it.* 

## Working Around Nuke’s Limited Position Options

As far as I’m aware, Nuke doesn’t offer any direct ways of generating a reference position pass – only a world position pass. 

But, as always, with a bit of ingenuity we can make one. 

The idea is to create a world position pass, output it in UV space, framehold it to lock the coordinates, and apply it back as a texture to our animated geometry. 

💡

This requires the geometry to have UVs. 

The coordinates will then stick to the object, and we can use them to create position mattes which will also stick to the object. 

![](https://storage.ghost.io/c/9a/44/9a44322e-a7f2-4402-a9a7-2c12ba7ce910/content/images/2024/05/Setup.png)

*The setup.* 

First, you’ll need to grab your **animated geometry** and your **camera**, and connect them up to a **ScanlineRender** node. 

In the **Shader** tab of the ScanlineRender1 node, tick **output vectors** and choose a layer to output the position data to. Below, I chose to create a new layer and name it **P**. 

![](https://storage.ghost.io/c/9a/44/9a44322e-a7f2-4402-a9a7-2c12ba7ce910/content/images/2024/05/ScanlineRender1_SettingsB.png)

*Outputting a world position pass using the ScanlineRender1 node.* 

To do the same, click on the dropdown menu next to **surface point**, select **new**, name your layer **P**, click on the **rgba** button, and then hit **OK**. 

![](https://storage.ghost.io/c/9a/44/9a44322e-a7f2-4402-a9a7-2c12ba7ce910/content/images/2024/05/ScanlineRender1_Position.png)

*Creating a position layer.* 

The ScanlineRender1 node will now output **world position** data in the **P** layer. Let’s turn that into a texture: 

In the **ScanlineRender** tab of the ScanlineRender1 node, set the **projection mode** to **uv**. 

![](https://storage.ghost.io/c/9a/44/9a44322e-a7f2-4402-a9a7-2c12ba7ce910/content/images/2024/05/ScanlineRender1_SettingsA.png)

*Setting the projection mode to uv in the ScanlineRender1 node.* 

Next, shuffle out the position pass (which is now in UV space) using a **Shuffle** node. 

💡

Make sure to set the ****alpha to white** in the Shuffle1 node! You’ll need a solid alpha in order to apply the position data back onto the geometry correctly. (That is, to use the full, unaltered position values). 

![](https://storage.ghost.io/c/9a/44/9a44322e-a7f2-4402-a9a7-2c12ba7ce910/content/images/2024/05/Shuffle1_Settings.png)

*The Shuffle1 settings.* 

Next, pick a frame where the animated geometry is visible in the frame and **FrameHold** the world position texture. 

Then, apply this frameheld texture back onto the animated geometry using an **ApplyMaterial** node. 

Output the textured geometry through a new **ScanlineRender** node with the **projection mode** set to **render camera**, using the same camera as before. 

Now, you’ll have a **reference position** pass in the **rgb** channels. 

Add your favourite position matte gizmo at the end, and colour pick away! 

I hope you found this tutorial useful. For more Nuke tips & tricks, see [Nuke](https://www.keheka.com/tag/nuke/).

[Sign up for the newsletter!](https://www.keheka.com/#/portal/signup)