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:
authorDalai Felinto <dalai@blender.org>2022-05-23 16:57:33 +0300
committerDalai Felinto <dalai@blender.org>2022-05-23 16:57:33 +0300
commit3e4f84d10d248fd44ad7365f102ba1a44d655fe3 (patch)
treee59ef5067cb69620f641a5f7d87786bf3a5c40ac /source/blender/imbuf
parent09292b89c3354dc099f3f1f1c37ad3bfbdb53dff (diff)
parenteb5e7d0a31eed698909c23ab0ca89c8fd4929365 (diff)
Merge remote-tracking branch 'origin/blender-v3.2-release'
Diffstat (limited to 'source/blender/imbuf')
-rw-r--r--source/blender/imbuf/IMB_colormanagement.h30
-rw-r--r--source/blender/imbuf/intern/IMB_colormanagement_intern.h8
-rw-r--r--source/blender/imbuf/intern/colormanagement.c56
-rw-r--r--source/blender/imbuf/intern/colormanagement_inline.c40
4 files changed, 93 insertions, 41 deletions
diff --git a/source/blender/imbuf/IMB_colormanagement.h b/source/blender/imbuf/IMB_colormanagement.h
index 1f0ed4cafbe..50af946cd95 100644
--- a/source/blender/imbuf/IMB_colormanagement.h
+++ b/source/blender/imbuf/IMB_colormanagement.h
@@ -72,9 +72,21 @@ BLI_INLINE float IMB_colormanagement_get_luminance(const float rgb[3]);
* Byte equivalent of #IMB_colormanagement_get_luminance().
*/
BLI_INLINE unsigned char IMB_colormanagement_get_luminance_byte(const unsigned char[3]);
-BLI_INLINE void IMB_colormanagement_xyz_to_rgb(float rgb[3], const float xyz[3]);
-BLI_INLINE void IMB_colormanagement_rgb_to_xyz(float xyz[3], const float rgb[3]);
-const float *IMB_colormanagement_get_xyz_to_rgb(void);
+
+/**
+ * Conversion between scene linear and other color spaces.
+ */
+BLI_INLINE void IMB_colormanagement_xyz_to_scene_linear(float scene_linear[3], const float xyz[3]);
+BLI_INLINE void IMB_colormanagement_scene_linear_to_xyz(float xyz[3], const float scene_linear[3]);
+BLI_INLINE void IMB_colormanagement_rec709_to_scene_linear(float scene_linear[3],
+ const float rec709[3]);
+BLI_INLINE void IMB_colormanagement_scene_linear_to_rec709(float rec709[3],
+ const float scene_linear[3]);
+BLI_INLINE void IMB_colormanagement_aces_to_scene_linear(float scene_linear[3],
+ const float aces[3]);
+BLI_INLINE void IMB_colormanagement_scene_linear_to_aces(float aces[3],
+ const float scene_linear[3]);
+const float *IMB_colormanagement_get_xyz_to_scene_linear(void);
/** \} */
@@ -188,15 +200,19 @@ void IMB_colormanagement_imbuf_to_float_texture(float *out_buffer,
* - Color picking values 0..1 map to scene linear values in the 0..1 range,
* so that picked albedo values are energy conserving.
*/
-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_color_picking_v3(float color_picking[3],
+ const float scene_linear[3]);
+void IMB_colormanagement_color_picking_to_scene_linear_v3(float scene_linear[3],
+ const float color_picking[3]);
/**
* Conversion between sRGB, for rare cases like hex color or copy/pasting
* between UI theme and scene linear colors.
*/
-void IMB_colormanagement_scene_linear_to_srgb_v3(float pixel[3]);
-void IMB_colormanagement_srgb_to_scene_linear_v3(float pixel[3]);
+BLI_INLINE void IMB_colormanagement_scene_linear_to_srgb_v3(float srgb[3],
+ const float scene_linear[3]);
+BLI_INLINE void IMB_colormanagement_srgb_to_scene_linear_v3(float scene_linear[3],
+ const float srgb[3]);
/**
* Convert pixel from scene linear to display space using default view
diff --git a/source/blender/imbuf/intern/IMB_colormanagement_intern.h b/source/blender/imbuf/intern/IMB_colormanagement_intern.h
index c89b15480a2..23b3f0191b7 100644
--- a/source/blender/imbuf/intern/IMB_colormanagement_intern.h
+++ b/source/blender/imbuf/intern/IMB_colormanagement_intern.h
@@ -18,8 +18,12 @@ struct ImBuf;
struct OCIO_ConstCPUProcessorRcPtr;
extern float imbuf_luma_coefficients[3];
-extern float imbuf_xyz_to_rgb[3][3];
-extern float imbuf_rgb_to_xyz[3][3];
+extern float imbuf_scene_linear_to_xyz[3][3];
+extern float imbuf_xyz_to_scene_linear[3][3];
+extern float imbuf_scene_linear_to_aces[3][3];
+extern float imbuf_aces_to_scene_linear[3][3];
+extern float imbuf_scene_linear_to_rec709[3][3];
+extern float imbuf_rec709_to_scene_linear[3][3];
#define MAX_COLORSPACE_NAME 64
#define MAX_COLORSPACE_DESCRIPTION 512
diff --git a/source/blender/imbuf/intern/colormanagement.c b/source/blender/imbuf/intern/colormanagement.c
index d2ede758023..014efaa4aba 100644
--- a/source/blender/imbuf/intern/colormanagement.c
+++ b/source/blender/imbuf/intern/colormanagement.c
@@ -73,10 +73,12 @@ static int global_tot_looks = 0;
/* Luma coefficients and XYZ to RGB to be initialized by OCIO. */
float imbuf_luma_coefficients[3] = {0.0f};
-float imbuf_xyz_to_rgb[3][3] = {{0.0f}};
-float imbuf_rgb_to_xyz[3][3] = {{0.0f}};
-static float imbuf_xyz_to_linear_srgb[3][3] = {{0.0f}};
-static float imbuf_linear_srgb_to_xyz[3][3] = {{0.0f}};
+float imbuf_scene_linear_to_xyz[3][3] = {{0.0f}};
+float imbuf_xyz_to_scene_linear[3][3] = {{0.0f}};
+float imbuf_scene_linear_to_rec709[3][3] = {{0.0f}};
+float imbuf_rec709_to_scene_linear[3][3] = {{0.0f}};
+float imbuf_scene_linear_to_aces[3][3] = {{0.0f}};
+float imbuf_aces_to_scene_linear[3][3] = {{0.0f}};
/* lock used by pre-cached processors getters, so processor wouldn't
* be created several times
@@ -573,10 +575,16 @@ static void colormanage_load_config(OCIO_ConstConfigRcPtr *config)
/* Load luminance coefficients. */
OCIO_configGetDefaultLumaCoefs(config, imbuf_luma_coefficients);
- OCIO_configGetXYZtoRGB(config, imbuf_xyz_to_rgb);
- invert_m3_m3(imbuf_rgb_to_xyz, imbuf_xyz_to_rgb);
- copy_m3_m3(imbuf_xyz_to_linear_srgb, OCIO_XYZ_TO_LINEAR_SRGB);
- invert_m3_m3(imbuf_linear_srgb_to_xyz, imbuf_xyz_to_linear_srgb);
+
+ /* Load standard color spaces. */
+ OCIO_configGetXYZtoSceneLinear(config, imbuf_xyz_to_scene_linear);
+ invert_m3_m3(imbuf_scene_linear_to_xyz, imbuf_xyz_to_scene_linear);
+
+ mul_m3_m3m3(imbuf_scene_linear_to_rec709, OCIO_XYZ_TO_REC709, imbuf_scene_linear_to_xyz);
+ invert_m3_m3(imbuf_rec709_to_scene_linear, imbuf_scene_linear_to_rec709);
+
+ mul_m3_m3m3(imbuf_aces_to_scene_linear, imbuf_xyz_to_scene_linear, OCIO_ACES_TO_XYZ);
+ invert_m3_m3(imbuf_scene_linear_to_aces, imbuf_aces_to_scene_linear);
}
static void colormanage_free_config(void)
@@ -1418,9 +1426,9 @@ bool IMB_colormanagement_space_name_is_srgb(const char *name)
return (colorspace && IMB_colormanagement_space_is_srgb(colorspace));
}
-const float *IMB_colormanagement_get_xyz_to_rgb()
+const float *IMB_colormanagement_get_xyz_to_scene_linear()
{
- return &imbuf_xyz_to_rgb[0][0];
+ return &imbuf_xyz_to_scene_linear[0][0];
}
/** \} */
@@ -2313,7 +2321,8 @@ void IMB_colormanagement_imbuf_to_float_texture(float *out_buffer,
}
}
-void IMB_colormanagement_scene_linear_to_color_picking_v3(float pixel[3])
+void IMB_colormanagement_scene_linear_to_color_picking_v3(float color_picking[3],
+ const float scene_linear[3])
{
if (!global_color_picking_state.cpu_processor_to && !global_color_picking_state.failed) {
/* Create processor if none exists. */
@@ -2335,12 +2344,15 @@ void IMB_colormanagement_scene_linear_to_color_picking_v3(float pixel[3])
BLI_mutex_unlock(&processor_lock);
}
+ copy_v3_v3(color_picking, scene_linear);
+
if (global_color_picking_state.cpu_processor_to) {
- OCIO_cpuProcessorApplyRGB(global_color_picking_state.cpu_processor_to, pixel);
+ OCIO_cpuProcessorApplyRGB(global_color_picking_state.cpu_processor_to, color_picking);
}
}
-void IMB_colormanagement_color_picking_to_scene_linear_v3(float pixel[3])
+void IMB_colormanagement_color_picking_to_scene_linear_v3(float scene_linear[3],
+ const float color_picking[3])
{
if (!global_color_picking_state.cpu_processor_from && !global_color_picking_state.failed) {
/* Create processor if none exists. */
@@ -2362,25 +2374,13 @@ void IMB_colormanagement_color_picking_to_scene_linear_v3(float pixel[3])
BLI_mutex_unlock(&processor_lock);
}
+ copy_v3_v3(scene_linear, color_picking);
+
if (global_color_picking_state.cpu_processor_from) {
- OCIO_cpuProcessorApplyRGB(global_color_picking_state.cpu_processor_from, pixel);
+ OCIO_cpuProcessorApplyRGB(global_color_picking_state.cpu_processor_from, scene_linear);
}
}
-void IMB_colormanagement_scene_linear_to_srgb_v3(float pixel[3])
-{
- mul_m3_v3(imbuf_rgb_to_xyz, pixel);
- mul_m3_v3(imbuf_xyz_to_linear_srgb, pixel);
- linearrgb_to_srgb_v3_v3(pixel, pixel);
-}
-
-void IMB_colormanagement_srgb_to_scene_linear_v3(float pixel[3])
-{
- srgb_to_linearrgb_v3_v3(pixel, pixel);
- mul_m3_v3(imbuf_linear_srgb_to_xyz, pixel);
- mul_m3_v3(imbuf_xyz_to_rgb, pixel);
-}
-
void IMB_colormanagement_scene_linear_to_display_v3(float pixel[3], ColorManagedDisplay *display)
{
OCIO_ConstCPUProcessorRcPtr *processor = display_from_scene_linear_processor(display);
diff --git a/source/blender/imbuf/intern/colormanagement_inline.c b/source/blender/imbuf/intern/colormanagement_inline.c
index 411cf9af802..668307ec802 100644
--- a/source/blender/imbuf/intern/colormanagement_inline.c
+++ b/source/blender/imbuf/intern/colormanagement_inline.c
@@ -27,14 +27,46 @@ unsigned char IMB_colormanagement_get_luminance_byte(const unsigned char rgb[3])
return unit_float_to_uchar_clamp(val);
}
-void IMB_colormanagement_xyz_to_rgb(float rgb[3], const float xyz[3])
+void IMB_colormanagement_xyz_to_scene_linear(float scene_linear[3], const float xyz[3])
{
- mul_v3_m3v3(rgb, imbuf_xyz_to_rgb, xyz);
+ mul_v3_m3v3(scene_linear, imbuf_xyz_to_scene_linear, xyz);
}
-void IMB_colormanagement_rgb_to_xyz(float xyz[3], const float rgb[3])
+void IMB_colormanagement_scene_linear_to_xyz(float xyz[3], const float scene_linear[3])
{
- mul_v3_m3v3(xyz, imbuf_rgb_to_xyz, rgb);
+ mul_v3_m3v3(xyz, imbuf_scene_linear_to_xyz, scene_linear);
+}
+
+void IMB_colormanagement_rec709_to_scene_linear(float scene_linear[3], const float rec709[3])
+{
+ mul_v3_m3v3(scene_linear, imbuf_rec709_to_scene_linear, rec709);
+}
+
+void IMB_colormanagement_scene_linear_to_rec709(float rec709[3], const float scene_linear[3])
+{
+ mul_v3_m3v3(rec709, imbuf_scene_linear_to_rec709, scene_linear);
+}
+
+void IMB_colormanagement_scene_linear_to_srgb_v3(float srgb[3], const float scene_linear[3])
+{
+ mul_v3_m3v3(srgb, imbuf_scene_linear_to_rec709, scene_linear);
+ linearrgb_to_srgb_v3_v3(srgb, srgb);
+}
+
+void IMB_colormanagement_srgb_to_scene_linear_v3(float scene_linear[3], const float srgb[3])
+{
+ srgb_to_linearrgb_v3_v3(scene_linear, srgb);
+ mul_m3_v3(imbuf_rec709_to_scene_linear, scene_linear);
+}
+
+void IMB_colormanagement_aces_to_scene_linear(float scene_linear[3], const float aces[3])
+{
+ mul_v3_m3v3(scene_linear, imbuf_aces_to_scene_linear, aces);
+}
+
+void IMB_colormanagement_scene_linear_to_aces(float aces[3], const float scene_linear[3])
+{
+ mul_v3_m3v3(aces, imbuf_scene_linear_to_aces, scene_linear);
}
#endif /* __IMB_COLORMANAGEMENT_INLINE_H__ */