Simple Cycles Shadow Catcher

After looking around the internet for cycles shadow catchers I was unable to find anything that I could properly use, they all either involved specific ways to set up the environment nodes or had to be hand tweaked and was difficult to get a match between the shadow plane and the background. Because of this difficulty I decided to have a go at creating my own shadow catcher.

The first thing that is needed is to set up the rendered objects and the shadow catcher. The shadow catcher is a simple plane placed at ground level. In order to mask objects and shadows, pass indexes must be assigned under the ‘object’ tab in the ‘properties’ window. For this tutorial I have decided to give the shadow catcher a pass index of 1 and all the objects on my truck a pass index of 2.

The next step is setting up the shadow catcher material. It is set up in the following way:


The colour of the diffuse texture depends on the colour of your environment, as if they don’t match then the bounced light will not look correct. The two mix nodes are to ensure that the ground plane does not appear in any reflections.

Once the shadow catcher has been set up the different render layers must be set up. There are three different render layers used and they are set up in the following way:


The first render layer is the ‘Main Scene’ layer. This is exactly the same as the default render layer, with the exception of the Object Index pass being checked.
The second render layer is the ‘Shadow Catching’ render layer. As with the main render layer, the Object Index pass is checked as well as the Shadow pass being active. It is important that this render layer only has the layer that your shadow catcher and any lamps are in being active.
The last render layer is the ‘Environment’ layer. It is important to ensure the active layer is empty. I have set the samples of this pass to 1, as it is not actually rendering any objects.

Once these three render layers have been set up it is time for composition. This is how the layers are combined:


This image is rather self explanatory though there are a few thing you need to know. The value node that is plugged in to the multiply is there to control shadow strength, the higher the value the darker the shadow. The colour circled in white is the colour that the shadow catcher is when not in shadow. The best way to find that colour is to look at the shadow pass (If I can work out how to render the shadow plane without any shadows, I will be able to divide by that image rather than a set colour). The white arrow can be connected to the final composite or be plugged into your existing composition node tree as the original image.

So that’s how I have set up my Cycles shadow catcher for HDRi lighting. The one improvement that needs to be made is to render another pass that shows the shadow plane affected by lights but not shadows, to avoid the need for colour guessing.
If this has helped you please drop any renders in the thread, I’d love to see what people can do with this

Attachments




Here is a before and after shot when using the shadow plane. The background is setup using smart IBL and one sun lamp.
Before:

After:


Although this is not the best HDRi image to show off the shadow catcher, the truck is noticeably more grounded in the second render

Attachments



For a shadow catcher, this is the most versatile solution I’ve found: https://www.youtube.com/watch?v=k7gKzgvFiGM

It works for reflections too, and with tweaking, you can separate your shadow correction and reflection correction. It’s now one of my default node setups.

With a tiny bit of extra work, and a separate scene, you can do the background too in the same render.