Compositing challenge: shadows

I had an issue with doubling shadows that was surprisingly tricky to deal with (I’m still not sure I handled it as well as I could have, and I’m open to other ideas). The problem is that when you lay CG shadows over real shadows in the image, the double-shadowed area becomes twice as dark. This obviously isn’t correct. Only one light source (in this case the sun) is being blocked, so the shadows should merge seamlessly. You can see the problem in the top picture here, along with my best effort at a solution in the bottom picture.

shadowcomp1

 

I tried a couple of approaches that didn’t really work, and the more I thought about it the more I thought that getting a perfect result could be quite tricky. For what it’s worth, here’s how I handled it:

For the shadow itself, I used a CC node on the plate factored by an inverted shadow pass as I discussed a few posts back. Lowering the gain slightly brought me to a very close approximation of the actual shadow, but of course with the overlapping shadows too dark. Then I fed the output of that into a lighten node, again using the inverted shadow pass as a factor, with a solid color as the second input. The solid color was basically a sample of the darkest point of the ordinary, correct shadow color. I tweaked that color until I got the most unobtrusive result, like so:

shadowcomp2

 

Note that this method wouldn’t have worked at all if there were different colors or values in the ground under the shadow. I had to be able to assume that the shadow itself on the street should be the darkest value. Still, the problem here was that the resulting lightened portion lacked the speckled texture of the street. So I wanted to add some speckling only to that lightened area.

To isolate the lightened area, I used a difference node with the non-lightened image and the lightened image as inputs. I separated the results into HSV components and used the value, like this:

shadowcomp3

 

This gave me a matte to work with only the solid-colored lightened portion.

Separately, I rendered out a b/w high contrast image of the street to give me a street texture map of sorts. I multiplied that with the lightened image to give it a little bit of grit, using the difference output as a factor (I added a multiplier to that so I could adjust the influence). I also used that as a factor for adjusting the hue and value of the output.

shadowcomp4

 

The result is far from perfect, but it’s less noticeable than the double shadows I started with. With all that’s going on in the frame I don’t think it will be at all noticeable. Still, if people have other ideas for dealing with doubled shadows, I’d love to hear them.

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: