[WIP] Design: Painting Color Management #72424

Open
opened 2019-12-13 16:28:33 +01:00 by Jeroen Bakker · 8 comments
Member

This design are based on the next principles:

  • When mixing colors, do it always in the linear scene reference space. For Blender that is linear REC709.
  • Include the color space when storing colors for color picker and don't convert it the color channels.

Issues

Current issues we try to solve:

  • #68242 (Color space seems wrong while painting in image editor.)
  • Color picker stores in sRGB or linear REC709. the storage is defined by the RNA (COLOR, COLOR_GAMMA). Since blender 2.80 the default color picker is set to HSV, what has some usability issues (HSV has multiple values that represents the same black in sRGB and linear REC709). User notice this when they set Value to 0, that the next time they open the color picker that the HUE and Saturation are also set to 0.

Scoping

The solution is focused on Sculpt/Paint brushes, but will be reusable in other areas. The solution is designed on single colors. ImBuf should be used when working with buffers. Changes to ImBuf are not in scope.

Proposal

Proposal is to implement a framework for color picking and mixing colors. To test the framework we include the first implementation in the Paint and Sculpt Brushes. The idea of this approach is to be more explicit when colors are being used.

DNA

In DNA_color_types.h add a struct that can store a color and relevant information of the color.

typedef struct Color_RUNTIME_Color {
    float color_straight_alpha[4];
    float color_premult_alpha[4];
} Color_RUNTIME_Color;

typedef struct Color_RUNTIME {
    /* flag contains the validity of the other fields */
    int flag;
    Color_RUNTIME_Color linear_scene;
    Color_RUNTIME_Color display;

    ...

} Color_RUNTIME;

typedef struct Color3 {
    float components[3];
    float alpha;
    ColorManagedColorspaceSettings color_space;
    Color_RUNTIME runtime;
} Color3;

Color3.alpha is always stored as straight alpha.
The runtime caches common conversions of the color in different OpenColorIO roles and alpha association. The Color3.runtime field will be flagged to be invalid when the scene color management is changed or a different scene is loaded. The runtime is also updated when the color management roles in the scene are changed, a another scene is loaded.

In DNA_brush_types.h deprecate the rgb and alpha and add a new field Color3 color;.

BKE

Add functions in BKE_colortools.h for getting the values for a color in a specific OCIO Role, invalidate all runtime fields in loaded data, invalidate one runtime field.

UI

Update the color picker template to support this data structure. This also means that we don't do the pixel read to find the selected color, but interpret the screen coordinate on the wheel to find our what color has been picked.

Painting/Brushes

When doing this change a lot of compile errors needs to be fixed. This gives us the opportunity to migrate them to the new implementation and make sure we tackle these cases. Textures still needs special attention.

OCIO

The color configuration needs to be adjusted with color spaces for the color picker role.

This design are based on the next principles: * When mixing colors, do it always in the linear scene reference space. For Blender that is linear REC709. * Include the color space when storing colors for color picker and don't convert it the color channels. **Issues** Current issues we try to solve: * #68242 (Color space seems wrong while painting in image editor.) * Color picker stores in sRGB or linear REC709. the storage is defined by the RNA (COLOR, COLOR_GAMMA). Since blender 2.80 the default color picker is set to HSV, what has some usability issues (HSV has multiple values that represents the same black in sRGB and linear REC709). User notice this when they set `Value` to 0, that the next time they open the color picker that the `HUE` and `Saturation` are also set to 0. **Scoping** The solution is focused on Sculpt/Paint brushes, but will be reusable in other areas. The solution is designed on single colors. `ImBuf` should be used when working with buffers. Changes to `ImBuf` are not in scope. **Proposal** Proposal is to implement a framework for color picking and mixing colors. To test the framework we include the first implementation in the Paint and Sculpt Brushes. The idea of this approach is to be more explicit when colors are being used. __DNA__ In `DNA_color_types.h` add a struct that can store a color and relevant information of the color. ``` typedef struct Color_RUNTIME_Color { float color_straight_alpha[4]; float color_premult_alpha[4]; } Color_RUNTIME_Color; typedef struct Color_RUNTIME { /* flag contains the validity of the other fields */ int flag; Color_RUNTIME_Color linear_scene; Color_RUNTIME_Color display; ... } Color_RUNTIME; typedef struct Color3 { float components[3]; float alpha; ColorManagedColorspaceSettings color_space; Color_RUNTIME runtime; } Color3; ``` `Color3.alpha` is always stored as straight alpha. The runtime caches common conversions of the color in different OpenColorIO roles and alpha association. The `Color3.runtime` field will be flagged to be invalid when the scene color management is changed or a different scene is loaded. The runtime is also updated when the color management roles in the scene are changed, a another scene is loaded. In `DNA_brush_types.h` deprecate the `rgb` and `alpha` and add a new field `Color3 color;`. __BKE__ Add functions in `BKE_colortools.h` for getting the values for a color in a specific OCIO Role, invalidate all `runtime` fields in loaded data, invalidate one `runtime` field. __UI__ Update the color picker template to support this data structure. This also means that we don't do the pixel read to find the selected color, but interpret the screen coordinate on the wheel to find our what color has been picked. __Painting/Brushes__ When doing this change a lot of compile errors needs to be fixed. This gives us the opportunity to migrate them to the new implementation and make sure we tackle these cases. Textures still needs special attention. __OCIO__ The color configuration needs to be adjusted with color spaces for the color picker role.
Jeroen Bakker self-assigned this 2019-12-13 16:28:33 +01:00
Author
Member

