Rendering HDRI background and image seperately

For a simple test scene, I am using an HDRI image both as background as well as lighting.

I want to be able to change my 3-D objects independently from the background in the compositor.

The usual way to do that would be to render out the objects on a transparent background and alpha-over them to the background image.

My problem now is: I can set “transparent” only for the whole render… not for different render layers. So if I render my objects on “transparent”, my HDRI will never be rendered.

Right now, I circumvented the problem by rendering out the background seperately, save it as an image-file and use this as the compositor background. But that isn’t an optimal solution.

Is there a way to solve this problem Did I - again - miss something obvious?

What you’re looking for is in the ‘Passes’ section of the render layers tab. You want to check the Environment pass:


This will add an Environment element to your rendered image that you can use in the compositor to add back in your background. A bit more info on what it does is contained in the blender docs section on passes.

And again I learned something new! Thank you very much!