LuxCoreRender / LuxCore

LuxCore source repository
Apache License 2.0
1.16k stars 145 forks source link

Fully transparent pixel-sized-holes in alpha channel in fully opaque render. #536

Closed juangea closed 3 years ago

juangea commented 3 years ago

I'm getting some fully transparent pixels in my renders, it was hard to notice at first, but when I used the result for compositing, using a bright image behind the darker interior showed some pixels, I mention them as fireflies because they are single pixels, but it's not fireflies, it's more like holes in the alpha, holes of the size of a pixel.

This becomes obvious when I force the contrast in a scene that should not allow a single transparent pixel:

Render:

image

Alpha channel contrasted to make the problem more visible, make a zoom if you don't see the white pixel, the pixel-holes does not repeat from render to render, they are different:

image

Here is the blend file I used for this example, the composite in the compositor is the alpha to make the problem visible:

alpha_bug.zip

Dade916 commented 3 years ago

Your test scene has not enabled alpha channel at all. Am I missing something ?

juangea commented 3 years ago

It should have the transparent background enabled in the camera, and you see the alpha as black because it's inverted due to the color ramp, just to make the pixel more visible, here is another picture:

image

The alpha should be fully opaque (with the color ramp, fully black), but it has some white pixels, in more complex scenes they are like pixel-holes in the render.

Just in case I uploaded the wrong .blend I'll upload it again, this time I made 100% sure that this is the correct Blend I show you in the picture:

alpha_bug_2.zip

Dade916 commented 3 years ago

Alpha is not enabled in LuxCore AOVs panel and it is not configured through LuxCore API. Does it happen if you enable Alpha in AOVs pannel ?

This may be a bug in BlendLuxCore, it may ask for a not configure AOV and get just garbage.

Theverat commented 3 years ago

When "use transparent film" is enabled, the ALPHA AOV is added:

https://github.com/LuxCoreRender/BlendLuxCore/blob/b7c61706f7f0f9a3cacb78f283a8cafc548378c9/export/aovs.py#L84

Dade916 commented 3 years ago

Do you use different code for the FILESAVER ? Alpha is not enabled when exporting the scene.

juangea commented 3 years ago

@Dade916 you can enable the Alpha AOV if you want, there should not be any difference, just that when you export you have the AOV, but in my render the Alpha is enabled, so enable it anyways :)

Theverat commented 3 years ago

Do you use different code for the FILESAVER ? Alpha is not enabled when exporting the scene.

Yes, transparent film is ignored when using filesaver.

Dade916 commented 3 years ago

I should have fixed the problem.

juangea commented 3 years ago

Thanks @Dade916 I’ll test this tomorrow and confirm the fix :)

juangea commented 3 years ago

I`m not sure this is entirely solved, now I-m getting alpha transparency in fully solid parts of the scene, I see this happening in vegetation materials, like grass or plants, here is an example:

Render section:

image

Render alpha:

image

This is the shader used for this plant, which is one of the obvious ones, nothing fancy:

image

image

Dade916 commented 3 years ago

I solved the problem of the original test scene. That one looks like something different: it smells like a side effect of recent changes to alpha channel.

You should try:

1) does it happen with v2.5 ?

2) increase the max. total/specular/glossy depth in v2.6 to something very high, does it still happen ?

3) a test scene with a quad with the wall material and an overlapping quad with the leaf material, does it still happen ?

juangea commented 3 years ago

Ok, I'll do these tests.

Ignore the previous picture, I was wrong, I'll do the tests and tell you something, I'll also try to send you a simple scene to reproduce it.

juangea commented 3 years ago

Ok, you have another PM in the forum with a scene with a cube that reproduces the exact problem :)

(Today you have two PM's from me with two different scenes with two different problems, it's being a prplific day hahaha)

I'll test this in 2.5 to see if it happens, but I have to render some scenes for today so I won't be able to install back 2.5 I think, I'll do it if I can :)

The problem still happens with the Path depth to 64 (in everything).

Dade916 commented 3 years ago

Well, it is the result of using glossytranslucent: it transmits paths over an hemisphere so some of them will just hit the sky and set alpha according due to the recent changes (https://forums.luxcorerender.org/viewtopic.php?f=5&t=3568&start=10#p30294).

It works as you expected in the following cases:

1) if you replace glossytranslucent with glossy material; 2) if you set glossytranslucent transmission to black; 3) if you use roughglass with appropriate parameters;

1 and #2 will change a bit the look for a plant shown full screen (but, I'm pretty sure, not in your scene).

3 may produce the correct result because, instead of using a diffuse transmission (i.e. over all the hemisphere), will use a glossy transmission (i.e. more "directional" if you use low roughness values so the paths will hit the solid background instead of been fired in random directions). However the reflections will be too sharp.

Dade916 commented 3 years ago

A possible solution to the changes of https://forums.luxcorerender.org/viewtopic.php?f=5&t=3568&start=10#p30294 could be to set alpha only for specular or glossy transmissions (not for diffuse transmissions).

Dade916 commented 3 years ago

A possible solution to the changes of https://forums.luxcorerender.org/viewtopic.php?f=5&t=3568&start=10#p30294 could be to set alpha only for specular or glossy transmissions (not for diffuse transmissions).

I applied this change to the sources, it seems to work well and it makes sense.

juangea commented 3 years ago

Great, but I think I won't be able to test it until @Theverat updates the addon, right?

Dade916 commented 3 years ago

The Linux daily binaries should still be for v2.92 so you may be able to try it.

juangea commented 3 years ago

ah, ok, I'll test it on linux, but does it require some setting?

Because if we get alpha over translucent materials it renders translucency useless to recreate vegetation, and we cannot recreate vegetation withoout translucency :)

Dade916 commented 3 years ago

No, it should work out of the box.

juangea commented 3 years ago

Unless the change is not yet in the build (it's from 2 minutes ago) The problem persists:

image

I think the only viable option is to have a setting in the material to enable / disable alpha behaviour, similar to what is done by Corona.

juangea commented 3 years ago

Think that it's normal to want alpah out of normal glass, but in general we don't need alpha from the translucency of a tree leave or from grass, but we actually need translucency.

Dade916 commented 3 years ago

You are not using the correct version. The latest sources are working. You can check the status of builds here: https://dev.azure.com/LuxCoreRender/LuxCoreRender/_build

When they are all green, you can download the latest builds. I think Acasta69 reverted to Python v3.7 so Windows build will be usable too (when ready).

juangea commented 3 years ago

Understood, I'll repeate the test as soon as I see everything green.

Thanks!

juangea commented 3 years ago

DONE!

The translucent problem is gone, I'll do another test with a bigger scene, but it seems to be solved :)