Transparency in refraction shaders

Hi,

is there a way to save the transparency of refracton (and/or glass) shaders to the alpha channel?
To explain this better I attached a screenshot of a rendered image in the Image Editor.

  • there is a black cube with a transparency shader
  • there is a cylinder with a standard glass shader. Nothing is changed. The color is set to white.
  • there are two green spheres behind the cube and the cylinder
  • the background color of the scene is set to orange

As we know, everything that has these checker boxes in the Image Editor is saved to the alpha channel of, for example, a png or tif file.
On the cube we can see that transparency will be saved to the alpha channel everywhere it is ot blocked by the green sphere.
On the cylinder on the other hand we can not see any transparency. Only the orange of the background shader.

So is it possible to get alpha transparency on refraction and glass shaders somehow, perhaps by setting the background shader to transparent or something like that? I searched for the transparency shader in the node editor but it doesn´t seem to exist for backgrounds.


Refractive shaders render opaque in Cycles.
AFAIK there is no way around that other than avoiding refractive shaders in the first place.

And I don’t quite see what sense it would make to render refraction with alpha: It’s the point of refractive shaders to bend the light and to visually distort objects seen through them. But how would you translate that into flat alpha channel? You wouldn’t, because it would look fake as hell.

Rendering refraction transparent makes only sense whenever the refraction is practically unnoticeable. And if it is, why bother with a refractive shader in the first place that will only increase your render time?

I use that feature in VRay all the time.

If you´ve got a refractive surface and render it with alpha your compositing guy who recieves the rendered files can put whatever background behind it and you don´t have to wait with rendering until the customer/boss/art director has decided which background they want. If the background is just a color it works perfectly. And often, even if it is something more complex it often doesn´t matter if it doesn´t get distorted. It looks fine anyways.

Yeah, I’ve been asking myself the same question and tried with a LOT of workarounds but basically refraction is opaque :mad:

I’m with Lumpegnon here. For advertising images, specially product shots, you often have to make changes to the backgrounds after the rendering is done; and clients ask for this kind of changes when the ad campaign is already out, so you have just minutes to make the changes, having transparency for the refraction would be incredibly useful to avoid several hours long re-renders…

I don’t think that’s absurd at all; any kind of transparent surface (refractive or not) should give an alpha to use on compositing.

Here´s an example.
This teapot was rendered in VRay and has a refractive material. It was rendered on a white background. I then just switched out the backgrounds in PS and it looks fine.
Sure, if you stop and look you will notice that the multi colored gradient isn´t distoted. But for stuff people glance at for half a second like ads or someting flying by in an animation it doesn´t matter at all.