# Composite a 3D object into a photograph

I was wondering how you would go about putting a 3D object into a photograph so that portions of the image are:

1. In front of, or
2. Behind the model.

For example, a photo taken from the roadside with a tree in the foreground. I want to show a 3D model of a car in the photo on the road but a section of it is not visible because it is obscured by the tree.

Is this possible? If so, how can you do it?

• Try out the camera mapping techniques: blenderguru.com/videos/camera-mapping-tutorial-v2 – user703 Jun 16 '13 at 13:29
• two posts that will interest you: cycles holdout material and cast shadows on footage/stills – zeffii Jun 16 '13 at 13:31
• while the answer to the question here is contained in both those links, I don't feel this question is a direct duplicate. It manages to ask a very succinct question and therefore is a good example of how to ask this question. – zeffii Jun 16 '13 at 14:12
• The most important part is covered by Jozsef but I would suggest you to dig a little in to image based lightning. You can do it with a regural mirror ball. It helps a lot in compositing CGI into footage - especialy that car ... is reflective:) – user710 Jun 16 '13 at 18:02

To answer this question with the one thing not mentioned there. You don't really need to use compositing here as you might have thought, the simplest way to do this is to model an object to mimic the shape of the object you want to use to obscure your other object(s) and while some people have and or will use some complex node setups, you can just add a new material to the 'mask object', enable Transparency, set it to Mask and turn the Alpha to 0 like this..