# Isolate light cast on a surface through glass

I have a white plane and a glass object on top of it, with 2 spotlights casting light through the glass object. This causes a lot of light to be cast onto the white plane.

I want to turn the plane into alpha, either in the material or in post and isolate just the glass object and the cast light. Something like a shadow catcher, but for this refracted light instead of shadows. Is this possible?

• Try this one: blender.stackexchange.com/questions/134048/… – cgslav Mar 22 '19 at 14:57
• On a suitably simple scene, you could use the diffuse indirect pass on a separate renderlayer to get just the caustics. That way rendering twice and subtracting isn't required. – gandalf3 Mar 27 '19 at 23:07

# Alpha masks will not work for this

Alpha is for blending one image on top of another so it will not work with light, because light should be added, not blended, but you can separate only the light information.

# Separating light information

To separate light going through the glass object you would need to render it and then render a version without it. In this case it happens that the light that we need is going through glass, so if caustics are disabled the render will come out without it. Or if you wanted the light to be only from a specific light source you could disable the light source instead. You should just subtract the image without the light from the image with the light and you will be left with the light information that now could be added to another image. Note that it is important to work with 32bit color depth here.

# Separating glass

Glass is a lot harder to separate since it has refractions and internal reflections. You can have a look at this post, but I ignore internal reflections here. the refractions are also not completely accurate, because they come from a plane and not from realistic directions. To have more accurate results, it would be possible to separate glass to components like internal reflections with render passes and light paths node in the materials so it can be reconstructed in a more acurate way with different refractions. That gets a bit complicated, let me know, if you wish to explore this further.

• I may be misunderstanding the answer, but I'm not sure this is what I'm after. I'm trying to be able to convert the white background to alpha so that I can layer the object+its cast light over other backgrounds (this is for a website which has a changing background) – Ascalon Mar 23 '19 at 0:16
• If you want to put an object on another background, alpha mask is enough, however if you want to shine light on another background, you have to add(as in add values together) light to it. It should be addition( and it should be done with linear values, not sRGB) - that's another blending operation than mixing colors according to a grayscale mask. Note how on the checker background, the light does not replace colors but makes them lighter. CSS now supports some blending modes. I think screen should be close enough. – Martynas Žiemys Mar 23 '19 at 1:47
• I just want to overlay the image. It's for a website header that is partially transparent and will show the website's background through it. So I'm trying to turn the white background of my setup into alpha without losing the light cast onto it from the glass. – Ascalon Mar 23 '19 at 1:53
• If you use only alpha, you will loose the light cast, because it is cast on whatever is in your render, not the background it would be above. You could composite your header with CSS mix-blend-mode Property You would need images of your background, your objects without the light mixed with it with regular alpha and then you would need to add the light on top of everything with 'screen' blend mode so it brightens the images below in areas where it shines. – Martynas Žiemys Mar 23 '19 at 14:29
• @Drudge The typical kind of alpha (aka straight/unassociated) — the kind implemented in browsers, for instance — doesn't do emissive blending. That is, there is no way to contort the alpha channel such that areas where light is meant to be added will be correctly handled. In addition, the whole operation must take place in a linear color space, which as far as I know also isn't supported natively by any browsers. As a work around, you could perform the compositing yourself in javascript or webgl with a <canvas> element, or precompose the images. – gandalf3 Mar 27 '19 at 23:17