5

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.

enter image description here

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?

Ascalon
  • 6,579
  • 8
  • 55
  • 121
  • Try this one: https://blender.stackexchange.com/questions/134048/how-to-reflect-catch-light-but-be-invisible-on-render/134075#134075 – cgslav Mar 22 '19 at 14:57
  • 1
    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

1 Answers1

4

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.

enter image description 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.

Martynas Žiemys
  • 24,274
  • 2
  • 34
  • 77
  • 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 00: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 01: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 01: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
  • I understand that I can't have the background be only alpha. I am trying to turn the areas that don't have light cast on them from the glass into alpha so that it can be properly layered over other images. – Ascalon Mar 24 '19 at 07:56
  • 2
    @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
  • @gandalf3 It sounds like this is a lot more complicated than I though. I don't know what most of what you are saying here means, but I get the issue. I don't need to keep everything perfectly photorealistic here, I just need to get some opacity so that the website's background shows through instead of the current white plane I rendered it on. So areas with no object or light spill should be 100% transparent, and the lightspill should be partially transparent, depending on the amount of light. But it's sounding like I need to just move to a different concept entirely here. – Ascalon Mar 28 '19 at 03:14
  • @Drudge You can try to hack it, but the practical upshot is even if you get something that might look okay against one background, it'll will likely look ugly against another. If you want to go that route, I think your best bet is to over-expose the caustics heavily so that you don't run the risk of having darker caustics against a lighter background (which will look very wrong indeed). The linked example was made by simply plugging the isolated caustics into both inputs of the set alpha node. – gandalf3 Mar 28 '19 at 09:37
  • CSS supports screen blending mode. That is far from correct way to do it(it works with non linear sRGB values and the math is completely incorrect as well), but if you have the light information separated as light on black as in my answer and mix it with the background in screen blending mode, you may get results that do not look completely wrong visually. – Martynas Žiemys Mar 28 '19 at 23:10