Added subscriber: @Jeroen-Bakker

Added subscriber: @Jeroen-Bakker
Member

Added subscriber: @PabloDobarro

Added subscriber: @PabloDobarro
Member

Added subscriber: @EAW

Added subscriber: @EAW
Jeroen Bakker changed title from Design: Painting Color Management to [WIP] Design: Painting Color Management 2019-12-15 15:16:58 +01:00

Added subscriber: @frameshift

Added subscriber: @frameshift

Looking good as far as I can tell. A few things:

When mixing colors, do it always in the linear scene reference space. For Blender that is linear REC709.

As Troy pointed out in Blender.chat, please get rid of any assumptions like this, anywhere. I don't think you'd find it unlikely that I can show you an instance of Blender with a reference space that's not even close to Rec. 709 ;)

Include the color space when storing colors for color picker

Is this necessary once Blender completely relies on OCIO roles?

Looking good as far as I can tell. A few things: > When mixing colors, do it always in the linear scene reference space. For Blender that is linear REC709. As Troy pointed out in Blender.chat, please get rid of any assumptions like this, anywhere. I don't think you'd find it unlikely that I can show you an instance of Blender with a reference space that's not even close to Rec. 709 ;) > Include the color space when storing colors for color picker Is this necessary once Blender completely relies on OCIO roles?
Author
Member

I will, I do want to re-validate other things in this patch.

There are several likely user stories that storing ocio roles doesn't address:

  • Open Blender, select different color picker role, all colors will change.
  • Blender has multiple color picker modes where the color space is fixed to sRGB or linear pending on what property you are working with.

From a user perspective this could also be implemented by using a color space that is able to restore the components of the different modes. But does such a color space exist? If so yes we can use a color role for storing; if not we might want to store the color space itself as proposed or another solution we can come up with.

When back in office I will update the design on this topic.

I will, I do want to re-validate other things in this patch. There are several likely user stories that storing ocio roles doesn't address: * Open Blender, select different color picker role, all colors will change. * Blender has multiple color picker modes where the color space is fixed to sRGB or linear pending on what property you are working with. From a user perspective this could also be implemented by using a color space that is able to restore the components of the different modes. But does such a color space exist? If so yes we can use a color role for storing; if not we might want to store the color space itself as proposed or another solution we can come up with. When back in office I will update the design on this topic.

I just reported #77736, totally forgot about this design task.
I would however like to stress that it's necessary for the colour picker to allow the user to choose between a display space and the scene linear space when colour picking. In any context. Shader nodes, texture painting, vertex colours, you name it.
Internally, always consider the scene linear values, but expose the alternative in the UI.

@Jeroen-Bakker any news on this?

I just reported #77736, totally forgot about this design task. I would however like to stress that it's necessary for the colour picker to *allow the user to choose* between **a** display space and **the** scene linear space when colour picking. *In any context.* Shader nodes, texture painting, vertex colours, you name it. Internally, always consider the scene linear values, but expose the alternative in the UI. @Jeroen-Bakker any news on this?

Added subscriber: @end_ahmed

Added subscriber: @end_ahmed
Julien Kaspar added this to the Sculpt, Paint & Texture project 2023-02-08 10:26:20 +01:00
Philipp Oeser removed the
Interest
Sculpt, Paint & Texture
label 2023-02-10 09:12:45 +01:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No Assignees
5 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#72424
No description provided.