Transparent background, threshold level

Use this forum for general user support and related questions.
Forum rules
Please upload a testscene that allows developers to reproduce the problem, and attach some images.
CodeHD
Developer
Developer
Posts: 492
Joined: Tue Dec 11, 2018 12:38 pm
Location: Germany

Transparent background, threshold level

Post 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.
Attachments
bg_nontrans_2.png
bg_trans_2.png
wasd
Posts: 319
Joined: Tue Apr 24, 2018 7:20 pm

Re: Transparent background, threshold level

Post by wasd »

Do you mind to share the scene?
CPU Bidir + Metropolis | Core i5-4570
CodeHD
Developer
Developer
Posts: 492
Joined: Tue Dec 11, 2018 12:38 pm
Location: Germany

Re: Transparent background, threshold level

Post 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.
Attachments
transparency_forum.blend
(1.07 MiB) Downloaded 253 times
wasd
Posts: 319
Joined: Tue Apr 24, 2018 7:20 pm

Re: Transparent background, threshold level

Post by wasd »

I get it. Volume was just too thin. There I multiplied scattering scale by 10:
unisob_autodetect_camvol-2.png
CPU Bidir + Metropolis | Core i5-4570
User avatar
Dade
Developer
Developer
Posts: 5675
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Re: Transparent background, threshold level

Post 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) ?
Support LuxCoreRender project with salts and bounties
CodeHD
Developer
Developer
Posts: 492
Joined: Tue Dec 11, 2018 12:38 pm
Location: Germany

Re: Transparent background, threshold level

Post 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 ;)
CodeHD
Developer
Developer
Posts: 492
Joined: Tue Dec 11, 2018 12:38 pm
Location: Germany

Re: Transparent background, threshold level

Post 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.
User avatar
Dade
Developer
Developer
Posts: 5675
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Re: Transparent background, threshold level

Post 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
Support LuxCoreRender project with salts and bounties
User avatar
B.Y.O.B.
Developer
Developer
Posts: 4146
Joined: Mon Dec 04, 2017 10:08 pm
Location: Germany
Contact:

Re: Transparent background, threshold level

Post 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.
Attachments
alpha channel on the left
alpha channel on the left
User avatar
B.Y.O.B.
Developer
Developer
Posts: 4146
Joined: Mon Dec 04, 2017 10:08 pm
Location: Germany
Contact:

Re: Transparent background, threshold level

Post by B.Y.O.B. »

Maybe a compositing setup like this would work?
Attachments
Captur2.PNG
Post Reply