Home · Lab · CG Multipass & Relighting

CG3 Position mattes from the P pass

Select by real 3D distance, not by screen position

CG Multipass & Relighting · ~7 min · In pack $15

1 Your mission

~7 min

matte the sparks’ reach, everything within 2 m of them: cover at least 85% of it while no more than 10% of the matte leaks beyond 2.4 m.

Hint: grow the 2D circle and watch the leak: a circle that covers 85% still leaks at least 63%, because near sand and ground much farther away sit side by side on screen. In 3D, click the cross, lift the centre to the sparks’ height, then set the radius.

SkyVFX Lab · CG3interactive · 1001

2 Why it works

The P pass stores each pixel’s 3D position in R G B (X Y Z), in scene units (metres in our Blender render). A matte built from the distance to a point in 3D selects by real distance, not by where things sit on screen, so things that touch on screen at different depths separate cleanly, and the matte stays in the same place in the world when the camera moves.

The sparks float 1.0 m above the sand. The cyan line marks everything within 2 m of them: the sand underneath and the robot’s near side. Try the “2D circle (screen)” first and watch the leak readout, then switch to the “3D sphere (P pass)”: click the sand under the sparks (orange cross), lift the centre and set the radius. The “P (XYZ→RGB)” view shows the positions as colour.

matte = 1 − smoothstep(r·(1 − f), r, |P − centre|)

Where the numbers come from: Every picture is a Blender 5.2 Cycles render of our own desert and robot, computed in your browser. Blender’s P pass is in world metres, Z up (the plate’s P and the robot’s P). The target (2 m from the sparks) comes from the same render’s P; the 2–2.4 m shell counts as neither cover nor leak. The warm grade is a teaching effect, and the sphere’s fall-off is a teaching smoothstep; Nuke tools may shape it differently.