Transparent reflector

Hi,

I’m trying to get a plane to show only the reflection and shadow of an object over it and have everything else transparent. For the plane I’m using a simple material with a mix shader (transparency and glossy) but I’m still getting the background reflected on the plane, so the full transparency is not as I need (attached example).


Bottom line: I need to get a PNG output with object + reflection + shadow and transparent background.

Any help is much appreciated. Either to a solution or a path to follow :slight_smile:
Thanks in advance.

It’s much easier done with multiple render passes and the compositor.

In fact, my (free) plugin, and no, not promoting, will do this. (https://github.com/RokenPrice/Shadow-Catcher)



Hi there Roken,

Seems to be exactly what I’m looking for but I can’t make it work… I’m getting an error in console window after installing it.


I’m running version 2.78c on a windows 10 x64 machine. Any thoughts what the error may be?

Sorry, nevermind the last message… I clicked “save as” and the script had tall the html trash in it.

Got a clean code file installed and no errors but still nothing new in Blender and it doesn’t even show in Add-ons panel! Do you have any additional info about its use?

Thanks again.

Ok, I got it working… probably encoding was not the correct in the .py file.

This is the approach I was thinking - different layers and passes and then a final compositing - but I thought it might be easier with just a material set-up. One last question, do you have a sample file (like the cube you posted) so I can understand the layers and objects relations? I tried a couple variation and it’s not working.

Thanks

Found a youtube video with your brief explanation and got it working. Works perfectly if (a big if) you have a solid background or image as final input. Otherwise, if you need a complete alpha (or no background) as final output, it just doesn’t work.

On the final nodes, if you set a background input as this:


Works flawlessly but, if you change the last input to transparency or a color with alpha=0, it messes everything:


Your work is great, but maybe you should try to cover this issue in a future update.
Any additional help for getting a PNG with alpha as final output would be great! Thanks anyway.

OK, won’t let me upload the blend, so a quick setup.

Create the cube, a light and the plane. The plane will be the shadow catcher. Assign a material to the plane as follows (NB: You can set up your diffuse/glossy however you want. The only part specific to the shadow catcher is the transparent mix and light path):


The transparent part prevents the plane reflecting in your other objects.

Move the cube to layer 1, the plane to layer 2, and the light to both layer 1 and 2. Enable layer 1 and 2 for render. Enable the shadow catcher plugin from the tool shelf, and the background if you need it.

Hit render.

NB. In the compositing node setup the Multiply node after the RGB curves is where you set the background. If you change the alpha on the unconnected colour you can get a complete alpha mask. Plugin a background image and it will composite on top of the image.

There are some settings on the tool shelf and in the compositor window (toolshelf for background image, and compositing to adjust the strength and blur of the shadows).

Also, video for usage from an old version at https://www.youtube.com/watch?v=M2LgAytYRts. Stuff I say I’ll automate in the video has since been automated, and the tools in the compositor simplify tweaking the final look. You need to ensure that the compositor nodes button is selected for the tools to have any effect.

Till there I got everything working. My only problem is that I need to output a completely transparent PNG with the reflection and the shadow. In the last nodes, if I disconnect the background and use a simple RGB color, still works… but if I change the alpha of that color to 0 (or below .200) the shadow and reflection disappear.


I understand that being a multiply node, if there’s nothing there to “multiply”, the result is 0 but that’s what I need. Any thoughts if this is achievable?

I’ve just tested, with variations on the node setup, and you’re right. At low alpha values the shadows/reflections disappear.

I have no idea why, but let me think on it.

I will also try a couple more steps after those last nodes - trying to isolate the shadow and reflection with alpha - and will update here if I manage to do it right. So far, I can do it but the reflection vanishes away!

Thanks a lot.

Hi there,

I managed to get a solution to have both reflection and shadow over a complete transparency or a color background. It’s not full proof but works with most settings I tried (colors with no alpha, colors with some alpha, etc). It’s basically the known method of isolating a shadow with render layers, except that I added a couple nodes to “extract” the reflection and then mix all the separated images into one.

So, to whoever has the same problem or needs help with this, I’m posting a sample and explanation of the main parts.

  1. Set a scene with a plane that will be the reflector and shadow catcher, add a light (or lights) and the object(s) that will be reflected into the floor.

  2. Move the floor plane to a different layer.

  3. Make sure the light(s) are in both layers (the one with the objects and the one with the floor)

  4. Set 3 different render layers:

  • “mainObjects” set to render only the layers where the objects are;
  • “floor4shadowAndReflection” set to render only the layer where the floor plane is. IMPORTANT! this layer must include Shadow pass, Glossy Direct and Glossy Indirect;
  • “floorClean” set to render only the layer with the floor plane and excluding the layer where objects are.
  1. Set composite nodes as below and hit render. Should work without a problem… but a few tweaks may be needed depending on the objects, scene, purpose, etc. Also attached a .blend file.

Here’s a print screen with the nodes and final result image with a solid color background:


And the same but with a completely transparent background (what I need) - for this, in the last node (AlphaOver) the mixing color must be rgb 0,0,0 alpha 0.


Thanks for the help and I hope someone finds this useful too.
Here’s the .blend
shadow_and_reflection_isolated_with_alpha.blend (569 KB)