Color spaces support (aka OpenColorIO v2.0)

Discussion related to the LuxCore functionality, implementations and API.
User avatar
Sharlybg
Donor
Donor
Posts: 3101
Joined: Mon Dec 04, 2017 10:11 pm
Location: Ivory Coast

Re: Color spaces support (aka OpenColorIO v2.0)

Post by Sharlybg »

Sorry guys is OCIO 2.0 now available on BlendLuxcore ?
Want to test it.
Support LuxCoreRender project with salts and bounties

Portfolio : https://www.behance.net/DRAVIA
User avatar
B.Y.O.B.
Developer
Developer
Posts: 4146
Joined: Mon Dec 04, 2017 10:08 pm
Location: Germany
Contact:

Re: Color spaces support (aka OpenColorIO v2.0)

Post by B.Y.O.B. »

Not exposed yet, no.
User avatar
richardbao
Posts: 17
Joined: Tue Mar 09, 2021 7:47 am

Re: Color spaces support (aka OpenColorIO v2.0)

Post by richardbao »

any info on the release date>?
v2.6 i guess?
User avatar
richardbao
Posts: 17
Joined: Tue Mar 09, 2021 7:47 am

Re: Color spaces support (aka OpenColorIO v2.0)

Post by richardbao »

Dade wrote: Sun Apr 11, 2021 10:21 am Introduction

I have added the support for color spaces to LuxCoreRender v2.6 branch. LuxCore internally works in a linear FP32 color space and any input/output color needs to be converted to/from that color space. There are currently 3 supported input/output color spaces: Nop, LuxCore and OpenColorIO.

Nop color space

This is the internal LuxCore linear FP32 color space so it is effectively a nop conversion (i.e. the color is not modified).

LuxCore color space

This is just a gamma corrected color space so all inputs are reversed gamma corrected and all output are gamma corrected.

OpenColorIO color space

OpenColorIO (https://opencolorio.org) color space supports a wide configurable range of color spaces, including industrial standards like: ACES (https://acescolorspace.com), Filmic (https://sobotka.github.io/filmic-blender), Sony Anim/VFX (https://github.com/imageworks/OpenColorIO-Configs), etc..

What is the problem ?

There was a major problem in LuxCore before the introduction of color spaces: LuxCore applies reverse gamma correction to input images (texture maps, etc.) but not to input colors. This means the color you pick on the screen was not the color you get as output (i.e. it is like if it was gamma corrected 2 times). The difference can be really huge. This is the main reason why you should start to use color spaces even if compatibility with the past is fully maintained.

Compatibility

By default, LuxCore still work exactly as now. All the new color spaces related features are available as an extension and are not breaking the compatibility with the past.

Outputs conversion

New OpenColorIO tone mapper

The first tool to enable the use of color spaces is the new TONEMAP_OPENCOLORIO. It converts the rendering output using OpenColorIO. It supporte 3 working modes:

1) Color space conversion, for instance, this converts from Sony "lnf" color space (LuxCore linear FP32 color space, aka Nop color space) to Sony "vd8" (Sony video 8bit color space):

Code: Select all

# From linear FP32 color space to video display 8 bit colorspace
film.imagepipelines.0.0.type = TONEMAP_OPENCOLORIO
film.imagepipelines.0.0.mode = COLORSPACE_CONVERSION
# Use system default OpenColorIO configuration
film.imagepipelines.0.0.config = ""
film.imagepipelines.0.0.src = lnf
film.imagepipelines.0.0.dst = vd8
2) Color space conversion for display:

Code: Select all

# Using a display mode
film.imagepipelines.0.0.type = TONEMAP_OPENCOLORIO
film.imagepipelines.0.0.mode = DISPLAY_CONVERSION
# Use Sony Anim OpenColorIO configuration
film.imagepipelines.0.0.config = "deps/opencolorio-configs/spi-anim/config.ocio"
film.imagepipelines.0.0.src = lnf
film.imagepipelines.0.0.display = sRGB
film.imagepipelines.0.0.view = Film
3) LUT conversion:

