Help Needed for Lighting with Composited Scenes

I have been experimenting with camera tracking and compositing scenes over recorded footage, and I am having issues with shadows and lighting. I am aiming for lighting to be as realistic as possible. I take multiple exposures on the spot with a 360° camera and merge them into a true HDR image, then use that as an environment texture to light the scene.

When I press “Setup Tracking Scene” in the movie clip editor it automatically sets up a foreground and backup layer for shadows, which works great at first glance. However, I soon noticed that the nodes are set up so that only greyscale shadows are overlayed onto the video footage, and aren’t affected by ambient light or light reflected from scene objects. I am looking for a solution so that the background scene will overlay color/light from ambient light and any light reflected from scene objects.

Update:
So I found this thread with a possible solution setup:


However, this setup still uses the shadow output from the render layer, so shadows are very one-dimensional.

For reference, here is a render of my scene after compositing. No shadow depth and little to no ambient light.


Here is a render of my scene without compositing. Notice the shadow has a cooler color temperature due to ambient light from the sky.


The second image is more desirable, but I don’t know of a way to seamlessly transmit the lighting from the shadow catcher to the background footage.

I disagree that the second image is more desirable. I see “another, real, shadow over there.” Simply make this shadow look more like that one. For example, extract the shadow-information from your (MultiLayer OpenEXR, of course …) render, darken it, and maybe blur it a little.

Also, consider rendering the object on a “shadow-catcher plane” which you discard – leaving only the shadow and, separately, the alpha-masked object. Now you can use the shadow to darken the real background from the clean plate (blurred, as previously mentioned), so that the polygon now appears to sit on the actual ground. Although you did a good job of simulating pavement, you actually don’t need to do that in most cases.