15
$\begingroup$

I'm trying to make a logo that will be on the header of a website. What I'd like to achieve, and the reason I'm using Blender, is the projected shadows on the background looking perfectly real (as opposed to doing a drop-shadow in Photoshop).

The only thing is, the background has to be transparent because the website might use different background colors / gradients that make it impossible to match with the exported 3D background.

I made this dummy file (not the real logo... duh!):

enter image description here

If I use the file as is, the grey borders of the image will be impossible to match with the website's background color. Here what I want:

enter image description here

So obviously, I tried masking the plane, which made the shadows disappear. I tried having a plane set to glass, which didn't work either. And I looked around for a similar question, but didn't find one.

I am not trying to render an object without a shadow, or a shadow without the emitter object. I've seen this question which has a very difficult solution to this problem, and this one that is very similar but in Blender Internal. This one is similar too but has never been solved. I'm only a beginner at Compositor, and I'm trying to learn more any chance I get, so any solution in Compositor is welcome if detailed enough. Although if there's a simpler or faster way, it's welcome too!

.blend file:

$\endgroup$
4
  • $\begingroup$ You could try to use the same compositor setup as is used for camera tracking. $\endgroup$ Feb 23, 2016 at 23:16
  • $\begingroup$ Hello! And thanks! Do you mind explaining a bit more or giving a link? $\endgroup$ Feb 23, 2016 at 23:27
  • 2
    $\begingroup$ If I understand this correctly what you need is a shadow catcher. Related (maybe duplicate?): blender.stackexchange.com/questions/14898/… $\endgroup$
    – user1853
    Feb 24, 2016 at 0:46
  • $\begingroup$ Well, yeah, this is exactly what I'm looking for! And, at the same time, I'm looking for ways to do this in Cycles and not BI, so not exactly the same thing, and I don't think a duplicate... $\endgroup$ Feb 24, 2016 at 12:05

2 Answers 2

25
$\begingroup$

UPDATE:

As of Version 2.79, there is an option to make an object become a shadow catcher in Cycles.

enter image description here

enter image description here

From the release notes

This option will make object to only receive shadows in a way that it could be alpha-overed onto another image.

The workflow is following:

Enable Film: Transparent.

enter image description here

Then (Quote from the develpoer's notes)

Create an object which matches real-life object on which shadow is to be catched.

Create approximate similar material on that object.

This is needed to make indirect light properly affecting CG objects in the scene.

Mark object as Shadow Catcher in the Object properties. Ideally, after doing that it will be possible to render the image and simply alpha-over it on top of real footage.

Once the plane has been marked as a shadow catcher, just render!

Again from the release notes

It is to be noted that shadow catcher objects will interact with other CG objects via indirect light interaction. For example, shadow catcher will be reflected in the glossy surfaces.

enter image description here


OLDER ANSWER:

You can do a shadow catcher using a shadow pass and different render layers to create an alpha channel for the scene:

enter image description here

  • Move the plane object (shadow catcher) to layer2.

  • Make a copy of the other objects and move them to layer 2.

    The idea is that on layer 1 you only have your objects but not the plan, and on layer 2 a copy of your objects and the plane that will act as shadow catcher.

    enter image description here

  • On all of the objects in layer 2, except for the shadow catcher plane, disable Ray visibility for camera. You want the plane to be visible, but the other objects should be transparent to camera and projecting shadows on the plane:

    enter image description here

  • Make sure your lamps and camera are active in layers 1 and 2.

    enter image description here

  • Set up two render layers:

    One for the objects in layer 1 that excludes information from layer 2.

    A second render layer for the shadows that includes a shadow pass and excludes layer 1.

    enter image description here

  • Enable Transparent on the Film section.

    enter image description here

  • In the compositor you can use the shadow pass to alter the values of the alpha channel of the object's layer.

    Add an invert node to shadow pass and plug the result as factor on a mix node (in add mode). Plug the alpha channel of the object's layer to the top socket and leave the lower socket empty.

    enter image description here

You can control the transparency of the shadows by changing the color on the empty socket of the mix node. If you make that color white the shadows will be fully opaque, if you make it black you'll have no shadows.

Alternatively you can use the values from the shadows layer and the transparency of the shadows will be set using the values from the original scene:

enter image description here

For softer shadows you can add some blur:

enter image description here

$\endgroup$
3
  • 2
    $\begingroup$ This answer is STELLAR. $\endgroup$
    – yPhil
    Jul 21, 2016 at 18:28
  • $\begingroup$ Just wanted to thank you especially! This answer is awesome! $\endgroup$ Mar 6, 2017 at 19:09
  • $\begingroup$ Thanks for updating this with 2.79 Shadow Catcher option, you rule cegaton! $\endgroup$ Jul 3, 2017 at 3:32
1
$\begingroup$

For the plane...

  1. UV Unwrap by hitting u >> Unwrap.
  2. Go into the image editor and create a new image, and save.
  3. Go into the node editor and add an Image Texture node.
  4. Make sure you get into the drop down, and select the saved uv image.
  5. On the render panel, goto the Bake section, and select "Shadow" in the Bake Type dropdown.
  6. Click "Bake"
  7. for the planes material mix the material between a diffuse and a transparent shader, using the baked image as the factor with it set to "Non-Color Data".

Here's the screenshot of the effect:

enter image description here

Use a gradient on the shadow such as this to head toward the effect that was in your question. You can control the color transparency on the ramp color selections per color.

Then bring into the compositor and key out the pure black color.

enter image description hereNOTE: Using Cycles Render


Non Shadow Bake Version - See Below


Here is the Non-Bake Version of the same basic thing. Cycles materials could be tweaked to get a better solution, and great news, the shadow pass does not have to be used either.

Blend File

$\endgroup$
7
  • $\begingroup$ It would be nicer to have a solution without any baking $\endgroup$ Feb 24, 2016 at 2:28
  • $\begingroup$ I believe that you could render out the shadow pass information separately, and use a very similar technique in the compositor instead. It's a little unproven on my part, but I'm almost certain this will work. If I get a chance I will prove it and include it as an alternate in an edit to the answer. $\endgroup$
    – Rick Riggs
    Feb 24, 2016 at 2:49
  • $\begingroup$ I followed @RickRiggs's answer and what happened was the result looks 10% transparent and still mostly white/grey. "2. create a new image" : using default settings? Also, I don't always have "use alpha" as an option on the right hand panel of the nodes setup like you do. $\endgroup$ Feb 29, 2016 at 7:30
  • $\begingroup$ I modified your file, and applied my answer to it. The modified blend $\endgroup$
    – Rick Riggs
    Feb 29, 2016 at 7:53
  • $\begingroup$ The weird thing about rendering these images, is that it adds the black color to the alpha channel. So in Gimp/Photoshop, you can still isolate it, and clear the color pretty easy. $\endgroup$
    – Rick Riggs
    Feb 29, 2016 at 7:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .