6
$\begingroup$

I'd like to make a glossy surface which reflects objects above it, but that also reflects a transparent background in the final render.

So in effect, the final render would contain only the reflections, not the surface itself.

Is this possible please?

$\endgroup$
  • $\begingroup$ Yes, mix a Transparent and Glossy shader. However reflections will be captured from all sources $\endgroup$ – VRM Mar 31 '15 at 15:18
  • $\begingroup$ This sort-of half works - there is transparency in the layer, but it's not completely transparent. As one would expect I suppose - it's half-glossy, half-transparent. Did I miss something? $\endgroup$ – Mark Smith Mar 31 '15 at 15:41
  • $\begingroup$ It is reflecting the world settings $\endgroup$ – VRM Mar 31 '15 at 15:46
  • $\begingroup$ Just found the solution, posting answer $\endgroup$ – VRM Mar 31 '15 at 15:57
  • 1
    $\begingroup$ Could you provide a Sketch of your desired setup, please? $\endgroup$ – Samoth Jan 25 '16 at 9:09
8
$\begingroup$

You need to use a Transparent shader, and a Glossy BSDF shader, combined with an Add Shader, not a mix shader.

Using the Add shader gives a perfect result:

Nodes:

Node Setup

Result:

Final Result

Although you should normally use a Mix shader (greater realism) this is a perfect use case.

Here is a comparison of the two methods:

Comparison GIF

$\endgroup$
  • 3
    $\begingroup$ this works only in the viewport but not for rendering! $\endgroup$ – user1853 Jan 24 '16 at 20:57
  • $\begingroup$ I never realised this! Indeed an interesting fact, I wonder what the real solution then is? $\endgroup$ – VRM Jan 24 '16 at 21:04
  • $\begingroup$ @troy_s No this doesn't work even with associated alpha. Because when compositing this the reflection will not be composited correctly (over light or white bacground for example). The alpha channel is only the physical object, what you need is also a mask around the reflection. i.stack.imgur.com/QKFKs.png I don't know why people upvote this. $\endgroup$ – Jaroslav Jerryno Novotny Jan 26 '16 at 8:32
  • $\begingroup$ It's work for me in rendering mode ! $\endgroup$ – mcbjam Feb 10 '16 at 6:02
  • $\begingroup$ Sorry. It works only if the the roughness of the glossy shader is 0 $\endgroup$ – mcbjam Feb 10 '16 at 6:24
2
$\begingroup$

This solution does not require compositing, and is actually very simple. Think of the ground plane as being a plate of glass instead of an invisible mirror, transparent, yet glossy. So we will use a glass shader and not a glossy mixed with a transparent node.

Plug a Light path node into the IOR socket of the glass node to start with. The light path reference comes from a forum discussion I saw on BlenderArtists (unfortunately, I don't have the link presently, I'll add it if I come across it again). Add a transparent shader, then plug the glass shader into the top input of a mix node, and the transparent into the bottom input. Run this out to the output, render, and invisible, reflective surface! enter image description here Node setup:

enter image description here

Example .blend

$\endgroup$
  • $\begingroup$ I get the same issues as with all of the proposed answers involving any kind of transparency: the dark parts of the reflection become semitransparent... $\endgroup$ – user1853 Jan 25 '16 at 15:54
1
$\begingroup$

You can achieve this relatively straightforwardly using render layers and the compositor. Here's the result I was able to get. It looks much better over a black or grey background than white.

final render

With lots of simplification to the node setup it's easy to mask out just the reflection.

just the reflection

Set up two layers in your scene. The first layer will be your main render, and the second layer will be used to mask out the reflections. Make instanced duplicates of all of the scene objects (Alt+D) and move these duplicates to the second layer. Keeping all of the duplicates selected, change the material properties to be linked to object instead of to data and copy that setting to the other selected scene objects using the context menu. Add a new material to the active duplicate and set it up to be Emission, white, strength 1. Link this material to the other scene objects (Ctrl+L, Materials) so that they're all emissive. At this point the first layer should look something like this:

layer 1

And your second layer should look something like this:

layer 2

Next, make a reflection plane and put a copy of it on each layer. It can be instanced if you wish. This is the material I used for the reflection plane:

reflection plane material

It's set up to show a glossy surface to the camera and to be invisible otherwise. This prevents it from affecting the rest of the scene's rendering. Of course, if you want some other behavior, you should feel free to make it happen.

Now that the scene is set up, it's time to set up the render layers. There are two, one for each layer in the scene.

Render layer setup

The first layer is set up to be a beauty render. It excludes the second layer and uses the environment IBL to get a good final render. I've enabled the glossy indirect pass as well, although I suspect it might not be necessary for your use case.

The second layer is set up to mask the scene and its reflection, and it's set up to exclude the first layer. It's limited to ten samples because all of the shaders in the layer resolve quickly, so it's cheap to render. I've enabled an emission output that produces a mask for the scene and a glossy direct and glossy color output that produces a mask for the reflection. Make sure to turn Use Environment off, otherwise you'll see the reflection of the world in the reflection plane which isn't helpful.

In the composite, you can get the mask for the scene with the Emit output of the reflection mask layer.

Scene mask

You can get the mask for the reflection by multiplying glossy direct contribution by glossy color. Just glossy direct is close, but isn't antialiased in some areas.

Reflection mask

You can get a mask of the scene and the reflection together by enabling and using the combined pass for the mask layer.

From here you can use that mask to get an image of just the reflection:

Just the reflection

Or, something more complex like the original render plus the reflection with the reflection mask multiplied by the value of the reflection.

Complex example

The setup also works pretty robustly with curved reflecting surfaces. Here's a monkey, which I used the glossy indirect pass to get the color of since I didn't want the direct specular highlights it was picking up.

Reflection of the balls on the monkey

$\endgroup$
1
+200
$\begingroup$

I am sorry, but the only "correct" solution is to render a custom mask as a secondary render to your scene like this:

enter image description here

Where you give all the objects a white emission shader, the ground a sharp glossy shader and you uncheck the environment from render-layers.


Explanation:

For this to work in one render layer the ground shader would have to react whether the ray reflects environment or reflects an object. Which it cannot, because for the light-path node all the ground plane is one ray type, has same transparency depth and same ray-length.

For multi-layer solution utilizing the same objects you would have to overwrite their material with a white emission material in the second render layers and you would have to have a choice to exclude the ground plane from the overriding. Which is sadly not possible.

Multi-layer solution that would work needs copies of objects with a different material (white emission) on separate scene layer which is same like a dupli-scene for the mask or a second render for the mask.

So the only option is to use a compositor and key the reflection objects with some color-key. Which put's a restriction on those objects to not have that color.

$\endgroup$
  • $\begingroup$ @troy_s white 1.0 emission is special because with it you get a perfect black and white mask to cut your objects with reflections from the render. You should try the transparent + glossy solution with associated alpha and also composite it (pick a bright background) and you'll see. $\endgroup$ – Jaroslav Jerryno Novotny Jan 26 '16 at 8:35
  • $\begingroup$ The original wanted to remove the object itself, hence the original answers. Second, the idea of using an emission is a tad of a hack, as it won't work if your display referred transform is anything other than a 1.0 hard cut. It would seem more prudent to actually glean the occlusion. Surely there is a method to impact the transparent node with a light path. $\endgroup$ – troy_s Jan 26 '16 at 19:01
  • $\begingroup$ @troy_s Yes it would be nice with light path if it could be done..it cannot for reasons in my answer. Semi-transparency in reflection is a problem than only keying can deal with. $\endgroup$ – Jaroslav Jerryno Novotny Jan 26 '16 at 19:38
  • $\begingroup$ Well no, you don't need to key. The emit hack works for occlusion, and the emission is handled via the RGB. $\endgroup$ – troy_s Jan 26 '16 at 20:25
  • $\begingroup$ @troy_s and if there is refraction? Then you have to craft the mask with lot of work (build those emission shaders tailored to each object). Keying is the easier thing. Yeah I shouldn't say that only keying can deal with it, true. $\endgroup$ – Jaroslav Jerryno Novotny Jan 26 '16 at 20:28

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.