Color spaces support (aka OpenColorIO v2.0)

Discussion related to the LuxCore functionality, implementations and API.
User avatar
Dade
Developer
Developer
Posts: 5672
Joined: Mon Dec 04, 2017 8:36 pm
Location: Italy

Color spaces support (aka OpenColorIO v2.0)

Post by Dade »

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.
Support LuxCoreRender project with salts and bounties
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 »

Great news I was waiting for it for a long time. Amazing job. now we can use all benefits of OpenColorIO color space.
User avatar
Dez!
Posts: 368
Joined: Sun Apr 08, 2018 1:09 am
Location: Ekaterinburg
Contact:

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

Post by Dez! »

never used it. but now it will be interesting to try. thanks Dade for showing the way to better solutions
Linux Plasma | Ryzen 5, 32Gb, SSD M2, GT 590 RX | BenQ 27 | Wacom One | Microsoft Ergo | Tie Guan Yin tea
http://dezigner.tilda.ws/
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 »

Would Like to see picture of the difference and how it can impact color. :idea:
Support LuxCoreRender project with salts and bounties

Portfolio : https://www.behance.net/DRAVIA
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 »

Sharlybg wrote: Mon Apr 12, 2021 4:27 pm Would Like to see picture of the difference and how it can impact color. :idea:
OpenColorIO, ACES, Filmic, etc. home pages have examples and explanations.
Support LuxCoreRender project with salts and bounties
Martini
Posts: 125
Joined: Fri Nov 23, 2018 11:36 am
Location: Australia

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

Post by Martini »

Hi Dade,

I think there might be a bug with this, when used together with a ColorRamp? :?

I first noticed this when I updated to the 2.6 daily (downloaded binary release from GitHub), on an existing scene with an image texture I was using for Roughness on a Glass material (I noticed it made the glass opaque), but I have been able to reproduce it just with Diffuse color too.

Before adding color spaces first commit:
Commit f932e1a01d3f0ca52512ab104b38801747b871b1
Commit f932e1a01d3f0ca52512ab104b38801747b871b1
After adding color spaces first commit:
Commit 857c1cd2401ab9a31aa27ce5387e2dc0718577c9
Commit 857c1cd2401ab9a31aa27ce5387e2dc0718577c9
The only difference between the three rounded cubes materials is what goes between the texture and the diffuse color socket.
  • On the left, the texture is directly connected to the Matte material Diffuse color
  • In the middle the texture is multiplied by white (i.e. no-op) first. I have also tested this with Remap and the result is still OK
  • On the right is a ColorRamp - broken :oops:
Below is the shader setup showing the issue
Shader setup that produces the issue
Shader setup that produces the issue
During rebuilding I did not touch the external dependencies, so the problem might have been introduced somewhere in commit 857c1cd2401ab9a31aa27ce5387e2dc0718577c9, most likely in src/slg/scene/parsetextures.cpp

Below is a few hours worth of git bisect logs and rebuilding and testing... hope this helps :)

Code: Select all

C:\dev\LuxCoreRender\LuxCore>git bisect log
git bisect start
# bad: [4881b244aea14b5523b3fe697b5d1ee7877c4a95] Removed some debug code from Intel OIDN plugin
git bisect bad 4881b244aea14b5523b3fe697b5d1ee7877c4a95
# good: [c8ae6722a0278fd4824ac93030a31f5139d00cae] Release v2.5
git bisect good c8ae6722a0278fd4824ac93030a31f5139d00cae
# bad: [cf2a27e746c68f593e7fd49b8084fb78b463d455] Merge pull request #521 from julescmay/regualriseCoordinateSystem
git bisect bad cf2a27e746c68f593e7fd49b8084fb78b463d455
# good: [91f66d67e387ba02958a54f5b5eb189713f2866b] Trying to fix OpenColorIO compilation on Windows
git bisect good 91f66d67e387ba02958a54f5b5eb189713f2866b
# good: [91f66d67e387ba02958a54f5b5eb189713f2866b] Trying to fix OpenColorIO compilation on Windows
git bisect good 91f66d67e387ba02958a54f5b5eb189713f2866b
# good: [91f66d67e387ba02958a54f5b5eb189713f2866b] Trying to fix OpenColorIO compilation on Windows
git bisect good 91f66d67e387ba02958a54f5b5eb189713f2866b
# good: [1184c3bf5f0799006f8708bfa9ab9ff6ff10d5ce] Fixed a problem when using chain of shapes with mesh vertex/triangle AOVs (issue #659)
git bisect good 1184c3bf5f0799006f8708bfa9ab9ff6ff10d5ce
# good: [d085b68e2b8ab98d091d54f86ac5805c8af0fc4c] Introduced the generic ColorSpaceConfig class
git bisect good d085b68e2b8ab98d091d54f86ac5805c8af0fc4c
# bad: [5fe191cd3ee027dc84ba17aaccae1f9be018c513] Added the support for color spaces (Nop, LuxCore and OpenColorIO) to light sources
git bisect bad 5fe191cd3ee027dc84ba17aaccae1f9be018c513
# good: [7d1b8281e5cb2a115e90151de43ad7d687929e6f] Added the support for color spaces (LuxCore and OpenColorIO) to constant textures
git bisect good 7d1b8281e5cb2a115e90151de43ad7d687929e6f
# bad: [857c1cd2401ab9a31aa27ce5387e2dc0718577c9] Added the support for color spaces (Nop, LuxCore and OpenColorIO) to implicit definitions of constant textures
git bisect bad 857c1cd2401ab9a31aa27ce5387e2dc0718577c9
# good: [f932e1a01d3f0ca52512ab104b38801747b871b1] Merge with master
git bisect good f932e1a01d3f0ca52512ab104b38801747b871b1
# first bad commit: [857c1cd2401ab9a31aa27ce5387e2dc0718577c9] Added the support for color spaces (Nop, LuxCore and OpenColorIO) to implicit definitions of constant textures
Edit: Sorry, forgot to mention, I'm running Windows 10 64-bit, and Blender 2.92.0
Attachments
ColorSpaces bug.blend
Scene demonstrating the issue
(132.75 KiB) Downloaded 335 times
AMD Ryzen Threadripper PRO 5995WX 64-Cores | 2x Gigabyte RTX 4090 Gaming OC
ASUS Pro WS WRX80E-SAGE SE WIFI | 256GB Kingston Server Premier ECC Unbuffered DDR4
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 »

I should have fixed the problem.
Support LuxCoreRender project with salts and bounties
Martini
Posts: 125
Joined: Fri Nov 23, 2018 11:36 am
Location: Australia

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

Post by Martini »

Yep, seems to be working perfectly again 8-)

Thank you so much! :D
AMD Ryzen Threadripper PRO 5995WX 64-Cores | 2x Gigabyte RTX 4090 Gaming OC
ASUS Pro WS WRX80E-SAGE SE WIFI | 256GB Kingston Server Premier ECC Unbuffered DDR4
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 »

I don't see where in blendluxcore i can switch to this new color spaces.
Like i'm missing something :?:
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. »

It's not yet available there, but it's on the todo list.
Post Reply