Hey guys! Today’s tutorial is about how render Transparent Shadows in Blender Cycles. I have seen multiple tutorials explaining this, and most of them work, but they sometimes do not work properly or are lacking important features. If you didn’t know, Blender Internal can render Transparent Shadows too (Check out my tutorial on it HERE! 😀 ) (but it’s much easier than Cycles. 😉 ) The reason I made my own Node Setup for rendering Transparent Shadows in Cycles is because I watched Blender Tutor’s “How to Render a Shadow Pass in Cycles” tutorial. Well, that didn’t work for my scene, because he used a “linear mask”, and I could not get it to work with my scene because mine was a lot more complicated than his scene. So, I launched Blender and started playing with Nodes.
Let’s get started!
For this tutorial, I’m going to use Suzanne the Monkey as my example model. First, I added it (Add>Mesh>Monkey), deleted the default point lamp, created a sun lamp, and moved my camera.
NOTEWORTHY: Any kind of light source will work for this tutorial. Mesh Lamps, Generate Lamps (like Sun, Point, etc.), or any other light source will work. If a shadow is cast, this node setup will render it.
For the monkey to cast a shadow, I need to add a Plane under the model for it to cast a shadow on. Adding a Material on this plane is not necessary, but you can add it if you want.
Then, I’ll move the plane to Layer 2. To do that, select it, press ‘M’ and then click the layer you want (or press 2 on your keyboard). Once that box has gone away, show layer 2 in the viewport by holding Shift and clicking Layer 2. (This will show layers 1 and two).
I will need to go to the Render Layer Settings . On the render layer that contains the monkey, find the Mask Layers section and select the second layer in it. This will tell Cycles not to render the plane, but will still let it cast a shadow on it (if you understand that 😛 )
Now, we need to create a new Render Layer. This Render Layer will contain the plane for the shadows. Let’s name that Render Layer “Shadow”. There are many things we need to do in this layer. First, we need to tell this Render Layer what layer in our scene to render. Under the “Layer” header, select only the second layer (the layer with the base plane). Then, we need to tell Blender which passes to render on this Render Layer. Under the Passes header, make sure “Combined” and “Shadow” are selected.
Now for the Nodes (this is the fun part 😉 ). First, you need to go the the Node Editor. The easiest way is to go to the top pane, and use the interface changer.
once there, make sure you check “Use Nodes”. You will need 2 Render Layer Nodes. One for the main part of the scene to render (which will probably be called “Render Layer“), and the other for the shadow plane (which we named “Shadow“). We will also need a Mix node (which we changed to Multiply), Set Alpha node, Invert node, Alpha Over, and of course the Composite node.
I cannot explain exactly what every node I use in this setup does (it takes a bit of time and it would probably be difficult to explain in writing), so I have provided a picture of the node setup below.
Make sure that you follow this node setup exactly, because if the colors in the Multiply and Set Alpha nodes are not exactly white, the Shadow Pass will not work correctly.
This is the final result obviously, it’s not the same model I used in the tutorial. I lost that model I used at the beginning, and I think you’d like to see something other than a monkey head for once. 😉
If you want a softer shadow look, or have Ambient Occlusion on, you can use the “AO” pass instead of (or along with) the Shadow pass. All you have to do is select AO in the render layers and connect it in the Node Setup where the Shadow would be. If you want to mix the AO and the Shadow passes, just plug the Shadow pass and the AO pass into a a Mix Node (set to Multiply) then plug it into the other mix node (set to multiply). (See picture below)
There are a few issues with this Node Setup, but they are unable to be fixed because of the way Cycles renders shadows. On the edges of the Shadow plane, there is a small outline due to the fact the the plane has a shadow on it’s edge somehow (like I said, it’s the way Cycles renders shadows). The only way to fix this is to make sure the edges of your shadow plane do not show in the render (by scaling it so large that the edges are not seen in the camera). And that doesn’t always work either.
I hope this tutorial helps with Cycles! It helped me a lot with my renders. 🙂