CG Jam

How to use the shadow catcher in cycles 2.79

Blenders new Shadow catcher.

So blender got a new shadow catcher feature in version 2.79, like yeah thats not news, everyone knows that, but how do you adjust it to match your scene? well thats the secret we’re about to reveal!

Good idea, poor results.

Shadows have been troublesome in blender. Previous results required various workarounds in the compositor, which was ok, and the motion tracking workflow actually set that up for you, but, we wanted a simpler solution and in 2.79 we finally got one. By selecting the object data tab and opening up the cycles settings panel you can simply tick a check box and turn any object into a shadow catcher.

Neat, but as you can see there are no settings to make adjustments to the shadow, so results would be washed out…

and the surface plane would show in any reflected surface…

not really great, but thankfully it is an easy fix. first lets deal with those reflections.

Just add a material…

Yep its that simple, the shadow catcher doesn’t have to be a blank plane, you can add a material to it just as you would any other object, and it will still be treated as a shadow catcher in the view-port and render. That is to say it will be invisible except for the shadow, only now, the surface will be reflected as whatever texture is applied!

Simply switch to camera view so you can see the scene from the cameras perspective. Then with the shadow object selected enter edit mode and select all the vertices and press U – project from view. Open a uv image editor window and select the background image you want the shadow catcher to reflect and make sure it is lined up the same as it appears in the camera view. Then simply create a new material and assign the image texture.

Fixing the strength.

This is just as simple a fix, but first we need to re-order a few things. First move the shadow  catcher onto a new layer by selecting it and pressing M ( in object mode). Then you need to set up your layers. Create a new layer in the render layers tab and set them up to only render the objects on their individual layers.

We wont worry about passes for this lesson, the default set up is fine.  In the render settings under film, ensure transparent  is checked, then render the image.

now all we need to do is connect the render layers  together with an alpha over node. Then connect the background image with another alpha over node. Remember, things in the background plug into the top image slot on the alpha over node. then make sure you have the  last alpha over connected to the composite output node. Ok, onto the magic.

You’ll notice that the render layers node has an alpha channel output. We are going to use that output from the shadow layer and plug it into a colour ramp node ( add -converter – color ramp ). Now, we need to connect the colour ramp back into the shadow image and we do this by plugging the image output of the render layer into a set alpha node ( add – converter- set alpha).  Now all we have to do is slide the  white marker on the color ramp to increase the strength of the shadow and the black to increase the sharpness.

It is possible at this point  that you may experience some fringing between your model and its shadow, so drop in a dilate/erode node (add- filter – dilate/erode) and increase the distance by one or two steps. To finish, drop in a blur  ( add-filter-blur) and just blur the shadow by one or two pixels just to soften the harsh edges. and we are almost done. You’ll notice that the shadow is pitch black so we want to add in some transparency, and we do this by reducing the factor between the model render layer and the shadow render layer. VERY VERY SLIGHTLY!! you only need to adjust it by as little as 0.005 to have a big effect. In this scene iIreduced the fac from 1.0 to 0.991 to get the correct shadow, any more and the shadow becomes too transparent to be realistic.

And there you have it. perfect shadows with the new shadow catcher feature.

Go make cool things! But before you go remember to hit that subscribe bell to your right and get instant notifications when we release a new lesson.

See you next time.

Share this: