bring 3d scene objects position in the compositor


I was wondering if there is a way to use a 3d object position in the compositor.

Basically it would be like the track position node, just instead of importing data of a tracker, I would like to use the data from an empty object directly from the 3d viewport.

It would be very useful to bring 2d elements in a 3d render in post.

Is something like this possible?

Thank you in advance!

Object location in world space is not defined in camera view space, so you cannot get a position value. You can get UV for surface and Z for depth/occlusion in camera view. But that wouldn’t help attribute location.
Perhaps render out a fast Open GL of the scene, then track that in the MCE?

It should be possible, but not with regular tools available in the compositor.
There is a python function that convert a 3D position to screen space :

import bpy
import bpy_extras
bpy_extras.object_utils.world_to_camera_view(bpy.context.scene, , vec)

where vec is the position of your 3D object,
That should return the 2D position between 0 and 1 , that you need to multiply with the render size.

That should be possible to set a driver inside the compositor , it just can be more or less tricky depending on your python / driver skills.

Worse case scenario : one can make a python script that generate animation curves of a node if making the driver gets too complicated or impossible.

All that said, 3pointEdit solution is still quite simple and work without getting geeky.

Good luck :smiley:

Yup. A driver that returns the values to the compositor

img_follow_camera_space_ja12.blend (102 KB)

thank you guys! I am heading out now, will definitely check this out in the evening!

It’s amazing that there’s a very nice script to export this data to after effects, but there is nothing to do the same within blender itself! :smiley: