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.
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 »

B.Y.O.B. wrote: Wed Mar 04, 2020 6:45 pm
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.
Mmm, no, that is very wrong, I will check.
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 6:30 pm I think you could just post-process the alpha channel: if (alpha > 0.0) than set alpha = 1.0
No, that is not what I intended. I do want to keep transparency outside the beams.
B.Y.O.B. wrote: Wed Mar 04, 2020 6:52 pm Maybe a compositing setup like this would work?
Yes, but no. The test scene I uploaded is too simple, as I also realised from my own test. (When I uploaded it I still assumed a problem somehwere else.) In the actual scene, there is some background light to provide shading for the lens barrel, and hence there is some white volumetric scattering all across the image. I couldn't yet find a good balance with the laser beam.
Dade wrote: Wed Mar 04, 2020 8:01 pm Mmm, no, that is very wrong, I will check.
The alpha is not the same everywhere, there are some different values. All very low, but as discussed above, this doesn't seem wrong. Again, what B.Y.O.B. observed might be because of the too simple test scene (?)
CodeHD
Developer
Developer
Posts: 492
Joined: Tue Dec 11, 2018 12:38 pm
Location: Germany

Re: Transparent background, threshold level

Post by CodeHD »

Updated test scene + render, with a distant source to illuminate the rest of the volume, showing a new observation:

In the transparent part of the volume, there are white values >100, while in front of the black object the peak is around 30, and mean much lower. As the homogeneous volume is limited, there should not be values higher than twice the black area, which is about in the middle of the volume.
A reference stripe looking outside the volume at the top and bottom is fine.
Attachments
transparency_forum.blend
(1.06 MiB) Downloaded 209 times
test_forum.png
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. »

New compositing setup idea:
Attachments
Capture.PNG
Capture2.PNG
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. »

You can also clean out the alpha values below a threshold (from the volume) with a setup like this, although this will hurt anti-aliasing a bit:
Attachments
Capture3.PNG
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 9:31 pm Updated test scene + render, with a distant source to illuminate the rest of the volume, showing a new observation:

In the transparent part of the volume, there are white values >100, while in front of the black object the peak is around 30, and mean much lower. As the homogeneous volume is limited, there should not be values higher than twice the black area, which is about in the middle of the volume.
A reference stripe looking outside the volume at the top and bottom is fine.
You seem to assume that scattering is a linear process, it isn't, it follows an exponential law.
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 9:59 pm You seem to assume that scattering is a linear process, it isn't, it follows an exponential law.
But in this setup with a low scattering scale compared with the dimensions of the volume, we should not observe that. Even if, the light is coming from the direction of the camera, so the second half of the volume should then be darker and contribute less than what is seen over the black object.
CodeHD
Developer
Developer
Posts: 492
Joined: Tue Dec 11, 2018 12:38 pm
Location: Germany

Re: Transparent background, threshold level

Post by CodeHD »

I now let it render over night to get a converged result, and also tested one of BYOB's compositor setups.

The result is that the compositor setup works and gives me the desired output :)

If I export the un-composited image to png or 16-bit tiff, I again only get full white colors in the transparent areas. I.e. the png-output in transparent areas converges to white(?)
But the EXR output shows the correct result.

From other threads I understand that some image processing is not applied for EXR. But would that the be in LuxCore, BlendLuxCore, or Blender itslef?
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. »

CodeHD wrote: Thu Mar 05, 2020 7:35 am From other threads I understand that some image processing is not applied for EXR. But would that the be in LuxCore, BlendLuxCore, or Blender itslef?
As far as I know, this is Blender behaviour: the Blender color management (which is usually applied after everything else) is not applied if you save the render result as 32 bit EXR/HDR.
CodeHD
Developer
Developer
Posts: 492
Joined: Tue Dec 11, 2018 12:38 pm
Location: Germany

Re: Transparent background, threshold level

Post by CodeHD »

I had a look around Blender related stuff, and indeed, there are other people noticing this behaviour, e.g.

https://developer.blender.org/T53265

The explanations I read sound a bit like the Blender color management assumes a white background and blends all colors according to the transparency. Not sure if this is exactly how it works internally, but anyways that would explain my observations.

Thanks for the input everyone, I can now work with it the way I wanted ;)
Post Reply