Page 1 of 3

Transparent background, threshold level

Posted: Wed Mar 04, 2020 1:10 pm
by CodeHD
I'm currently working on a visualisation of rays in a lens system, using lasers with homogeneous volume.

I'm trying to do it with a transparent background, but then the rays that are in front of the background get (mostly) cut off. Example renders attached.

Is there a setting for this somehwere? Viewport render doesn't show this behaviour.

Using Blender 2.81 and LuxCore 2.3rc1.

Re: Transparent background, threshold level

Posted: Wed Mar 04, 2020 2:49 pm
by wasd
Do you mind to share the scene?

Re: Transparent background, threshold level

Posted: Wed Mar 04, 2020 4:04 pm
by CodeHD
I think I see the problem. I inspected the RGBA values pixel by pixel. The RGB values of the laser beam are in fact there, but the alpha-value remains zero for most of them, and small for the remaining. Thats why when I import it into another programm and add a background, the beam doesn't appear.

Thinking about this, I believe it is correct behaviour. Volumetric scattering in front of transparent probably just isn't easy.

For now, I can easily work around this problem in my use case.

Re: Transparent background, threshold level

Posted: Wed Mar 04, 2020 4:54 pm
by wasd
I get it. Volume was just too thin. There I multiplied scattering scale by 10:
unisob_autodetect_camvol-2.png

Re: Transparent background, threshold level

Posted: Wed Mar 04, 2020 5:03 pm
by Dade
CodeHD wrote: Wed Mar 04, 2020 4:04 pm I think I see the problem. I inspected the RGBA values pixel by pixel. The RGB values of the laser beam are in fact there, but the alpha-value remains zero for most of them, and small for the remaining.
I assume it is the correct behavior: alpha will be an average of all the times the ray pass trough (alpha = 0.0) and all the times the ray is scattered (when the laser is visible, alpha = 1.0). So if the volume scatters the laser 1 out of 10 times, alpha should be equal to 0.1.

Are you experiencing a different behavior (for instance alpha a lot smaller than the expected value) ?

Re: Transparent background, threshold level

Posted: Wed Mar 04, 2020 5:57 pm
by CodeHD
Dade wrote: Wed Mar 04, 2020 5:03 pm Are you experiencing a different behavior (for instance alpha a lot smaller than the expected value) ?
Well, I don't have a reference what the values "should be" in this scene, but what I am seeing makes sense, so I again agree that this is correct behaviour.
Hence my "problem" (i should have put it in quotation marks before ;) ) is that the beam in front of the intransparent lens barrel is a saturated green, but if add a white background to the image in post I do not see the beam, even though the color values are there. This would be nice for renders of volumetric stuff that you later want to combine with something else.

I just played around with a script that (basically) adds the color saturation or brightness to alpha. Works to some degree, but suffers from noise and white-scattered light from the scene illumination (If only OIDN worked with alpha :P). So it may not really be a universal solution.

I will let it render for a while to get a clean image. maybe a decent workaround is possible. Its a corner case ;)

Re: Transparent background, threshold level

Posted: Wed Mar 04, 2020 6:12 pm
by CodeHD
wasd wrote: Wed Mar 04, 2020 4:54 pm I get it. Volume was just too thin. There I multiplied scattering scale by 10: unisob_autodetect_camvol-2.png
Forgot to respond to this. It's not quite the solution I'm going for because is also increases scatter outside the beams, where i do want transparency. I'm currently trying to instead increase the brightness of the lasers.

Re: Transparent background, threshold level

Posted: Wed Mar 04, 2020 6:30 pm
by Dade
CodeHD wrote: Wed Mar 04, 2020 5:57 pm I just played around with a script that (basically) adds the color saturation or brightness to alpha. Works to some degree, but suffers from noise and white-scattered light from the scene illumination (If only OIDN worked with alpha :P). So it may not really be a universal solution.
I think you could just post-process the alpha channel: if (alpha > 0.0) than set alpha = 1.0

Re: Transparent background, threshold level

Posted: Wed Mar 04, 2020 6:45 pm
by B.Y.O.B.
Dade wrote: Wed Mar 04, 2020 6:30 pm I think you could just post-process the alpha channel: if (alpha > 0.0) than set alpha = 1.0
That won't work, since the alpha is the same over the whole volume.
The alpha is not modified by how much light was received for a pixel.

Re: Transparent background, threshold level

Posted: Wed Mar 04, 2020 6:52 pm
by B.Y.O.B.
Maybe a compositing setup like this would work?