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/editors/interface/interface_handlers.c
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/editors/interface/interface_handlers.c')
-rw-r--r--source/blender/editors/interface/interface_handlers.c46
1 files changed, 10 insertions, 36 deletions
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 3a3259e8d1f..3949c1e2d50 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -5440,7 +5440,6 @@ static bool ui_numedit_but_HSVCUBE(
float x, y;
float mx_fl, my_fl;
bool changed = true;
- bool use_display_colorspace = ui_but_is_colorpicker_display_space(but);
ui_mouse_scale_warp(data, mx, my, &mx_fl, &my_fl, shift);
@@ -5454,9 +5453,7 @@ static bool ui_numedit_but_HSVCUBE(
#endif
ui_but_v3_get(but, rgb);
-
- if (use_display_colorspace)
- ui_block_cm_to_display_space_v3(but->block, rgb);
+ ui_scene_linear_to_color_picker_space(but, rgb);
ui_rgb_to_color_picker_HSVCUBE_compat_v(but, rgb, hsv);
@@ -5469,8 +5466,7 @@ static bool ui_numedit_but_HSVCUBE(
/* calculate original hsv again */
copy_v3_v3(rgb, data->origvec);
- if (use_display_colorspace)
- ui_block_cm_to_display_space_v3(but->block, rgb);
+ ui_scene_linear_to_color_picker_space(but, rgb);
copy_v3_v3(hsvo, hsv);
@@ -5518,9 +5514,6 @@ static bool ui_numedit_but_HSVCUBE(
{
/* vertical 'value' strip */
float min = but->softmin, max = but->softmax;
- if (use_display_colorspace) {
- ui_block_cm_to_display_space_range(but->block, &min, &max);
- }
/* exception only for value strip - use the range set in but->min/max */
hsv[2] = y * (max - min) + min;
break;
@@ -5537,9 +5530,7 @@ static bool ui_numedit_but_HSVCUBE(
}
ui_color_picker_to_rgb_HSVCUBE_v(but, hsv, rgb);
-
- if (use_display_colorspace)
- ui_block_cm_to_scene_linear_v3(but->block, rgb);
+ ui_color_picker_to_scene_linear_space(but, rgb);
/* clamp because with color conversion we can exceed range [#34295] */
if (but->a1 == UI_GRAD_V_ALT) {
@@ -5565,13 +5556,9 @@ static void ui_ndofedit_but_HSVCUBE(
const float hsv_v_max = max_ff(hsv[2], but->softmax);
float rgb[3];
float sensitivity = (shift ? 0.15f : 0.3f) * ndof->dt;
- bool use_display_colorspace = ui_but_is_colorpicker_display_space(but);
ui_but_v3_get(but, rgb);
-
- if (use_display_colorspace)
- ui_block_cm_to_display_space_v3(but->block, rgb);
-
+ ui_scene_linear_to_color_picker_space(but, rgb);
ui_rgb_to_color_picker_HSVCUBE_compat_v(but, rgb, hsv);
switch ((int)but->a1) {
@@ -5620,9 +5607,7 @@ static void ui_ndofedit_but_HSVCUBE(
hsv_clamp_v(hsv, hsv_v_max);
ui_color_picker_to_rgb_HSVCUBE_v(but, hsv, rgb);
-
- if (use_display_colorspace)
- ui_block_cm_to_scene_linear_v3(but->block, rgb);
+ ui_color_picker_to_scene_linear_space(but, rgb);
copy_v3_v3(data->vec, rgb);
ui_but_v3_set(but, data->vec);
@@ -5737,7 +5722,6 @@ static bool ui_numedit_but_HSVCIRCLE(
float rgb[3];
ColorPicker *cpicker = but->custom_data;
float *hsv = cpicker->color_data;
- bool use_display_colorspace = ui_but_is_colorpicker_display_space(but);
ui_mouse_scale_warp(data, mx, my, &mx_fl, &my_fl, shift);
@@ -5760,9 +5744,7 @@ static bool ui_numedit_but_HSVCIRCLE(
BLI_rcti_rctf_copy(&rect, &but->rect);
ui_but_v3_get(but, rgb);
- if (use_display_colorspace)
- ui_block_cm_to_display_space_v3(but->block, rgb);
-
+ ui_scene_linear_to_color_picker_space(but, rgb);
ui_rgb_to_color_picker_compat_v(rgb, hsv);
/* exception, when using color wheel in 'locked' value state:
@@ -5784,9 +5766,7 @@ static bool ui_numedit_but_HSVCIRCLE(
/* calculate original hsv again */
copy_v3_v3(hsvo, hsv);
copy_v3_v3(rgbo, data->origvec);
- if (use_display_colorspace)
- ui_block_cm_to_display_space_v3(but->block, rgbo);
-
+ ui_scene_linear_to_color_picker_space(but, rgbo);
ui_rgb_to_color_picker_compat_v(rgbo, hsvo);
/* and original position */
@@ -5812,9 +5792,7 @@ static bool ui_numedit_but_HSVCIRCLE(
normalize_v3_length(rgb, but->a2);
}
- if (use_display_colorspace)
- ui_block_cm_to_scene_linear_v3(but->block, rgb);
-
+ ui_color_picker_to_scene_linear_space(but, rgb);
ui_but_v3_set(but, rgb);
data->draglastx = mx;
@@ -5831,14 +5809,12 @@ static void ui_ndofedit_but_HSVCIRCLE(
{
ColorPicker *cpicker = but->custom_data;
float *hsv = cpicker->color_data;
- bool use_display_colorspace = ui_but_is_colorpicker_display_space(but);
float rgb[3];
float phi, r /*, sqr */ /* UNUSED */, v[2];
float sensitivity = (shift ? 0.06f : 0.3f) * ndof->dt;
ui_but_v3_get(but, rgb);
- if (use_display_colorspace)
- ui_block_cm_to_display_space_v3(but->block, rgb);
+ ui_scene_linear_to_color_picker_space(but, rgb);
ui_rgb_to_color_picker_compat_v(rgb, hsv);
/* Convert current color on hue/sat disc to circular coordinates phi, r */
@@ -5889,9 +5865,7 @@ static void ui_ndofedit_but_HSVCIRCLE(
normalize_v3_length(data->vec, but->a2);
}
- if (use_display_colorspace)
- ui_block_cm_to_scene_linear_v3(but->block, data->vec);
-
+ ui_color_picker_to_scene_linear_space(but, data->vec);
ui_but_v3_set(but, data->vec);
}
#endif /* WITH_INPUT_NDOF */