OpenColorIO and Krita: processing and drawing HDR images

Images with a wide dynamic range will not surprise anyone. Probably everyone at least once in their life tried to create an HDR photo. However, few people know that this technology has been used in the film industry for more than ten years, and all conveyor workflows, from creating textures to rendering the finished scene, are closely related to working in linear color spaces represented by floating point numbers.

In this article I will try to explain what a stage-oriented color management workflow is, why the OpenColorIO library is needed, and how to set up work in the OpenColorIO environment in the free graphics editor for Krita artists.

What is OpenColorIO?


OpenColorIO (OCIO) is a color library for the film industry. In particular, she was used to make Spider-Man 2 (2004) and Alice in Wonderland (2010). OpenColorIO is designed to convert all color spaces that are encountered as the image progresses along the pipeline.

Example. The texture maker created the texture in the sRGB color space, 8-bit per channel. When moving further along the conveyor, the texture gets to the modeler, who, to impose it on the model, translates it into linear RGB, 16-bit floating point. The scene is rendered again in linear RGB, 32-bit floating point, and the final result is translated back to sRGB8 so that it can be displayed on a standard monitor.

For thought at your leisure
Why, before applying texture to the model and, in particular, before generating mipmaps (MIP pyramids), should the texture be converted to linear color space? What threatens sRGB?

Obviously, all these transformations must somehow be described. Moreover, it is desirable that they be described centrally, because one film can work not just a few people, but several teams or even companies, each of which has its own rules and standards. This problem is precisely what OpenColorIO solves.

All workflow parameters in OpenColorIO are determined by the so-called configuration, which is usually just a directory with a text file config.ocioand look-up table, LUT files. The configuration file describes all the transformations between the color spaces used in the pipeline. So in order to ensure uniform color work for all artists, it will be enough to send them this configuration and ask them to register the path to it in the environment variable$OCIO. All OCIO-enabled applications will read this variable and will automatically use the correct settings.

Examples of configurations can be found on the official website .

Why not ICC?


Many probably already wondered why this OpenColorIO is needed when there is an ICC profile mechanism standardized by the International Color Consortium?
Many, many technical details for those interested
Yes, indeed, ICC profiles solve a similar problem. They also describe how to convert color from space A to space B. But they have one feature: all the connections in them are made through the absolute spaces L * a * b or CIE XYZ. This was done on purpose. When using ICC profiles, the user wants the image to look the same on all output devices. Moreover, the user most likely does not have access to the devices themselves. They may be on the other side of the street (city, country or globe), but the image should still look the same. In this case, without reference to the reference color spaces can not do.