Code: Select all

# Using a custom LUT mode
film.imagepipelines.0.0.type = TONEMAP_OPENCOLORIO
film.imagepipelines.0.0.mode = LUT_CONVERSION
film.imagepipelines.0.0.lutfile = deps/opencolorio-configs/spi-anim/luts/lmf.spi1d
OpenColorIO transformations already include gamma correction, so this tone mapper doesn't require to use the gamma correction plugin.

Inputs conversion

Image maps color space support

It is now possible to declare the color space of an image map (used for texture mapping, infinite lights, etc.) in order to have the appropriate conversion to internal LuxCore rnedering color space. For instance, Nop color space:

Code: Select all

scene.textures.imgtex.file = scenes/randomizedtiling/pattern-3.jpg
scene.textures.imgtex.colorspace = nop
LuxCore color space:

Code: Select all

scene.textures.imgtex.file = scenes/randomizedtiling/pattern-3.jpg
scene.textures.imgtex.colorspace = luxcore
scene.textures.imgtex.colorspace.gamma = 2.2
OpenColorIO color space:

Code: Select all

scene.textures.imgtex.file = scenes/randomizedtiling/pattern-3.jpg
scene.textures.imgtex.colorspace = opencolorio
# Use system default OpenColorIO configuration
scene.textures.imgtex.colorspace.config = ""
scene.textures.imgtex.colorspace.name = vd8
Constant float and float3 textures (aka constant colors)

It is now possible to declare the color space of a constant color (float and float3), for instance:

Code: Select all

scene.textures.KhakiCol.type = constfloat3
scene.textures.KhakiCol.value = 1. 0.824176 0.549451
scene.textures.KhakiCol.colorspace = luxcore
scene.textures.KhakiCol.colorspace.gamma = 2.2
##
scene.textures.DarkGreenCol.type = constfloat3
scene.textures.DarkGreenCol.value = 0. 0.4 0.
scene.textures.DarkGreenCol.colorspace = opencolorio
# Use system default OpenColorIO configuration
scene.textures.DarkGreenCol.colorspace.config = ""
scene.textures.DarkGreenCol.colorspace.name = vd8
Implicit definitions of constant float and float3 textures (aka constant colors)

LuxCore supports a more compact and inlined definition of constant colors. This syntax has been extended too:

Code: Select all

# Old syntax
scene.materials.HalveRed.type = matte
scene.materials.HalveRed.kd = 0.70003 0. 0.

Code: Select all

scene.materials.HalveRed.type = matte
scene.materials.HalveRed.kd = nop 0.70003 0. 0.

Code: Select all

scene.materials.HalveRed.type = matte
scene.materials.HalveRed.kd = luxcore 2.2 0.70003 0. 0.

Code: Select all

scene.materials.HalveRed.type = matte
scene.materials.HalveRed.kd = opencolorio "" vd8 0.70003 0. 0.
Materials and Light sources constant colors

The same syntax of implicit definitions of constant float and float3 can be used in all properties of material and light sources. This pretty much cover all possible inputs.

Blender integration

How to integrated this feature in Blender is something still to be defined and it depends in how Blender supports and works with color spaces. The general rule should be to have the possibility to pick a color space every time you select a color or an image. The same for the outputs. Adding this feature may require few iterations.


Hi Dade, any explanation on this mode 2?


film.imagepipelines.0.0.src = lnf
film.imagepipelines.0.0.display = sRGB
film.imagepipelines.0.0.view = Film

i am little confused with the display and view parameters. whats the difference and what are they use for?
User avatar
Dade
Developer
Developer
Posts: 5672
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Re: Color spaces support (aka OpenColorIO v2.0)

Post by Dade »

richardbao wrote: Thu Aug 05, 2021 12:19 pm film.imagepipelines.0.0.src = lnf
film.imagepipelines.0.0.display = sRGB
film.imagepipelines.0.0.view = Film

