Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2018-12-13 17:59:58 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2018-12-13 21:25:45 +0300
commit6601a89650f92454aa57bc01bedebd4086f6d98d (patch)
treee25523b1b8598f64947a727266bd13f7223ca299 /source/blender/imbuf
parent33993c056a557d8c51ff9d01ff3666ab81d40c29 (diff)
Fix T58549, T56741: HSV color picker issues with Filmic view transform.
In 2d655d3 the color picker was changed to use display space HSV values. This works ok for a simple sRGB EOTF, but fails with view transforms like Filmic where display space V 1.0 maps to RGB 16.292. Instead we now use the color_picking role from the OCIO config when converting from RGB to HSV in the color picker. This role is set to sRGB in the default OCIO config. This color space fits the following requirements: * It is approximately perceptually linear, so that the HSV numbers and the HSV cube/circle have an intuitive distribution. * It has the same gamut as the scene linear color space. * Color picking values 0..1 map to scene linear values in the 0..1 range, so that picked albedo values are energy conserving.
Diffstat (limited to 'source/blender/imbuf')
-rw-r--r--source/blender/imbuf/IMB_colormanagement.h3
-rw-r--r--source/blender/imbuf/intern/colormanagement.c66
2 files changed, 68 insertions, 1 deletions
diff --git a/source/blender/imbuf/IMB_colormanagement.h b/source/blender/imbuf/IMB_colormanagement.h
index 8c903af2420..29e54158f4b 100644
--- a/source/blender/imbuf/IMB_colormanagement.h
+++ b/source/blender/imbuf/IMB_colormanagement.h
@@ -96,6 +96,9 @@ void IMB_colormanagement_scene_linear_to_colorspace_v3(float pixel[3], struct Co
void IMB_colormanagement_colorspace_to_scene_linear(float *buffer, int width, int height, int channels, struct ColorSpace *colorspace, bool predivide);
+void IMB_colormanagement_scene_linear_to_color_picking_v3(float pixel[3]);
+void IMB_colormanagement_color_picking_to_scene_linear_v3(float pixel[3]);
+
void IMB_colormanagement_scene_linear_to_display_v3(float pixel[3], struct ColorManagedDisplay *display);
void IMB_colormanagement_display_to_scene_linear_v3(float pixel[3], struct ColorManagedDisplay *display);
diff --git a/source/blender/imbuf/intern/colormanagement.c b/source/blender/imbuf/intern/colormanagement.c
index 5d0e59e1788..f2244b6ab5c 100644
--- a/source/blender/imbuf/intern/colormanagement.c
+++ b/source/blender/imbuf/intern/colormanagement.c
@@ -130,7 +130,14 @@ static struct global_glsl_state {
/* Container for GLSL state needed for OCIO module. */
struct OCIO_GLSLDrawState *ocio_glsl_state;
struct OCIO_GLSLDrawState *transform_ocio_glsl_state;
-} global_glsl_state;
+} global_glsl_state = {NULL};
+
+static struct global_color_picking_state {
+ /* Cached processor for color picking conversion. */
+ OCIO_ConstProcessorRcPtr *processor_to;
+ OCIO_ConstProcessorRcPtr *processor_from;
+ bool failed;
+} global_color_picking_state = {NULL};
/*********************** Color managed cache *************************/
@@ -699,6 +706,15 @@ void colormanagement_exit(void)
if (global_glsl_state.transform_ocio_glsl_state)
OCIO_freeOGLState(global_glsl_state.transform_ocio_glsl_state);
+ if (global_color_picking_state.processor_to)
+ OCIO_processorRelease(global_color_picking_state.processor_to);
+
+ if (global_color_picking_state.processor_from)
+ OCIO_processorRelease(global_color_picking_state.processor_from);
+
+ memset(&global_glsl_state, 0, sizeof(global_glsl_state));
+ memset(&global_color_picking_state, 0, sizeof(global_color_picking_state));
+
colormanage_free_config();
}
@@ -1911,6 +1927,54 @@ void IMB_colormanagement_colorspace_to_scene_linear(float *buffer, int width, in
}
}
+void IMB_colormanagement_scene_linear_to_color_picking_v3(float pixel[3])
+{
+ if (!global_color_picking_state.processor_to && !global_color_picking_state.failed) {
+ /* Create processor if none exists. */
+ BLI_mutex_lock(&processor_lock);
+
+ if (!global_color_picking_state.processor_to && !global_color_picking_state.failed) {
+ global_color_picking_state.processor_to =
+ create_colorspace_transform_processor(global_role_scene_linear,
+ global_role_color_picking);
+
+ if (!global_color_picking_state.processor_to) {
+ global_color_picking_state.failed = true;
+ }
+ }
+
+ BLI_mutex_unlock(&processor_lock);
+ }
+
+ if (global_color_picking_state.processor_to) {
+ OCIO_processorApplyRGB(global_color_picking_state.processor_to, pixel);
+ }
+}
+
+void IMB_colormanagement_color_picking_to_scene_linear_v3(float pixel[3])
+{
+ if (!global_color_picking_state.processor_from && !global_color_picking_state.failed) {
+ /* Create processor if none exists. */
+ BLI_mutex_lock(&processor_lock);
+
+ if (!global_color_picking_state.processor_from && !global_color_picking_state.failed) {
+ global_color_picking_state.processor_from =
+ create_colorspace_transform_processor(global_role_color_picking,
+ global_role_scene_linear);
+
+ if (!global_color_picking_state.processor_from) {
+ global_color_picking_state.failed = true;
+ }
+ }
+
+ BLI_mutex_unlock(&processor_lock);
+ }
+
+ if (global_color_picking_state.processor_from) {
+ OCIO_processorApplyRGB(global_color_picking_state.processor_from, pixel);
+ }
+}
+
/* convert pixel from scene linear to display space using default view
* used by performance-critical areas such as color-related widgets where we want to reduce
* amount of per-widget allocations