In the case of the process of creating a movie, everything looks a little different. The task of connecting different output devices is relegated to the background (they can somehow cope with profiling monitors in a professional studio), but a new requirement arises: transformations must take place without loss. Moreover, for them there must be inverse transformations that also do not lead to distortions. Indeed, consider a simple example. After scanning from the film, we get the file in a logarithmic color space, then convert it to linear to perform compositing, and then to display on the monitor we apply the inverse transformation with a power of 2.2. Obviously, with such transformations, the errors in the lights are 1 bit (244 <->

Here, OpenColorIO with its centralization enters the scene. All color spaces with which they will work at each stage of creating a film are designed before the start of work. The transformations between them are chosen one-to-one so that the image can move without loss both along the conveyor and in the opposite direction. These transformations are set directly, without using bindings to the L * a * b or CIE XYZ reference spaces, which would instantly bring a lot of problems (at least, constant conversion of the white point value back and forth, for L * a * b and CIE XYZ it is defined standard - D50). So conversions in OpenColorIO are simpler and are often described by simple mathematical expressions.

Thus, the finished configuration of OpenColorIO defines a closed set of color spaces in which artists can work and are guaranteed to get a high-quality result. In a way, the less versatility and complexity of adding a new space acts as a limiter and protects artists from using unverified color spaces.

To some extent, OpenColorIO belongs to a lower level of abstractions than ICC, much like assembler is below high-level languages. Similarly, an artist, using OpenColoIO, gets much more features that are not available in high-level tools. Of course, at the cost of great knowledge and some complication of the concepts used.

Scene-referred vs. output-referred workflow


Most people are accustomed to believing that ICC profiles and all this venture with color management are needed only in order to correctly output the file to the printer (minilab, typography). In general, they are right. Such a workflow, when a file is being prepared for a specific output device, is usually called an output-referred workflow. However, what if your picture is eventually displayed on multiple media? For example, a scene from a movie will be displayed at least on a monitor, projector and film. Each device has its own characteristics, its own gamma and its own dynamic range. What workspace to choose and how to work with it?

To solve this problem, when making films we went a different way. All work takes place in linear RGB space with unlimited dynamic range (RGB channel values ​​can easily exceed 1.0). Rendering, the generation of special effects, everything happens in this artificial space, and only at the final stage of the project, when you need to display the image on a specific device, it is brought to the standard range 0.0 ... 1.0 (compress or crop) and sent to the device. Such workflow called scene-oriented (scene-referred).

Features Critics for working with color


Krita supports work in both device-oriented and scene-oriented workflows. At the same time, work is supported both with ICC profiles and with the global OpenColorIO settings. Next, consider both of the Krita settings.

Connecting monitor calibration and profiling data to Crete (ICC profile)

When OCIO is disabled or if OCIO is operating in mode Internal, it uses the ICC profile specified in the settings (or received from the X server) to render the image on the screen of Crete. To get accurate color reproduction, you need to follow a few simple steps:

  1. Calibrate the monitor and build its profile. Under Linux, this can be done using dispcalGUI(verified with X-Rite i1Display 2). An ICC profile will be received at the output.
  2. Download the VCGT-tag (Video Card Gamma Table) stored in the ICC profile into the LUT of the video card. Under Linux, this can be done with xcalibor dispwin. Under Windows, just select it in the system settings. At this point, the monitor will become calibrated, but the profiling data will not be active yet.
  3. Choose a monitor profile Crete settings: Preferences->Color Management.

Now the color of all images will be displayed correctly.

Creating an OpenColorIO configuration with monitor profile data

One of the advantages of OpenColorIO for us is that when it is used, it becomes possible to transfer color-related calculations to the GPU, thereby significantly accelerating rendering. It is far from a fact that ordinary users will need to create and describe their own color spaces, but acceleration of work will be needed for sure. As an example, we’ll create a configuration that will take into account data on monitor profiling.

Working with OpenColorIO is a bit more complicated than working with ICC, as we need to explicitly create a transformation for each input color space that we will use. Create a conversion that converts colors from sRGB to monitor space.

To do this, we need to create a 3D LUT table for this conversion. In dispcalGUIselectTools->Create 3D LUT, we select sRGB as the source space, and the ICC profile of the monitor as the target. The resulting file is saved in a subdirectory of the lutstest configuration under the name srgb_to_monitor.3dl. Now, when this configuration is activated, the color space of the image will be converted to monitor space using OpenColorIO tools. If openGL mode is active, then all calculations will take place on the GPU.

Drawing HDR images in Crete


A conventional monitor is clearly not an HDR device, so special tricks are used to display and edit a file with a wide dynamic range. The artist, working with the work, can choose which part of the range he wants to work at the moment. To do this, it has settings Экспозицииand Гамма-коррекции, which are used only when rendering on the display and do not affect the data stored in the file. Changing the exposure compresses or vice versa stretches the range, and changing the gamma value changes the steepness of the conversion curve. You can change the current exposure value with a simple gesture: just hold down the 'Y' key and drag the canvas with your mouse. Exposure will change dynamically. A similar gesture can be assigned to change the gamma.

A feature of Krita is that it has color selection tools that are aware of all the transformations that occur with the image before it is displayed on the display. Therefore, the colors in the color selection panels are displayed exactly as they will look when drawing, whatever the exposure settings, gamma and color spaces at the moment. Moreover, when changing the display settings, Crete will try to adjust the current drawing color so that with the new settings it looks exactly the same as with the previous ones, and the user can continue to draw in the same color. This is not always possible, since conversion to the color space of the monitor is often irreversible. In such cases, when changing the exposure and gamma settings, you will see how the current selected color changes slightly.

Thus, Krita allows you to draw an image without thinking about the current exposure value. Just change the current range with a gesture and draw.

Bonus for reading to the end:

HDR landscape from Wolthera van Hövell tot Westerflier


HDR scene by Timothée Giet


Instead of a conclusion


In this article, I tried to tell you what methods of working with images are used in the film industry and what functionality Crete offers to support these processes.
This functionality has been added to the main branch recently and many things require improvement in terms of user experience. We are working on it and accept any wishes regarding this.

Also popular now: