26
$\begingroup$

I am superimposing CGI over video footage, and have run into a problem in making materials for objects that act as 'shadow catchers'.

Essentially I want a shader that is shadeless—like an emitter—but catches shadows and light from other objects. This is so I can reconstruct objects in footage so other objects in the scene interact convincingly with them.

Here's an overcomplicated diagram to illustrate my point: The problem

(In this particular scenario, the problem could be glossed over by using RGB curves, but that is definitely not the case with more complicated scenes)

Isn't this a common situation? How to the real guys do it? Thank you.

(I am welcome suggestions of other ways of doing this.)

$\endgroup$
  • 2
    $\begingroup$ Yep, this is one of those features that's been on the wanted list for a while. It'll be added sometime, hopefully in the near future.. (though AFAIK no one is currently working on it). $\endgroup$ – gandalf3 Dec 10 '14 at 4:33
  • 1
    $\begingroup$ @gandalf3 Well, now there is someone working on it. See developer.blender.org/D1788 $\endgroup$ – PhoneixS Oct 4 '16 at 15:21
  • $\begingroup$ Related: blender.stackexchange.com/q/518/28015 $\endgroup$ – JakeD Apr 28 '18 at 2:37
2
$\begingroup$

Note: this solution may not work for everyone...you give up some control because changing the appearance of the shadow can only be done in the compositor AFAIK. See the end of my answer for more details.


There is a simpler way to build a basic shadow catcher now, thanks to Blender 2.78c. There is no longer even a need for a material, just enable "Shadow Catcher" in the Cycles Settings panel in the shadow catcher plane's object settings.

enter image description here


For more advanced tweaking of the new shadow catcher, you can add a material to the plane as detailed in this article:

https://cgjam.net/how-to-use-the-shadow-catcher-in-cycles-2-79/

See here for more info, or the section in the Blender manual here.

enter image description here

This image literally took less than ten minutes to make thanks to this free model by MAC2001, this free model by hasapeta, Greg Zaal's amazing, free HDRIs, and this new Blender feature.


This solution is not easily adjusted, however, as Jeroslav notes in the comments:

Unfortunately this method is very limited and will provide only black shadows, no color bleed...For someone it may work, but this does not produce correct result in general.

You can actually get somewhat more control over this shadow method by putting the shadow catcher on its own render layer and playing with it in the compositor. In this case, I put the shadow catcher on a different layer that had the layers that my cars were on as a mask layer. Enable the environment pass for one of the layers so you can get the HDRI in the compositor.

Here is a possible compositor node setup (note that I just made this so that it looks right to me, this is not technically "correct"). In this case, I gave the lefthand value of the compositor a slightly bluish tint as well as making it brighter (of course) to change the shadow color.

enter image description here

enter image description here

Result:

enter image description here

$\endgroup$
  • 3
    $\begingroup$ Unfortunately this method is very limited and will provide only black shadows, no color bleed. You should also include the negatives in the answer so it does not seem equivalent. For someone it may work, but this does not produce correct result in general. $\endgroup$ – Jaroslav Jerryno Novotny Apr 28 '18 at 13:31
  • $\begingroup$ @JaroslavJerrynoNovotny I've played around with it some more and edited my answer... $\endgroup$ – JakeD Apr 28 '18 at 14:18
29
$\begingroup$
  • Divide objects into 2 scene layers, move actors (Suzanne) onto layer 1, move backgrounds onto second layer, place lights into both of them.
  • Setup 3 render layers - First for layer 1, second for layer 2 and third for layer 2 with layer 1 excluded:

Scene render layers

  • Render it with transparent bacgrounds, it will produce results like this:

Layer 1 Layer 2 Layer 3

  • In compositor divide render layer 2 (BG_With_Shadow) with 3 (BG_Clean) - you now have a shadow to multiply over your backdrop and layer 1 to composite into backdrop:

Nodes Shadow

$\endgroup$
  • 2
    $\begingroup$ Instead of the Subtract node, I recommend the Divide Node. The goal is to multiply the result with any image: So bg_with_shadow needs to be divided by bg_clean to get the factor, bg_clean needs to be multiplied with to get the bg_with_shadow version. $\endgroup$ – Random Citizen Feb 7 '17 at 21:47
  • 2
    $\begingroup$ @RandomCitizen Yep you are right. Divide is not only recommended it is needed, the subtract-invert math is wrong. Thanks for pointing this out. $\endgroup$ – Jaroslav Jerryno Novotny Feb 7 '17 at 22:17
  • $\begingroup$ I tried this, and instead of getting white I got gray. The solution was using Default view in color management. I suspect the log color of filmic is to blame, but I don't know enough to have filmic and true shadow catching for now. Edit: I was using photoshop to composite the shadow and object (for a class) and was noting that the grey was affecting the whole image from a multiplication blending perspective. The visual grey was indeed grey to photoshop. Using EXR's solved my problem and I was able to use filmic. $\endgroup$ – Boris N Feb 22 at 22:37
  • $\begingroup$ @BorisN please ask this as a question and post your own answer. Others with a similar issue can benefit from your experience, and you can also get other answers on the same topic. $\endgroup$ – cegaton Feb 22 at 23:56
0
$\begingroup$

One little idea: use built-in camera tracking. Then scene will be prepared for you by Blender. This is, I think, the simplest way. Maybe it won't work in your case, I don't know!

Camera tracking in blender has the ability to set up the scene. Then it writes everything you need into the composer, and just by creating the ground plane and extruding it, you should receive the result of shadow catcher. Basically, the ground plane in camera tracking is the shadow catcher.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.