exr image output

Discussion related to the LuxCore functionality, implementations and API.
CodeHD
Donor
Donor
Posts: 437
Joined: Tue Dec 11, 2018 12:38 pm
Location: Germany

Re: exr image output

Post by CodeHD »

Hi bartek_zgo,

There is one difference between your code and the one Dade posted. Try to remove these two lines from your code:

Code: Select all

film.imagepipelines.0.3.type = "GAMMA_CORRECTION"
film.imagepipelines.0.3.value = "1.0"
I've just had a little stroll through the source code. While technically it shouldn't change the result with gamma set to 1.0, I believe the GammaCorrectionPipeline limits the output to 12 bit. Dade, did I see that correctly?

Then another idea I saw from that (Again, maybe Dade can confirm): LuxCore seem to operate Gamma correction on the imae normalized to minimum/mximum pixel value. Your post-production software might apply a different minimum/maximum clamping, based on the histogram, before gamma. This would explain the higher contrast you get as a result.
User avatar
Dade
Developer
Developer
Posts: 5672
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Re: exr image output

Post by Dade »

Your problem is with Gimp, not with LuxCore.

This is the PNG (gamma 2.2):

normal.jpg

This is the same .exr (gamma 1.0) file loaded with exrdisplay (the ILM's tool to display EXR files, ILM originally created the file format) and different parameters:

exrdisplay.jpg

For the second exrdisplay (the one looking like the PNG) I used the "-1" option:

Code: Select all

david@Desktop-3900x:~/projects/luxcorerender/LuxCore$ exrdisplay 
usage: exrdisplay [options] imagefile

Displays an OpenEXR image on the screen.

Options:

-p        displays the preview (thumbnail)
          image instead of the main image

-l lx ly  displays level (lx,ly) of a tiled
          multiresolution image

-w        displays all pixels in the data window,
          ignoring the display window

-a        ignores the image's pixel aspect ratio,
          and does not scale the image to make
          the pixels square

-c x      loads only image channel x

-1        sets exposure and knee sliders so that pixel
          value 0.0 becomes black, and 1.0 becomes white

-n        normalizes the pixels so that the smallest
          value becomes 0.0 and the largest value
          becomes 1.0

-A        same as -c A -1 (displays alpha)

-Z        same as -c Z -n (displays depth)

-s        swaps the image's top and bottom half, then
          swaps the left and right half, so that the
          four corners of the image end up in the center.
          (Useful for checking the seams of wrap-around
          texture map images.)

-u        changing the exposure and knee controls
          continuously updates the on-screen image

-t n      use n parallel threads to read the image file

-h        prints this message
-1 sets exposure and knee sliders so that pixel
value 0.0 becomes black, and 1.0 becomes white
This is the PNG and the EXR, side by side in GIMP v2.10.20:

gimp.jpg

Your GIMP is old or has not the default settings or something else.
Support LuxCoreRender project with salts and bounties
bartek_zgo
Posts: 116
Joined: Mon Oct 26, 2020 11:42 am

Re: exr image output

Post by bartek_zgo »

1. I don't think my gimp is wrong. Previously I had gimp v2.10.18. Now I have updated to v2.10.22. The result is the same. If I open with XnView it is still the same.
2. Removing gamma correction from pipeline does not change anything. Gamma 1.0 == no gamma correction. This make sense.
3. In my opinion png with gamma 2.2 (file rbg_g22.png) should be identical to exr with gamma 1.0 (file: rgb_noGamma.exr) but hey are not:
Capture2.PNG
4. Is something wrong with my pipelines:

Code: Select all

film.imagepipelines.0.0.type = "NOP"
film.imagepipelines.0.1.type = "NOP"
film.imagepipelines.0.2.type = "TONEMAP_LUXLINEAR"
film.imagepipelines.0.2.sensitivity = "100"
film.imagepipelines.0.2.exposure = 0.1
film.imagepipelines.0.2.fstop = 22
film.imagepipelines.0.3.type = "GAMMA_CORRECTION"
film.imagepipelines.0.3.value = "1.0"
film.outputs.0.type = "RGB_IMAGEPIPELINE"
film.outputs.0.index = 0
film.outputs.0.filename = "c:\Bartek\stack\LuxCoreTests\exrGammaProblems\rgb.png"
film.outputs.1.type = "RGB_IMAGEPIPELINE"
film.outputs.1.index = 0
film.outputs.1.filename = "c:\Bartek\stack\LuxCoreTests\exrGammaProblems\rgb.exr"

film.imagepipelines.1.0.type = "NOP"
film.imagepipelines.1.1.type = "NOP"
film.imagepipelines.1.2.type = "TONEMAP_LUXLINEAR"
film.imagepipelines.1.2.sensitivity = "100"
film.imagepipelines.1.2.exposure = 0.1
film.imagepipelines.1.2.fstop = 22
film.imagepipelines.1.3.type = "GAMMA_CORRECTION"
film.imagepipelines.1.3.value = "2.2"
film.outputs.2.type = "RGB_IMAGEPIPELINE"
film.outputs.2.index = 1
film.outputs.2.filename = "c:\Bartek\stack\LuxCoreTests\exrGammaProblems\rgb_g22.png"
film.outputs.3.type = "RGB_IMAGEPIPELINE"
film.outputs.3.index = 1
film.outputs.3.filename = "c:\Bartek\stack\LuxCoreTests\exrGammaProblems\rgb_g22.exr"

film.imagepipelines.2.0.type = "NOP"
film.imagepipelines.2.1.type = "NOP"
film.imagepipelines.2.2.type = "TONEMAP_LUXLINEAR"
film.imagepipelines.2.2.sensitivity = "100"
film.imagepipelines.2.2.exposure = 0.1
film.imagepipelines.2.2.fstop = 22
film.outputs.4.type = "RGB_IMAGEPIPELINE"
film.outputs.4.index = 2
film.outputs.4.filename = "c:\Bartek\stack\LuxCoreTests\exrGammaProblems\rgb_noGamma.png"
film.outputs.5.type = "RGB_IMAGEPIPELINE"
film.outputs.5.index = 2
film.outputs.5.filename = "c:\Bartek\stack\LuxCoreTests\exrGammaProblems\rgb_noGamma.exr"
Here is my exr file:https://files.fm/u/p8n92v2dr
Attachments
exrGammaProblems.zip
(1.51 MiB) Downloaded 183 times
User avatar
Dade
Developer
Developer
Posts: 5672
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Re: exr image output

Post by Dade »

bartek_zgo wrote: Tue Nov 24, 2020 1:17 pm 3. In my opinion png with gamma 2.2 (file rbg_g22.png) should be identical to exr with gamma 1.0 (file: rgb_noGamma.exr) but hey are not:
Capture2.PNG
No. PNG is a file format with values between [0.0, 1.0] while EXR is a file format with values between [0.0, +INF]. PNG with gamma X will look like EXR with gamma X if and only if EXR values are mapped between 0.0 and 1.0 (where X is whatever you want).

PNG is a LDR format, EXR is an HDR.
Support LuxCoreRender project with salts and bounties
bartek_zgo
Posts: 116
Joined: Mon Oct 26, 2020 11:42 am

Re: exr image output

Post by bartek_zgo »

So to get the same result I have to map maximum value in exr to 1 and after this apply gamma correction. The only thing I don't understand is why you got the same result in your previous post and I don't get them? Is there an option in LuxCore to rescale values to range 0-1 or there is an option in gimp that makes that?
Previously with maxwell render engine I didn't have this issue. So it means that maxwell already scales everything that the brights value is 1?
bartek_zgo
Posts: 116
Joined: Mon Oct 26, 2020 11:42 am

Re: exr image output

Post by bartek_zgo »

One more thing. If I download exr files from OpenExr homepage, open them with Gimp or XnView they look correct. So why when I open rgb_noGamma.exr file it looks wrong?
User avatar
Dade
Developer
Developer
Posts: 5672
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Re: exr image output

Post by Dade »

bartek_zgo wrote: Tue Nov 24, 2020 2:47 pm So to get the same result I have to map maximum value in exr to 1 and after this apply gamma correction. The only thing I don't understand is why you got the same result in your previous post and I don't get them? Is there an option in LuxCore to rescale values to range 0-1 or there is an option in gimp that makes that?
I used the "-1" exrdisplay option:

Code: Select all

-1        sets exposure and knee sliders so that pixel
          value 0.0 becomes black, and 1.0 becomes white
Support LuxCoreRender project with salts and bounties
bartek_zgo
Posts: 116
Joined: Mon Oct 26, 2020 11:42 am

Re: exr image output

Post by bartek_zgo »

As I understand, first you modified your file by exrdisplay, than you have open it gimp. Right?
So it means that all exr files that I have from other sources (webpages, maxwell), already are, let say "normalized". So they have range from 0 to 1. Why you can not save exr files already normalized? Is there a good reason to do this while opening, not while saving?
Let say that I don't have exrdisplay. It means that I can not open your exr file with gimp. Right?
User avatar
Dade
Developer
Developer
Posts: 5672
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Re: exr image output

Post by Dade »

bartek_zgo wrote: Wed Nov 25, 2020 8:17 am As I understand, first you modified your file by exrdisplay, than you have open it gimp. Right?
No, I didn't modified anything. I used an option to tell exrdisplay what is the min and max value to use: you can not apply gamma correction to an infinite range, you need to have a finite range, a min (usually 0.0) and a max (usually 1.0).
bartek_zgo wrote: Wed Nov 25, 2020 8:17 am Why you can not save exr files already normalized? Is there a good reason to do this while opening, not while saving?
Because they would be a LDR instead of an HDR image. It would the same of a 16bit PNG and it is not how EXR is intended to be used.
Support LuxCoreRender project with salts and bounties
CodeHD
Donor
Donor
Posts: 437
Joined: Tue Dec 11, 2018 12:38 pm
Location: Germany

Re: exr image output

Post by CodeHD »

bartek_zgo wrote: Tue Nov 24, 2020 2:47 pm So to get the same result I have to map maximum value in exr to 1 and after this apply gamma correction.
You might still not end up with exactly the same result as the LuxCore output, because LuxCore doesn't apply normalisation but a scaling factor that depends on gamma. (Normalisation doesn't really make sense anyways because you would lose control over the image brightness.) You can see the source code fo that factor here.

If we compute the ratio of this factor for gamma 2.2 and 1.0 we get 0.39.

To demonstrate the impact, I used the "rgb_noGamma.exr" from your scene and processed it in python in two ways to compare with the LuxCore:
First, I normalized the EXR, then applied gamma. Second, I scaled the image by a factor 0.39 as explained above, then applied gamma.

here is the result compared to the direct output from LuxCore:
combi.png
P.S.: If you're wondering why I use python, that's because I'm used to it and I have good control over the math happening there.

EDIT: This also means I was wrong in my earlier post that LuxCore operates on the normalized image. I assumed that from a quick anaylsis of the first images you posted...
Post Reply