i am little confused with the display and view parameters. whats the difference and what are they use for?
It all really depends on what your OpenColorIO configuration file defines. For instance looks at ACES configuration: https://github.com/imageworks/OpenColor ... g.ocio#L40

There you have a "ACES" display and a long list of devices: sRGB, DCDM, DCDM P3 gamut clip, P3-D60, P3-D60 ST2084 1000 nits, P3-D60 ST2084 2000 nits, P3-D60 ST2084 4000 nits, P3-DCI, Rec.2020, Rec.2020 ST2084 1000 nits, Rec.709, Rec.709 D60 sim., sRGB D60 sim., Raw, Log.

The general idea in LuxCore is to have multiple image pipelines with different OCIO settings: one to save on file in a generic color space, one for each display device you are using. This is done with the purpose to obtain the same output on different display devices.

All the tag (i.e. "lnf", "sRGB", "Film") are meaningful only in the context of a specific OCIO configuration, they are just arbitrary names corresponding to some kind of color space transformations defined in the configuration file. I think I used Sony VFX configuration in my example above.
Support LuxCoreRender project with salts and bounties
User avatar
richardbao
Posts: 17
Joined: Tue Mar 09, 2021 7:47 am

Re: Color spaces support (aka OpenColorIO v2.0)

Post by richardbao »

Dade wrote: Thu Aug 05, 2021 9:38 pm
richardbao wrote: Thu Aug 05, 2021 12:19 pm film.imagepipelines.0.0.src = lnf
film.imagepipelines.0.0.display = sRGB
film.imagepipelines.0.0.view = Film

i am little confused with the display and view parameters. whats the difference and what are they use for?
It all really depends on what your OpenColorIO configuration file defines. For instance looks at ACES configuration: https://github.com/imageworks/OpenColor ... g.ocio#L40

There you have a "ACES" display and a long list of devices: sRGB, DCDM, DCDM P3 gamut clip, P3-D60, P3-D60 ST2084 1000 nits, P3-D60 ST2084 2000 nits, P3-D60 ST2084 4000 nits, P3-DCI, Rec.2020, Rec.2020 ST2084 1000 nits, Rec.709, Rec.709 D60 sim., sRGB D60 sim., Raw, Log.

The general idea in LuxCore is to have multiple image pipelines with different OCIO settings: one to save on file in a generic color space, one for each display device you are using. This is done with the purpose to obtain the same output on different display devices.

All the tag (i.e. "lnf", "sRGB", "Film") are meaningful only in the context of a specific OCIO configuration, they are just arbitrary names corresponding to some kind of color space transformations defined in the configuration file. I think I used Sony VFX configuration in my example above.
Thanks for replying, Dade.
I have been playing with OCIO using filmic OCIO configuration for a while(i copy the filmic config from blender directly)
I also find it pretty difficult to tell if the new OCIO config has been correctly applied. Do you have any suggestions on it?
Besides, I tried the optional config "look" from filmic, seems not working though. is there anything I did wrong? or is it because it's not implemented?
here is my code

ocio_src=Linear
ocio_display=sRGB
ocio_view=Filmic
ocio_look=High Contrast

any suggestion would be appreciated!
User avatar
Dade
Developer
Developer
Posts: 5672
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Re: Color spaces support (aka OpenColorIO v2.0)

Post by Dade »

Do you have a simple test scene ? May becincluding a comparison with Cycles if there a difference in using filmic ?
Support LuxCoreRender project with salts and bounties
User avatar
richardbao
Posts: 17
Joined: Tue Mar 09, 2021 7:47 am

Re: Color spaces support (aka OpenColorIO v2.0)

Post by richardbao »

Dade wrote: Thu Aug 12, 2021 10:01 am Do you have a simple test scene? May be including a comparison with Cycles if there is a difference in using filmic ?
Yes, I am testing on our own DCC, so the file format is not the same though.

