OpenImageDenoise

Discussion related to the LuxCore functionality, implementations and API.
User avatar
B.Y.O.B.
Developer
Developer
Posts: 4146
Joined: Mon Dec 04, 2017 10:08 pm
Location: Germany
Contact:

Re: OpenImageDenoise

Post by B.Y.O.B. »

alpistinho wrote: Sun Feb 03, 2019 11:29 am I've set-up a second image pipeline but it doesn't change the image in any way, even though it becomes very slow and something is happening.
In their example, they check for errors after the filter is executed, not before:
https://github.com/OpenImageDenoise/oid ... pi-example

When we did the BCD integration, we started luxcoreui with

Code: Select all

-D screen.tool.type IMAGE_VIEW
So the image only updates every 4 seconds.
Also, you have to open "Window -> Film Outputs editor", look for your OIDN-imagepipeline and click "Show". This will trigger the imagepipeline for the first time.
Then you have to resize the new window.
You can re-run the imagepipeline with the "Refresh" button on the top left.
Attachments
example with BCD imagepipeline
example with BCD imagepipeline
User avatar
alpistinho
Developer
Developer
Posts: 198
Joined: Thu Jul 05, 2018 11:38 pm
Location: Rio de Janeiro

Re: OpenImageDenoise

Post by alpistinho »

B.Y.O.B. wrote: Sun Feb 03, 2019 11:54 am In their example, they check for errors after the filter is executed, not before:
https://github.com/OpenImageDenoise/oid ... pi-example
The example in the repo itself was executing before. In any case I've put it after the filter execution and it didn't throw anything.
B.Y.O.B. wrote: Sun Feb 03, 2019 11:54 am When we did the BCD integration, we started luxcoreui with

Code: Select all

-D screen.tool.type IMAGE_VIEW
So the image only updates every 4 seconds.
Also, you have to open "Window -> Film Outputs editor", look for your OIDN-imagepipeline and click "Show". This will trigger the imagepipeline for the first time.
Then you have to resize the new window.
You can re-run the imagepipeline with the "Refresh" button on the top left.
I did that but there are no filters showing on the "Current Film Outputs settings". The log lines I've added indicate that the code is running, however.

Code: Select all

[LuxCore][179.756] [IntelOIDNPlugin] Copying Film to output buffer
[LuxCore][183.828] [IntelOIDNPlugin] Copying Film to input buffer
[LuxCore][183.882] [IntelOIDNPlugin] Executing filter
Can you check my configuration file to see if I'm doing something wrong with it?

Code: Select all

film.width = 512
film.height = 512
scene.file = scenes/cornell/cornell.scn
##
#path.photongi.sampler.type = RANDOM
#path.photongi.sampler.type = METROPOLIS
path.photongi.photon.maxcount = 400000
path.photongi.photon.maxdepth = 4
path.photongi.visibility.lookup.radius = 0.15
path.photongi.direct.enabled = 0
path.photongi.indirect.enabled = 1
path.photongi.indirect.maxsize = 400000
path.photongi.indirect.lookup.radius = 0.075
path.photongi.caustic.enabled = 0
#path.photongi.debug.type = showdirect
##
#path.pathdepth.total = 4
#film.filter.width = 2
#tilepath.sampling.aa.size = 21
#tile.size = 16
#tile.multipass.enable = 1
#tile.multipass.convergencetest.threshold256 = 16
#tile.multipass.convergencetest.threshold.reduction = 0.5
#screen.tiles.converged.show = 1
#screen.tiles.passcount.show = 1
#screen.tiles.notconverged.show = 1
#screen.tiles.passcount.show = 1
#screen.tiles.error.show = 1
#lightstrategy.type = DLS_CACHE
##
film.imagepipelines.0.0.type = GAMMA_CORRECTION
film.imagepipelines.0.0.value = 2.2
film.imagepipelines.1.0.type = GAMMA_CORRECTION
film.imagepipelines.1.0.value = 2.2
film.imagepipelines.1.1.type = INTEL_OIDN
#film.imagepipelines.1.0.type = BCD_DENOISER
#film.imagepipelines.1.1.type = GAMMA_CORRECTION
#film.imagepipelines.1.1.value = 2.2
##
#film.imagepipelines.0.0.type = PATTERNS
#film.imagepipelines.0.0.index = 0
##
#film.outputs.1.type = RGB_IMAGEPIPELINE
#film.outputs.1.index = 0
#film.outputs.1.filename = normal.png
#film.outputs.2.type = RGB_IMAGEPIPELINE
#film.outputs.2.index = 1
#film.outputs.2.filename = denoised.png
#film.outputs.2.type = MATERIAL_ID_COLOR
#film.outputs.2.filename = cornell_MATERIAL_ID_COLOR.png
batch.haltspp = 5
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: OpenImageDenoise

Post by B.Y.O.B. »

alpistinho wrote: Sun Feb 03, 2019 12:06 pm film.imagepipelines.1.0.type = GAMMA_CORRECTION
film.imagepipelines.1.0.value = 2.2
film.imagepipelines.1.1.type = INTEL_OIDN
I would put the gamma correction after the denoising step, but otherwise, I can't find anything wrong.
I'll try to compile your branch on my machine.
User avatar
alpistinho
Developer
Developer
Posts: 198
Joined: Thu Jul 05, 2018 11:38 pm
Location: Rio de Janeiro

Re: OpenImageDenoise

Post by alpistinho »

B.Y.O.B. wrote: Sun Feb 03, 2019 12:13 pm
alpistinho wrote: Sun Feb 03, 2019 12:06 pm film.imagepipelines.1.0.type = GAMMA_CORRECTION
film.imagepipelines.1.0.value = 2.2
film.imagepipelines.1.1.type = INTEL_OIDN
I would put the gamma correction after the denoising step, but otherwise, I can't find anything wrong.
I'll try to compile your branch on my machine.
I just noticed that I was assuming that the Film would be tonemapped, the filter is even set up for LDR, but maybe that's not true.
Since there is no tonemapper defined, is the input film HDR and luxcoreui just tonemaps before drawing on the screen?
Support LuxCoreRender project with salts and bounties
User avatar
Dade
Developer
Developer
Posts: 5675
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Re: OpenImageDenoise

Post by Dade »

alpistinho wrote: Sun Feb 03, 2019 12:18 pm
B.Y.O.B. wrote: Sun Feb 03, 2019 12:13 pm
alpistinho wrote: Sun Feb 03, 2019 12:06 pm film.imagepipelines.1.0.type = GAMMA_CORRECTION
film.imagepipelines.1.0.value = 2.2
film.imagepipelines.1.1.type = INTEL_OIDN
I would put the gamma correction after the denoising step, but otherwise, I can't find anything wrong.
I'll try to compile your branch on my machine.
I just noticed that I was assuming that the Film would be tonemapped, the filter is even set up for LDR, but maybe that's not true.
Since there is no tonemapper defined, is the input film HDR and luxcoreui just tonemaps before drawing on the screen?
A normal image pipeline has a tone mapper plugin at some point. The denoiser should be the very first plugin in an image pipeline and it will receive the image in HDR format.

Something like:

Code: Select all

film.imagepipelines.1.0.type = INTEL_OIDN
film.imagepipelines.1.1.type = TONEMAP_LINEAR
film.imagepipelines.1.1.scale = 1.0
film.imagepipelines.1.2.type = GAMMA_CORRECTION
film.imagepipelines.1.2.value = 2.2
Support LuxCoreRender project with salts and bounties
User avatar
alpistinho
Developer
Developer
Posts: 198
Joined: Thu Jul 05, 2018 11:38 pm
Location: Rio de Janeiro

Re: OpenImageDenoise

Post by alpistinho »

Dade wrote: Sun Feb 03, 2019 12:27 pm
alpistinho wrote: Sun Feb 03, 2019 12:18 pm
B.Y.O.B. wrote: Sun Feb 03, 2019 12:13 pm
I would put the gamma correction after the denoising step, but otherwise, I can't find anything wrong.
I'll try to compile your branch on my machine.
I just noticed that I was assuming that the Film would be tonemapped, the filter is even set up for LDR, but maybe that's not true.
Since there is no tonemapper defined, is the input film HDR and luxcoreui just tonemaps before drawing on the screen?
A normal image pipeline has a tone mapper plugin at some point. The denoiser should be the very first plugin in an image pipeline and it will receive the image in HDR format.

Something like:

Code: Select all

film.imagepipelines.1.0.type = INTEL_OIDN
film.imagepipelines.1.1.type = TONEMAP_LINEAR
film.imagepipelines.1.1.scale = 1.0
film.imagepipelines.1.2.type = GAMMA_CORRECTION
film.imagepipelines.1.2.value = 2.2
I've set the filter to HDR and used your suggestion, but saw no change.
I've then changed some data structures to mimic exactly what they're doing on the documentation and while the image does not look denoised, it is different. It has some weird stripe pattern :lol:
Screenshot from 2019-02-03 11-09-45.png
Support LuxCoreRender project with salts and bounties
User avatar
Dade
Developer
Developer
Posts: 5675
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Re: OpenImageDenoise

Post by Dade »

alpistinho wrote: Sun Feb 03, 2019 1:10 pm It has some weird stripe pattern :lol:
The problem is in this kind of loop:

Code: Select all

for (u_int i = 0; i < pixelCount; i += 3) {
        color[i] = pixels[i].c[0];
        color[i + 1] = pixels[i].c[1];
        color[i + 2] = pixels[i].c[2];
}
It should be something like:

Code: Select all

for (u_int i = 0; i < pixelCount; ++i) {
        const i3 = i * 3;
        color[i3] = pixels[i].c[0];
        color[i3 + 1] = pixels[i].c[1];
        color[i3 + 2] = pixels[i].c[2];
}
Support LuxCoreRender project with salts and bounties
User avatar
alpistinho
Developer
Developer
Posts: 198
Joined: Thu Jul 05, 2018 11:38 pm
Location: Rio de Janeiro

Re: OpenImageDenoise

Post by alpistinho »

Dade wrote: Sun Feb 03, 2019 1:26 pm
alpistinho wrote: Sun Feb 03, 2019 1:10 pm It has some weird stripe pattern :lol:
The problem is in this kind of loop:

Code: Select all

for (u_int i = 0; i < pixelCount; i += 3) {
        color[i] = pixels[i].c[0];
        color[i + 1] = pixels[i].c[1];
        color[i + 2] = pixels[i].c[2];
}
It should be something like:

Code: Select all

for (u_int i = 0; i < pixelCount; ++i) {
        const i3 = i * 3;
        color[i3] = pixels[i].c[0];
        color[i3 + 1] = pixels[i].c[1];
        color[i3 + 2] = pixels[i].c[2];
}
Thanks Dade!

Sorry for the stupid mistake, it's working now =)
Screenshot from 2019-02-03 11-34-39.png
Screenshot from 2019-02-03 11-33-55.png
Support LuxCoreRender project with salts and bounties
User avatar
alpistinho
Developer
Developer
Posts: 198
Joined: Thu Jul 05, 2018 11:38 pm
Location: Rio de Janeiro

Re: OpenImageDenoise

Post by alpistinho »

Is there support for imagepipeline plugins to receive multiple films as input?

Looking at the ImagePipelinePlugin class it seems there is not, should it be extended to receive multiple Films?

EDIT:
I guess I could also hardcode the IntelOIDN class to calculate the needed AOV's internally
Support LuxCoreRender project with salts and bounties
User avatar
Dade
Developer
Developer
Posts: 5675
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Re: OpenImageDenoise

Post by Dade »

alpistinho wrote: Sun Feb 03, 2019 1:47 pm Is there support for imagepipeline plugins to receive multiple films as input?

Looking at the ImagePipelinePlugin class it seems there is not, should it be extended to receive multiple Films?
What do you mean ? A film can have one or more image pipelines and each image pipeline can have any number of plugins. So if you use the Oidn plugin multiple times, there will be multiple/different instances of your class and each one will be called with a different film (so I assume the answer to your question is no).
Support LuxCoreRender project with salts and bounties
Post Reply