3
$\begingroup$

I am looking to create a render pass that takes a scene and outputs, for each pixel, the 3D world coordinate of the center of the object to which that pixel belongs. In other words, all pixels that show the same object should have the same value.

Now, what I could do, is render a separate pass for each object where only the pixels of that object are white, and then set the values manually, but I was wondering if there was a better/quicker method.

Thanks a lot!

$\endgroup$

1 Answer 1

4
$\begingroup$

You can do this by using a Material Override and a special material to give the objects' positions.

First create a new material with an emission shader (you can add it to any object, it doesn't matter). Add an Input > Object Info node and plug the Location into the color of the emission shader.

enter image description here

Now you can create a fake user for the material and remove it from whatever object you added it to.

Then add a new render layer and set the Material Override (under the Layer rollout) to the material you just created. It would also be useful to override the samples to 1 as well to reduce rendertimes and effectively disable antialiasing.

enter image description here

In the resulting RAW rendered image the red, green, and blue values of each pixel will represent the location of the object rendered on that pixel.

$\endgroup$
1
  • $\begingroup$ Fantastic PGmath, exactly what I needed! Perfect! $\endgroup$ Commented Mar 16, 2016 at 16:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .