[WIP] Design: Painting Color Management #72424

Open
opened 3 years ago by Jeroen-Bakker · 8 comments
Collaborator

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 3 years ago
Poster
Collaborator

Added subscriber: @Jeroen-Bakker

Added subscriber: @Jeroen-Bakker
Collaborator

Added subscriber: @PabloDobarro

Added subscriber: @PabloDobarro
EAW commented 3 years ago

Added subscriber: @EAW

Added subscriber: @EAW
Jeroen-Bakker changed title from Design: Painting Color Management to [WIP] Design: Painting Color Management 3 years ago

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?
Poster
Collaborator

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
JulienKaspar added this to the Sculpt, Paint & Texture project 2 days ago
lichtwerk removed the
legacy module/Sculpt, Paint & Texture
label 6 hours ago
lichtwerk removed the
Interest/Sculpt, Paint & Texture
label 6 hours ago
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/Collada
Interest/Compositing
Interest/Core
Interest/Cycles
Interest/Dependency Graph
Interest/Development Management
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/Modeling
Interest/Modifiers
Interest/Motion Tracking
Interest/Nodes & Physics
Interest/Overrides
Interest/Performance
Interest/Performance
Interest/Physics
Interest/Pipeline, Assets & I/O
Interest/Platforms, Builds, Tests & Devices
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
legacy module/Animation & Rigging
legacy module/Core
legacy module/Development Management
legacy module/Eevee & Viewport
legacy module/Grease Pencil
legacy module/Modeling
legacy module/Nodes & Physics
legacy module/Pipeline, Assets & IO
legacy module/Platforms, Builds, Tests & Devices
legacy module/Python API
legacy module/Rendering & Cycles
legacy module/Sculpt, Paint & Texture
legacy module/Triaging
legacy module/User Interface
legacy module/VFX & Video
legacy project/1.0.0-beta.2
legacy project/Asset Browser (Archived)
legacy project/BF Blender: 2.8
legacy project/BF Blender: After Release
legacy project/BF Blender: Next
legacy project/BF Blender: Regressions
legacy project/BF Blender: Unconfirmed
legacy project/Blender 2.70
legacy project/Code Quest
legacy project/Datablocks and Libraries
legacy project/Eevee
legacy project/Game Animation
legacy project/Game Audio
legacy project/Game Data Conversion
legacy project/Game Engine
legacy project/Game Logic
legacy project/Game Physics
legacy project/Game Python
legacy project/Game Rendering
legacy project/Game UI
legacy project/GPU / Viewport
legacy project/GSoC
legacy project/Infrastructure: Websites
legacy project/LibOverrides - Usability and UX
legacy project/Milestone 1: Basic, Local Asset Browser
legacy project/Nodes
legacy project/OpenGL Error
legacy project/Papercut
legacy project/Pose Library Basics
legacy project/Retrospective
legacy project/Tracker Curfew
legacy project/Wintab High Frequency
Meta/Good First Issue
Meta/Papercut
migration/requires-manual-verification
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 & Devices
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 Information 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

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#72424
Loading…
There is no content yet.