How to create a Shadow Catcher in Blender (Cycles)

shadow-catcher

Setting up a Shadow Catcher in Blender is a bit more tricky than in other applications, but nevertheless straightforward if you know what you’re doing. I certainly did not when I first tried it, but thanks to this short YouTube video by Nonsense Blender Tutorials, I was able to set this up.

Here’s how to do it:

Scene Setup

Let’s use the the default scene with the cube and add a plane. Move the plane to the second layer (by pressing M 2). SHIFT select the first two layers so that both objects are showing together.

Perhaps adjust the light a little and make it slightly brighter.

screen-shot-2016-11-25-at-09-27-13

Render Layer Setup

Now we need to tell Blender that we’d like it to render our image in two passes onto two separate layers: one will be our object, the other one just the shadow on our plane.

To do that, head over to the Render Layers tab in the Properties Palette and create a second layer (one should already be there). Let’s name one Object and the other Shadow Catcher so we can tell them apart.

screen-shot-2016-11-25-at-09-21-59

See those little layer tabs underneath this list? With those we can tell Blender which pass goes onto which layer. Under Scene, SHIFT select the first two layers, just like we did in the scene.

Under Layer, we need to associate our Object Layer with the first tab, and the Shadow Catcher with the second tab. So select your Object Layer first, then hit the first box under Layer. Now select the Shadow Catcher layer and choose the second tab under Layer (it’s more complicated to explain than it actually is).

Further down there’s a Passes section. Tick the Shadow box here so that Blender does a separate render pass just for the shadow.

screen-shot-2016-11-25-at-09-22-13

Render Setup

In the Render Tab in the Properties Palette (the one with the little camera icon), find the Film section and choose Transparent. We need this so that Blender will render our background transparent rather than dark grey.

screen-shot-2016-11-25-at-09-32-15

We’re done with the setup now. Hit Render and see Blender go to work with two passes. Let’s combine these into a single transparent image that will show just the object and its cast shadow.

Compositing our layers

Split your viewport and switch to the Node Editor. Make sure it’s set to compositing mode (second icon) and select the Use Nodes option.

screen-shot-2016-11-25-at-09-35-11

You’ll see two nodes now: the first Object render layer connected to a Composite node. Select this node and duplicate it with SHIFT + D. Change this new node to Shadow Catcher, which makes it display our second render layer. Now we have access to both layers that Blender has rendered for us.

screen-shot-2016-11-25-at-09-39-15

Now we’ll create a Math Node (Add – Converter – Math) and set it to Subtract. We’ll connect the Alpha of our Shadow Catcher node to the top value input, and the Shadow output to the second input.

screen-shot-2016-11-25-at-09-40-25

Next we’ll create a Set Alpha node (Add – Converter – Set Alpha) and connect the Subtract node’s output to the Set Alpha node’s input.

Now we’ll create an Alpha Over node (Add – Color – Alpha Over) and connect the Set Alpha node’s output to the top input of the Alpha Over node. Connect the Alpha Over’s output to the input of the existing Composite node.

screen-shot-2016-11-25-at-09-47-09

And finally, let’s connect our first Render Layer node (Object) to the bottom input of the Alpha Over node. This will now compose both render layers the way we want them to look, i.e. displaying a transparent image of just our object and the shadow being cast (minus the plane).

Here’s what the full node setup looks like:

screen-shot-2016-11-25-at-09-48-56

Now we can use our render and add it to our favourite backgrounds. To control the intensity of the shadow being cast, adjust your light source accordingly.





Add your voice