I think the LuxCore has been implemented the same with cycle, the only difference is cycle enabled "looks" in the filmic OCIO config, which really makes the filmic pop.

here is the look config in the filmic ocio configuration.

Code: Select all

looks:
  - !<Look>
    name: Very High Contrast
    process_space: Filmic Log
    transform: !<GroupTransform>
        children:
            - !<FileTransform> {src: filmic_to_1.20_1-00.spi1d, interpolation: linear}
            - !<FileTransform> {src: filmic_to_0-70_1-03.spi1d, interpolation: linear, direction: inverse}

  - !<Look>
    name: High Contrast
    process_space: Filmic Log
    transform: !<GroupTransform>
        children:
            - !<FileTransform> {src: filmic_to_0.99_1-0075.spi1d, interpolation: linear}
            - !<FileTransform> {src: filmic_to_0-70_1-03.spi1d, interpolation: linear, direction: inverse}

  - !<Look>
    name: Medium High Contrast
    process_space: Filmic Log
    transform: !<GroupTransform>
        children:
            - !<FileTransform> {src: filmic_to_0-85_1-011.spi1d, interpolation: best}
            - !<FileTransform> {src: filmic_to_0-70_1-03.spi1d, interpolation: linear, direction: inverse}

  - !<Look>
    name: Medium Contrast
    process_space: Filmic Log
    transform: !<GroupTransform>
        children:

  - !<Look>
    name: Medium Low Contrast
    process_space: Filmic Log
    transform: !<GroupTransform>
        children:
            - !<FileTransform> {src: filmic_to_0-60_1-04.spi1d, interpolation: linear}
            - !<FileTransform> {src: filmic_to_0-70_1-03.spi1d, interpolation: linear, direction: inverse}

  - !<Look>
    name: Low Contrast
    process_space: Filmic Log
    transform: !<GroupTransform>
        children:
            - !<FileTransform> {src: filmic_to_0-48_1-09.spi1d, interpolation: linear}
            - !<FileTransform> {src: filmic_to_0-70_1-03.spi1d, interpolation: linear, direction: inverse}

  - !<Look>
    name: Very Low Contrast
    process_space: Filmic Log
    transform: !<GroupTransform>
        children:
            - !<FileTransform> {src: filmic_to_0-35_1-30.spi1d, interpolation: linear}
            - !<FileTransform> {src: filmic_to_0-70_1-03.spi1d, interpolation: linear, direction: inverse}

here are all the different looks that the filmic config offers
Screenshot 2021-08-13 100828.png
this is the direct output using filmic with no look
Screenshot 2021-08-13 101256.jpg
here is a demo of using filmic with "high contrast" look
Screenshot 2021-08-13 101355.jpg

As you can see, the "looks" really make filmic looks more pleasent depending on different result.
So, do we have "looks" implemented already? or will we?
User avatar
TAO
Developer
Developer
Posts: 850
Joined: Sun Mar 24, 2019 4:49 pm
Location: France
Contact:

Re: Color spaces support (aka OpenColorIO v2.0)

Post by TAO »

I'm trying to do a quick implementation for OCIO in 3dsmax and blender and i want to know if i get the idea correctly.
Here is what i have in mind.
Add color space rollout In the camera option section below the LUT.
Screenshot 2021-08-13 125105.jpg
Add color space node in the material editor, so it can be used for textures and other nodes.
Screenshot 2021-08-13 125038.jpg
I'm not sure if this is a good approach so i will appreciate any suggestions here.
User avatar
Dade
Developer
Developer
Posts: 5672
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Re: Color spaces support (aka OpenColorIO v2.0)

Post by Dade »

richardbao wrote: Fri Aug 13, 2021 2:25 am So, do we have "looks" implemented already? or will we?
OCIO "Looks" are something similar to a macro: you can get the same result by using/chaining other OCIO tools. However it can get quite complicated so I'm adding the direct support for looks.
Support LuxCoreRender project with salts and bounties
Post Reply