From b81f1b8cf17196122a7203dc79f4c20c1cd9d5bf Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Mon, 23 May 2022 09:03:33 +0200 Subject: Fix T98231: missing update when material output is in group Differential Revision: https://developer.blender.org/D14998 --- .../blender/blenkernel/intern/node_tree_update.cc | 37 ++++++++++++++-------- source/blender/makesdna/DNA_node_types.h | 2 ++ 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/source/blender/blenkernel/intern/node_tree_update.cc b/source/blender/blenkernel/intern/node_tree_update.cc index 8afe7ce7520..68e4cccba00 100644 --- a/source/blender/blenkernel/intern/node_tree_update.cc +++ b/source/blender/blenkernel/intern/node_tree_update.cc @@ -985,7 +985,7 @@ class NodeTreeMainUpdater { this->remove_unused_previews_when_necessary(ntree); this->ensure_tree_ref(ntree, tree_ref); - this->update_has_image_animation(*tree_ref); + this->propagate_runtime_flags(*tree_ref); if (ntree.type == NTREE_GEOMETRY) { if (node_field_inferencing::update_field_inferencing(*tree_ref)) { result.interface_changed = true; @@ -1256,10 +1256,10 @@ class NodeTreeMainUpdater { BKE_node_preview_remove_unused(&ntree); } - void update_has_image_animation(const NodeTreeRef &tree_ref) + void propagate_runtime_flags(const NodeTreeRef &tree_ref) { bNodeTree &ntree = *tree_ref.btree(); - ntree.runtime_flag &= ~NTREE_RUNTIME_FLAG_HAS_IMAGE_ANIMATION; + ntree.runtime_flag = 0; if (ntree.type != NTREE_SHADER) { return; } @@ -1268,21 +1268,30 @@ class NodeTreeMainUpdater { for (const NodeRef *group_node : tree_ref.nodes_by_type("NodeGroup")) { const bNodeTree *group = reinterpret_cast(group_node->bnode()->id); if (group != nullptr) { - if (group->runtime_flag & NTREE_RUNTIME_FLAG_HAS_IMAGE_ANIMATION) { - ntree.runtime_flag |= NTREE_RUNTIME_FLAG_HAS_IMAGE_ANIMATION; - return; - } + ntree.runtime_flag |= group->runtime_flag; } } /* Check if the tree itself has an animated image. */ - for (const StringRefNull idname : {"ShaderNodeTexImage", "ShaderNodeTexEnvironment"}) + for (const StringRefNull idname : {"ShaderNodeTexImage", "ShaderNodeTexEnvironment"}) { for (const NodeRef *node : tree_ref.nodes_by_type(idname)) { Image *image = reinterpret_cast(node->bnode()->id); if (image != nullptr && BKE_image_is_animated(image)) { ntree.runtime_flag |= NTREE_RUNTIME_FLAG_HAS_IMAGE_ANIMATION; - return; + break; } } + } + /* Check if the tree has a material output. */ + for (const StringRefNull idname : {"ShaderNodeOutputMaterial", + "ShaderNodeOutputLight", + "ShaderNodeOutputWorld", + "ShaderNodeOutputAOV"}) { + const Span nodes = tree_ref.nodes_by_type(idname); + if (!nodes.is_empty()) { + ntree.runtime_flag |= NTREE_RUNTIME_FLAG_HAS_MATERIAL_OUTPUT; + break; + } + } } void update_node_levels(bNodeTree &ntree) @@ -1392,10 +1401,12 @@ class NodeTreeMainUpdater { return true; } /* Assume node groups without output sockets are outputs. */ - /* TODO: Store whether a node group contains a top-level output node (e.g. Material Output) in - * run-time information on the node group itself. */ - if (bnode.type == NODE_GROUP && node.outputs().is_empty()) { - return true; + if (bnode.type == NODE_GROUP) { + const bNodeTree *node_group = reinterpret_cast(bnode.id); + if (node_group != nullptr && + node_group->runtime_flag & NTREE_RUNTIME_FLAG_HAS_MATERIAL_OUTPUT) { + return true; + } } return false; } diff --git a/source/blender/makesdna/DNA_node_types.h b/source/blender/makesdna/DNA_node_types.h index b66fe31c00e..e7e8ab3dd61 100644 --- a/source/blender/makesdna/DNA_node_types.h +++ b/source/blender/makesdna/DNA_node_types.h @@ -610,6 +610,8 @@ typedef enum eNodeTreeExecutionMode { typedef enum eNodeTreeRuntimeFlag { /** There is a node that references an image with animation. */ NTREE_RUNTIME_FLAG_HAS_IMAGE_ANIMATION = 1 << 0, + /** There is a material output node in the group. */ + NTREE_RUNTIME_FLAG_HAS_MATERIAL_OUTPUT = 1 << 1, } eNodeTreeRuntimeFlag; /* socket value structs for input buttons -- cgit v1.2.3 From c4e5a7d59a06e833d9e4de45d4eb3cf632a1e9e4 Mon Sep 17 00:00:00 2001 From: YimingWu Date: Mon, 23 May 2022 16:15:15 +0800 Subject: Fix T98258: Duplicated last vertex after GPencil sample. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also fixed an unreported issue of incorrect interpolation of thickness. Reviewed By: Aleš Jelovčan (frogstomp), Antonio Vazquez (antoniov) Differential Revision: https://developer.blender.org/D15005 --- release/datafiles/locale | 2 +- release/scripts/addons | 2 +- source/blender/blenkernel/intern/gpencil_geom.cc | 11 ++++++++--- source/tools | 2 +- 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/release/datafiles/locale b/release/datafiles/locale index fb1eac2ec80..647c85462d8 160000 --- a/release/datafiles/locale +++ b/release/datafiles/locale @@ -1 +1 @@ -Subproject commit fb1eac2ec80c0adee69990a5386b74a5bd4ca00c +Subproject commit 647c85462d87c3a9d3a189d28d72d1bd93f4d4a8 diff --git a/release/scripts/addons b/release/scripts/addons index 7025cd28ede..d936e4c01fa 160000 --- a/release/scripts/addons +++ b/release/scripts/addons @@ -1 +1 @@ -Subproject commit 7025cd28ede25eb44208722f842e35b10325c6cc +Subproject commit d936e4c01fa263a71a7d0665628ae621283b15ee diff --git a/source/blender/blenkernel/intern/gpencil_geom.cc b/source/blender/blenkernel/intern/gpencil_geom.cc index 041696fa8d3..dd22d64aee1 100644 --- a/source/blender/blenkernel/intern/gpencil_geom.cc +++ b/source/blender/blenkernel/intern/gpencil_geom.cc @@ -236,6 +236,7 @@ static int stroke_march_next_point(const bGPDstroke *gps, } else { next_point_index = gps->totpoints - 1; + remaining_till_next = 0; break; } } @@ -263,15 +264,18 @@ static int stroke_march_next_point(const bGPDstroke *gps, float ratio = remaining_march / remaining_till_next; interp_v3_v3v3(result, step_start, point, ratio); *ratio_result = ratio; + float d1 = len_v3v3(result, &gps->points[*index_from].x); + float d2 = len_v3v3(result, &gps->points[next_point_index].x); + float vratio = d1 / (d1 + d2); *pressure = interpf( - gps->points[next_point_index].pressure, gps->points[*index_from].pressure, ratio); + gps->points[next_point_index].pressure, gps->points[*index_from].pressure, vratio); *strength = interpf( - gps->points[next_point_index].strength, gps->points[*index_from].strength, ratio); + gps->points[next_point_index].strength, gps->points[*index_from].strength, vratio); interp_v4_v4v4(vert_color, gps->points[*index_from].vert_color, gps->points[next_point_index].vert_color, - ratio); + vratio); return next_point_index == 0 ? gps->totpoints : next_point_index; } @@ -320,6 +324,7 @@ static int stroke_march_next_point_no_interp(const bGPDstroke *gps, } else { next_point_index = gps->totpoints - 1; + remaining_till_next = 0; break; } } diff --git a/source/tools b/source/tools index 53b7c02a062..ccc8fceb6bd 160000 --- a/source/tools +++ b/source/tools @@ -1 +1 @@ -Subproject commit 53b7c02a062c3d6ec6b38ce670836321b4e78fab +Subproject commit ccc8fceb6bd83ffbf6e5207247fb8f76fc47a5b6 -- cgit v1.2.3 From a5409d2b5941a4292cc19f48cb8546e3ab91296f Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Mon, 23 May 2022 11:29:55 +0200 Subject: Fix T98316: geometry nodes stop updating after duplication This was a missing depsgraph update. --- source/blender/editors/object/object_modifier.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/source/blender/editors/object/object_modifier.cc b/source/blender/editors/object/object_modifier.cc index eed0a63565e..963e92942bb 100644 --- a/source/blender/editors/object/object_modifier.cc +++ b/source/blender/editors/object/object_modifier.cc @@ -3399,6 +3399,7 @@ static int geometry_node_tree_copy_assign_exec(bContext *C, wmOperator *UNUSED(o nmd->node_group = new_tree; id_us_min(&tree->id); + DEG_relations_tag_update(bmain); WM_event_add_notifier(C, NC_OBJECT | ND_MODIFIER, ob); return OPERATOR_FINISHED; } -- cgit v1.2.3 From 62a2b92b6bef8b01bd4b34f02b188297e1f62c71 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Mon, 23 May 2022 12:11:09 +0200 Subject: Fix T98283: Regression: crash when opening file that has Collision modifier on liboverride object Some RNA property update callbacks can already generate such modifier, and only one is allowed per object, so had to adapt code actually adding new modifiers in liboverride apply codebase. --- source/blender/makesrna/intern/rna_object.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 1fb41bf792f..98fc6633f78 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -1829,6 +1829,24 @@ bool rna_Object_modifiers_override_apply(Main *bmain, ModifierData *mod_dst = ED_object_modifier_add( NULL, bmain, NULL, ob_dst, mod_src->name, mod_src->type); + if (mod_dst == NULL) { + /* This can happen e.g. when a modifier type is tagged as `eModifierTypeFlag_Single`, and that + * modifier has somehow been added already by another code path (e.g. + * `rna_CollisionSettings_dependency_update` does add the `eModifierType_Collision` singleton + * modifier). + * + * Try to handle this by finding already existing one here. */ + const ModifierTypeInfo *mti = BKE_modifier_get_info((ModifierType)mod_src->type); + if (mti->flags & eModifierTypeFlag_Single) { + mod_dst = BKE_modifiers_findby_type(ob_dst, (ModifierType)mod_src->type); + } + + if (mod_dst == NULL) { + BLI_assert(mod_src != NULL); + return false; + } + } + /* XXX Current handling of 'copy' from particle-system modifier is *very* bad (it keeps same psys * pointer as source, then calling code copies psys of object separately and do some magic * remapping of pointers...), unfortunately several pieces of code in Object editing area rely on -- cgit v1.2.3 From 2f2d13b8c664b90a7d3249d6ad71bac3d519026d Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Mon, 23 May 2022 14:43:12 +0200 Subject: Fix T97237: dragging custom node group asset adds broken node Differential Revision: https://developer.blender.org/D15013 --- source/blender/editors/space_node/node_add.cc | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/source/blender/editors/space_node/node_add.cc b/source/blender/editors/space_node/node_add.cc index 7fb15d69ab5..e753ed6eb03 100644 --- a/source/blender/editors/space_node/node_add.cc +++ b/source/blender/editors/space_node/node_add.cc @@ -348,8 +348,14 @@ static int node_add_group_exec(bContext *C, wmOperator *op) ED_preview_kill_jobs(CTX_wm_manager(C), CTX_data_main(C)); + const char *node_idname = node_group_idname(C); + if (node_idname[0] == '\0') { + BKE_report(op->reports, RPT_WARNING, "Could not determine type of group node"); + return OPERATOR_CANCELLED; + } + bNode *group_node = node_add_node(*C, - node_group_idname(C), + node_idname, (node_group->type == NTREE_CUSTOM) ? NODE_CUSTOM_GROUP : NODE_GROUP, snode->runtime->cursor[0], @@ -368,6 +374,21 @@ static int node_add_group_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } +static bool node_add_group_poll(bContext *C) +{ + if (!ED_operator_node_editable(C)) { + return false; + } + const SpaceNode *snode = CTX_wm_space_node(C); + if (snode->edittree->type == NTREE_CUSTOM) { + CTX_wm_operator_poll_msg_set(C, + "This node editor displays a custom (Python defined) node tree. " + "Dropping node groups isn't supported for this."); + return false; + } + return true; +} + static int node_add_group_invoke(bContext *C, wmOperator *op, const wmEvent *event) { ARegion *region = CTX_wm_region(C); @@ -396,7 +417,7 @@ void NODE_OT_add_group(wmOperatorType *ot) /* callbacks */ ot->exec = node_add_group_exec; ot->invoke = node_add_group_invoke; - ot->poll = ED_operator_node_editable; + ot->poll = node_add_group_poll; /* flags */ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO | OPTYPE_INTERNAL; -- cgit v1.2.3 From 469ee7ff1529a1b28ce0b300835ebc42d5c5362f Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Thu, 19 May 2022 20:31:58 +0200 Subject: Python API: add mathutils.Color functions to convert color spaces Between scene linear and sRGB, XYZ, linear Rec.709 and ACES2065-1. And add some clarifications about color spaces in the docs. Fixes T98267 Ref T68926 Differential Revision: https://developer.blender.org/D14989 --- intern/opencolorio/fallback_impl.cc | 2 +- intern/opencolorio/ocio_capi.h | 13 +- intern/opencolorio/ocio_impl.cc | 9 +- source/blender/imbuf/IMB_colormanagement.h | 8 + .../imbuf/intern/IMB_colormanagement_intern.h | 4 + source/blender/imbuf/intern/colormanagement.c | 18 ++- .../blender/imbuf/intern/colormanagement_inline.c | 24 +++ source/blender/makesrna/intern/rna_mesh.c | 10 +- source/blender/python/mathutils/CMakeLists.txt | 2 + source/blender/python/mathutils/mathutils_Color.c | 169 ++++++++++++++++++++- 10 files changed, 231 insertions(+), 28 deletions(-) diff --git a/intern/opencolorio/fallback_impl.cc b/intern/opencolorio/fallback_impl.cc index d78b34d3c92..71b5ab9def2 100644 --- a/intern/opencolorio/fallback_impl.cc +++ b/intern/opencolorio/fallback_impl.cc @@ -244,7 +244,7 @@ void FallbackImpl::configGetDefaultLumaCoefs(OCIO_ConstConfigRcPtr * /*config*/, void FallbackImpl::configGetXYZtoRGB(OCIO_ConstConfigRcPtr * /*config*/, float xyz_to_rgb[3][3]) { /* Default to ITU-BT.709. */ - memcpy(xyz_to_rgb, OCIO_XYZ_TO_LINEAR_SRGB, sizeof(OCIO_XYZ_TO_LINEAR_SRGB)); + memcpy(xyz_to_rgb, OCIO_XYZ_TO_REC709, sizeof(OCIO_XYZ_TO_REC709)); } int FallbackImpl::configGetNumLooks(OCIO_ConstConfigRcPtr * /*config*/) diff --git a/intern/opencolorio/ocio_capi.h b/intern/opencolorio/ocio_capi.h index 9bd4ec374e2..4be838a218d 100644 --- a/intern/opencolorio/ocio_capi.h +++ b/intern/opencolorio/ocio_capi.h @@ -31,10 +31,15 @@ OCIO_DECLARE_HANDLE(OCIO_ConstContextRcPtr); OCIO_DECLARE_HANDLE(OCIO_PackedImageDesc); OCIO_DECLARE_HANDLE(OCIO_ConstLookRcPtr); -/* Standard XYZ to linear sRGB transform, for fallback. */ -static const float OCIO_XYZ_TO_LINEAR_SRGB[3][3] = {{3.2404542f, -0.9692660f, 0.0556434f}, - {-1.5371385f, 1.8760108f, -0.2040259f}, - {-0.4985314f, 0.0415560f, 1.0572252f}}; +/* Standard XYZ (D65) to linear Rec.709 transform. */ +static const float OCIO_XYZ_TO_REC709[3][3] = {{3.2404542f, -0.9692660f, 0.0556434f}, + {-1.5371385f, 1.8760108f, -0.2040259f}, + {-0.4985314f, 0.0415560f, 1.0572252f}}; +/* Standard ACES to XYZ (D65) transform. + * Matches OpenColorIO builtin transform: UTILITY - ACES-AP0_to_CIE-XYZ-D65_BFD. */ +static const float OCIO_ACES_TO_XYZ[3][3] = {{0.938280f, 0.337369f, 0.001174f}, + {-0.004451f, 0.729522f, -0.003711f}, + {0.016628f, -0.066890f, 1.091595f}}; /* This structure is used to pass curve mapping settings from * blender's DNA structure stored in view transform settings diff --git a/intern/opencolorio/ocio_impl.cc b/intern/opencolorio/ocio_impl.cc index 8d9c5dd2d49..a352c54da86 100644 --- a/intern/opencolorio/ocio_impl.cc +++ b/intern/opencolorio/ocio_impl.cc @@ -317,7 +317,7 @@ void OCIOImpl::configGetXYZtoRGB(OCIO_ConstConfigRcPtr *config_, float xyz_to_rg /* Default to ITU-BT.709 in case no appropriate transform found. * Note XYZ is defined here as having a D65 white point. */ - memcpy(xyz_to_rgb, OCIO_XYZ_TO_LINEAR_SRGB, sizeof(OCIO_XYZ_TO_LINEAR_SRGB)); + memcpy(xyz_to_rgb, OCIO_XYZ_TO_REC709, sizeof(OCIO_XYZ_TO_REC709)); /* Get from OpenColorO config if it has the required roles. */ if (!config->hasRole(ROLE_SCENE_LINEAR)) { @@ -328,13 +328,8 @@ void OCIOImpl::configGetXYZtoRGB(OCIO_ConstConfigRcPtr *config_, float xyz_to_rg /* Standard OpenColorIO role, defined as ACES AP0 (ACES2065-1). */ float aces_to_rgb[3][3]; if (to_scene_linear_matrix(config, "aces_interchange", aces_to_rgb)) { - /* This is the OpenColorIO builtin transform: - * UTILITY - ACES-AP0_to_CIE-XYZ-D65_BFD. */ - const float ACES_AP0_to_xyz_D65[3][3] = {{0.938280f, 0.337369f, 0.001174f}, - {-0.004451f, 0.729522f, -0.003711f}, - {0.016628f, -0.066890f, 1.091595f}}; float xyz_to_aces[3][3]; - invert_m3_m3(xyz_to_aces, ACES_AP0_to_xyz_D65); + invert_m3_m3(xyz_to_aces, OCIO_ACES_TO_XYZ); mul_m3_m3m3(xyz_to_rgb, aces_to_rgb, xyz_to_aces); } diff --git a/source/blender/imbuf/IMB_colormanagement.h b/source/blender/imbuf/IMB_colormanagement.h index 1f0ed4cafbe..94036da9d22 100644 --- a/source/blender/imbuf/IMB_colormanagement.h +++ b/source/blender/imbuf/IMB_colormanagement.h @@ -72,8 +72,16 @@ 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]); + +/** + * Conversion between scene linear and other color spaces. + */ 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]); +BLI_INLINE void IMB_colormanagement_rec709_to_rgb(float rgb[3], const float rec709[3]); +BLI_INLINE void IMB_colormanagement_rgb_to_rec709(float rec709[3], const float rgb[3]); +BLI_INLINE void IMB_colormanagement_aces_to_rgb(float rgb[3], const float aces[3]); +BLI_INLINE void IMB_colormanagement_rgb_to_aces(float aces[3], const float rgb[3]); const float *IMB_colormanagement_get_xyz_to_rgb(void); /** \} */ diff --git a/source/blender/imbuf/intern/IMB_colormanagement_intern.h b/source/blender/imbuf/intern/IMB_colormanagement_intern.h index c89b15480a2..fd70c633f83 100644 --- a/source/blender/imbuf/intern/IMB_colormanagement_intern.h +++ b/source/blender/imbuf/intern/IMB_colormanagement_intern.h @@ -20,6 +20,10 @@ 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_xyz_to_aces[3][3]; +extern float imbuf_aces_to_xyz[3][3]; +extern float imbuf_xyz_to_rec709[3][3]; +extern float imbuf_rec709_to_xyz[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 95e2d36891a..f189614e61c 100644 --- a/source/blender/imbuf/intern/colormanagement.c +++ b/source/blender/imbuf/intern/colormanagement.c @@ -75,8 +75,10 @@ static int global_tot_looks = 0; 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_xyz_to_rec709[3][3] = {{0.0f}}; +float imbuf_rec709_to_xyz[3][3] = {{0.0f}}; +float imbuf_xyz_to_aces[3][3] = {{0.0f}}; +float imbuf_aces_to_xyz[3][3] = {{0.0f}}; /* lock used by pre-cached processors getters, so processor wouldn't * be created several times @@ -573,10 +575,14 @@ static void colormanage_load_config(OCIO_ConstConfigRcPtr *config) /* Load luminance coefficients. */ OCIO_configGetDefaultLumaCoefs(config, imbuf_luma_coefficients); + + /* Load standard color spaces. */ 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); + copy_m3_m3(imbuf_xyz_to_rec709, OCIO_XYZ_TO_REC709); + invert_m3_m3(imbuf_rec709_to_xyz, imbuf_xyz_to_rec709); + copy_m3_m3(imbuf_aces_to_xyz, OCIO_ACES_TO_XYZ); + invert_m3_m3(imbuf_xyz_to_aces, imbuf_aces_to_xyz); } static void colormanage_free_config(void) @@ -2370,14 +2376,14 @@ void IMB_colormanagement_color_picking_to_scene_linear_v3(float pixel[3]) 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); + mul_m3_v3(imbuf_xyz_to_rec709, 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_rec709_to_xyz, pixel); mul_m3_v3(imbuf_xyz_to_rgb, pixel); } diff --git a/source/blender/imbuf/intern/colormanagement_inline.c b/source/blender/imbuf/intern/colormanagement_inline.c index 411cf9af802..4c632da1520 100644 --- a/source/blender/imbuf/intern/colormanagement_inline.c +++ b/source/blender/imbuf/intern/colormanagement_inline.c @@ -37,4 +37,28 @@ void IMB_colormanagement_rgb_to_xyz(float xyz[3], const float rgb[3]) mul_v3_m3v3(xyz, imbuf_rgb_to_xyz, rgb); } +void IMB_colormanagement_rec709_to_rgb(float rgb[3], const float rec709[3]) +{ + mul_v3_m3v3(rgb, imbuf_rec709_to_xyz, rec709); + mul_v3_m3v3(rgb, imbuf_xyz_to_rgb, rgb); +} + +void IMB_colormanagement_rgb_to_rec709(float rec709[3], const float rgb[3]) +{ + mul_v3_m3v3(rec709, imbuf_rgb_to_xyz, rgb); + mul_v3_m3v3(rec709, imbuf_xyz_to_rec709, rec709); +} + +void IMB_colormanagement_aces_to_rgb(float rgb[3], const float aces[3]) +{ + mul_v3_m3v3(rgb, imbuf_aces_to_xyz, aces); + mul_v3_m3v3(rgb, imbuf_xyz_to_rgb, rgb); +} + +void IMB_colormanagement_rgb_to_aces(float aces[3], const float rgb[3]) +{ + mul_v3_m3v3(aces, imbuf_rgb_to_xyz, rgb); + mul_v3_m3v3(aces, imbuf_xyz_to_aces, aces); +} + #endif /* __IMB_COLORMANAGEMENT_INLINE_H__ */ diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index 38d473f04dd..ec0a182e338 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -2195,7 +2195,7 @@ static void rna_def_mloopcol(BlenderRNA *brna) RNA_def_property_range(prop, 0.0f, 1.0f); RNA_def_property_float_funcs( prop, "rna_MeshLoopColor_color_get", "rna_MeshLoopColor_color_set", NULL); - RNA_def_property_ui_text(prop, "Color", ""); + RNA_def_property_ui_text(prop, "Color", "Color in sRGB color space"); RNA_def_property_update(prop, 0, "rna_Mesh_update_data_legacy_deg_tag_all"); } @@ -3210,7 +3210,9 @@ static void rna_def_mesh(BlenderRNA *brna) NULL); RNA_def_property_struct_type(prop, "MeshLoopColorLayer"); RNA_def_property_override_flag(prop, PROPOVERRIDE_IGNORE); - RNA_def_property_ui_text(prop, "Vertex Colors", "All vertex colors"); + RNA_def_property_ui_text(prop, + "Vertex Colors", + "Legacy vertex color layers. Deprecated, use color attributes instead"); rna_def_loop_colors(brna, prop); /* Sculpt Vertex colors */ @@ -3228,7 +3230,9 @@ static void rna_def_mesh(BlenderRNA *brna) NULL); RNA_def_property_struct_type(prop, "MeshVertColorLayer"); RNA_def_property_override_flag(prop, PROPOVERRIDE_IGNORE); - RNA_def_property_ui_text(prop, "Sculpt Vertex Colors", "All vertex colors"); + RNA_def_property_ui_text(prop, + "Sculpt Vertex Colors", + "Sculpt vertex color layers. Deprecated, use color attributes instead"); rna_def_vert_colors(brna, prop); /* TODO: edge customdata layers (bmesh py api can access already). */ diff --git a/source/blender/python/mathutils/CMakeLists.txt b/source/blender/python/mathutils/CMakeLists.txt index 1be9b568626..747d6c0e8f8 100644 --- a/source/blender/python/mathutils/CMakeLists.txt +++ b/source/blender/python/mathutils/CMakeLists.txt @@ -4,6 +4,7 @@ set(INC . ../../blenkernel ../../blenlib + ../../imbuf ../../bmesh ../../depsgraph ../../makesdna @@ -42,6 +43,7 @@ set(SRC set(LIB bf_blenlib + bf_imbuf bf_python_ext ${PYTHON_LINKFLAGS} diff --git a/source/blender/python/mathutils/mathutils_Color.c b/source/blender/python/mathutils/mathutils_Color.c index 8b126639f10..1495a465432 100644 --- a/source/blender/python/mathutils/mathutils_Color.c +++ b/source/blender/python/mathutils/mathutils_Color.c @@ -14,6 +14,8 @@ #include "../generic/py_capi_utils.h" #include "../generic/python_utildefines.h" +#include "IMB_colormanagement.h" + #ifndef MATH_STANDALONE # include "BLI_dynstr.h" #endif @@ -76,6 +78,120 @@ static PyObject *Color_ToTupleExt(ColorObject *self, int ndigits) return ret; } +PyDoc_STRVAR(Color_from_scene_linear_to_srgb_doc, + ".. function:: from_scene_linear_to_srgb()\n" + "\n" + " Convert from scene linear to sRGB color space.\n" + "\n" + " :return: A color in sRGB color space.\n" + " :rtype: :class:`Color`\n"); +static PyObject *Color_from_scene_linear_to_srgb(ColorObject *self) +{ + float col[3] = {self->col[0], self->col[1], self->col[2]}; + IMB_colormanagement_scene_linear_to_srgb_v3(col); + return Color_CreatePyObject(col, Py_TYPE(self)); +} + +PyDoc_STRVAR(Color_from_srgb_to_scene_linear_doc, + ".. function:: from_srgb_to_scene_linear()\n" + "\n" + " Convert from sRGB to scene linear color space.\n" + "\n" + " :return: A color in scene linear color space.\n" + " :rtype: :class:`Color`\n"); +static PyObject *Color_from_srgb_to_scene_linear(ColorObject *self) +{ + float col[3] = {self->col[0], self->col[1], self->col[2]}; + IMB_colormanagement_srgb_to_scene_linear_v3(col); + return Color_CreatePyObject(col, Py_TYPE(self)); +} + +PyDoc_STRVAR(Color_from_scene_linear_to_xyz_d65_doc, + ".. function:: from_scene_linear_to_xyz_d65()\n" + "\n" + " Convert from scene linear to CIE XYZ (Illuminant D65) color space.\n" + "\n" + " :return: A color in XYZ color space.\n" + " :rtype: :class:`Color`\n"); +static PyObject *Color_from_scene_linear_to_xyz_d65(ColorObject *self) +{ + float col[3]; + IMB_colormanagement_rgb_to_xyz(col, self->col); + return Color_CreatePyObject(col, Py_TYPE(self)); +} + +PyDoc_STRVAR(Color_from_xyz_d65_to_scene_linear_doc, + ".. function:: from_xyz_d65_to_scene_linear()\n" + "\n" + " Convert from CIE XYZ (Illuminant D65) to scene linear color space.\n" + "\n" + " :return: A color in scene linear color space.\n" + " :rtype: :class:`Color`\n"); +static PyObject *Color_from_xyz_d65_to_scene_linear(ColorObject *self) +{ + float col[3]; + IMB_colormanagement_xyz_to_rgb(col, self->col); + return Color_CreatePyObject(col, Py_TYPE(self)); +} + +PyDoc_STRVAR(Color_from_scene_linear_to_aces_doc, + ".. function:: from_scene_linear_to_aces()\n" + "\n" + " Convert from scene linear to ACES2065-1 linear color space.\n" + "\n" + " :return: A color in ACES2065-1 linear color space.\n" + " :rtype: :class:`Color`\n"); +static PyObject *Color_from_scene_linear_to_aces(ColorObject *self) +{ + float col[3]; + IMB_colormanagement_rgb_to_aces(col, self->col); + return Color_CreatePyObject(col, Py_TYPE(self)); +} + +PyDoc_STRVAR(Color_from_aces_to_scene_linear_doc, + ".. function:: from_aces_to_scene_linear()\n" + "\n" + " Convert from ACES2065-1 linear to scene linear color space.\n" + "\n" + " :return: A color in scene linear color space.\n" + " :rtype: :class:`Color`\n"); +static PyObject *Color_from_aces_to_scene_linear(ColorObject *self) +{ + float col[3]; + IMB_colormanagement_aces_to_rgb(col, self->col); + return Color_CreatePyObject(col, Py_TYPE(self)); +} + +PyDoc_STRVAR(Color_from_scene_linear_to_rec709_linear_doc, + ".. function:: from_scene_linear_to_rec709_linear()\n" + "\n" + " Convert from scene linear to Rec.709 linear color space.\n" + "\n" + " :return: A color in Rec.709 linear color space.\n" + " :rtype: :class:`Color`\n"); +static PyObject *Color_from_scene_linear_to_rec709_linear(ColorObject *self) +{ + float col[3]; + IMB_colormanagement_rgb_to_rec709(col, self->col); + return Color_CreatePyObject(col, Py_TYPE(self)); +} + +PyDoc_STRVAR(Color_from_rec709_linear_to_scene_linear_doc, + ".. function:: from_rec709_linear_to_scene_linear()\n" + "\n" + " Convert from Rec.709 linear color space to scene linear color space.\n" + "\n" + " :return: A color in scene linear color space.\n" + " :rtype: :class:`Color`\n"); +static PyObject *Color_from_rec709_linear_to_scene_linear(ColorObject *self) +{ + float col[3]; + IMB_colormanagement_rec709_to_rgb(col, self->col); + return Color_CreatePyObject(col, Py_TYPE(self)); +} + +/* ---------------------------- Colorspace conversion -------------- */ + PyDoc_STRVAR(Color_copy_doc, ".. function:: copy()\n" "\n" @@ -869,17 +985,56 @@ static struct PyMethodDef Color_methods[] = { /* base-math methods */ {"freeze", (PyCFunction)BaseMathObject_freeze, METH_NOARGS, BaseMathObject_freeze_doc}, + + /* Colorspace methods. */ + {"from_scene_linear_to_srgb", + (PyCFunction)Color_from_scene_linear_to_srgb, + METH_NOARGS, + Color_from_scene_linear_to_srgb_doc}, + {"from_srgb_to_scene_linear", + (PyCFunction)Color_from_srgb_to_scene_linear, + METH_NOARGS, + Color_from_srgb_to_scene_linear_doc}, + {"from_scene_linear_to_xyz_d65", + (PyCFunction)Color_from_scene_linear_to_xyz_d65, + METH_NOARGS, + Color_from_scene_linear_to_xyz_d65_doc}, + {"from_xyz_d65_to_scene_linear", + (PyCFunction)Color_from_xyz_d65_to_scene_linear, + METH_NOARGS, + Color_from_xyz_d65_to_scene_linear_doc}, + {"from_scene_linear_to_aces", + (PyCFunction)Color_from_scene_linear_to_aces, + METH_NOARGS, + Color_from_scene_linear_to_aces_doc}, + {"from_aces_to_scene_linear", + (PyCFunction)Color_from_aces_to_scene_linear, + METH_NOARGS, + Color_from_aces_to_scene_linear_doc}, + {"from_scene_linear_to_rec709_linear", + (PyCFunction)Color_from_scene_linear_to_rec709_linear, + METH_NOARGS, + Color_from_scene_linear_to_rec709_linear_doc}, + {"from_rec709_linear_to_scene_linear", + (PyCFunction)Color_from_rec709_linear_to_scene_linear, + METH_NOARGS, + Color_from_rec709_linear_to_scene_linear_doc}, {NULL, NULL, 0, NULL}, }; /* ------------------PY_OBECT DEFINITION-------------------------- */ -PyDoc_STRVAR(color_doc, - ".. class:: Color(rgb)\n" - "\n" - " This object gives access to Colors in Blender.\n" - "\n" - " :param rgb: (r, g, b) color values\n" - " :type rgb: 3d vector\n"); +PyDoc_STRVAR( + color_doc, + ".. class:: Color(rgb)\n" + "\n" + " This object gives access to Colors in Blender.\n" + "\n" + " Most colors returned by Blender APIs are in scene linear color space, as defined by " + " the OpenColorIO configuration. The notable exception is user interface theming colors, " + " which are in sRGB color space.\n" + "\n" + " :param rgb: (r, g, b) color values\n" + " :type rgb: 3d vector\n"); PyTypeObject color_Type = { PyVarObject_HEAD_INIT(NULL, 0) "Color", /* tp_name */ sizeof(ColorObject), /* tp_basicsize */ -- cgit v1.2.3 From eb5e7d0a31eed698909c23ab0ca89c8fd4929365 Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Fri, 20 May 2022 17:54:43 +0200 Subject: Cleanup: clarify what is scene linear color space in conversion conversion * Rename ambiguous rgb to scene_linear in some places * Precompute matrices to directly go to scene instead of through XYZ * Make function signatures more consistent --- intern/opencolorio/fallback_impl.cc | 5 +- intern/opencolorio/ocio_capi.cc | 4 +- intern/opencolorio/ocio_capi.h | 3 +- intern/opencolorio/ocio_impl.cc | 13 ++--- intern/opencolorio/ocio_impl.h | 7 +-- .../blender/editors/interface/interface_handlers.c | 4 +- source/blender/editors/interface/interface_ops.c | 4 +- .../interface/interface_region_color_picker.cc | 10 ++-- source/blender/editors/sculpt_paint/paint_image.cc | 4 +- .../blender/editors/sculpt_paint/paint_vertex.cc | 3 +- .../blender/editors/sculpt_paint/sculpt_expand.c | 2 +- .../editors/sculpt_paint/sculpt_filter_color.c | 2 +- source/blender/editors/sculpt_paint/sculpt_ops.c | 3 +- .../editors/sculpt_paint/sculpt_paint_color.c | 2 +- source/blender/imbuf/IMB_colormanagement.h | 30 +++++++---- .../imbuf/intern/IMB_colormanagement_intern.h | 12 ++--- source/blender/imbuf/intern/colormanagement.c | 58 ++++++++++------------ .../blender/imbuf/intern/colormanagement_inline.c | 40 +++++++++------ source/blender/nodes/shader/node_shader_util.cc | 2 +- source/blender/python/mathutils/mathutils_Color.c | 20 ++++---- 20 files changed, 119 insertions(+), 109 deletions(-) diff --git a/intern/opencolorio/fallback_impl.cc b/intern/opencolorio/fallback_impl.cc index 71b5ab9def2..8fc0ccd7918 100644 --- a/intern/opencolorio/fallback_impl.cc +++ b/intern/opencolorio/fallback_impl.cc @@ -241,10 +241,11 @@ void FallbackImpl::configGetDefaultLumaCoefs(OCIO_ConstConfigRcPtr * /*config*/, rgb[2] = 0.0722f; } -void FallbackImpl::configGetXYZtoRGB(OCIO_ConstConfigRcPtr * /*config*/, float xyz_to_rgb[3][3]) +void FallbackImpl::configGetXYZtoSceneLinear(OCIO_ConstConfigRcPtr * /*config*/, + float xyz_to_scene_linear[3][3]) { /* Default to ITU-BT.709. */ - memcpy(xyz_to_rgb, OCIO_XYZ_TO_REC709, sizeof(OCIO_XYZ_TO_REC709)); + memcpy(xyz_to_scene_linear, OCIO_XYZ_TO_REC709, sizeof(OCIO_XYZ_TO_REC709)); } int FallbackImpl::configGetNumLooks(OCIO_ConstConfigRcPtr * /*config*/) diff --git a/intern/opencolorio/ocio_capi.cc b/intern/opencolorio/ocio_capi.cc index 5e4c2a87a0b..b31f3794361 100644 --- a/intern/opencolorio/ocio_capi.cc +++ b/intern/opencolorio/ocio_capi.cc @@ -118,9 +118,9 @@ void OCIO_configGetDefaultLumaCoefs(OCIO_ConstConfigRcPtr *config, float *rgb) impl->configGetDefaultLumaCoefs(config, rgb); } -void OCIO_configGetXYZtoRGB(OCIO_ConstConfigRcPtr *config, float xyz_to_rgb[3][3]) +void OCIO_configGetXYZtoSceneLinear(OCIO_ConstConfigRcPtr *config, float xyz_to_scene_linear[3][3]) { - impl->configGetXYZtoRGB(config, xyz_to_rgb); + impl->configGetXYZtoSceneLinear(config, xyz_to_scene_linear); } int OCIO_configGetNumLooks(OCIO_ConstConfigRcPtr *config) diff --git a/intern/opencolorio/ocio_capi.h b/intern/opencolorio/ocio_capi.h index 4be838a218d..97e6ff02779 100644 --- a/intern/opencolorio/ocio_capi.h +++ b/intern/opencolorio/ocio_capi.h @@ -135,7 +135,8 @@ const char *OCIO_configGetDisplayColorSpaceName(OCIO_ConstConfigRcPtr *config, const char *view); void OCIO_configGetDefaultLumaCoefs(OCIO_ConstConfigRcPtr *config, float *rgb); -void OCIO_configGetXYZtoRGB(OCIO_ConstConfigRcPtr *config, float xyz_to_rgb[3][3]); +void OCIO_configGetXYZtoSceneLinear(OCIO_ConstConfigRcPtr *config, + float xyz_to_scene_linear[3][3]); int OCIO_configGetNumLooks(OCIO_ConstConfigRcPtr *config); const char *OCIO_configGetLookNameByIndex(OCIO_ConstConfigRcPtr *config, int index); diff --git a/intern/opencolorio/ocio_impl.cc b/intern/opencolorio/ocio_impl.cc index a352c54da86..7cf7fbefcd6 100644 --- a/intern/opencolorio/ocio_impl.cc +++ b/intern/opencolorio/ocio_impl.cc @@ -311,13 +311,14 @@ static bool to_scene_linear_matrix(ConstConfigRcPtr &config, return true; } -void OCIOImpl::configGetXYZtoRGB(OCIO_ConstConfigRcPtr *config_, float xyz_to_rgb[3][3]) +void OCIOImpl::configGetXYZtoSceneLinear(OCIO_ConstConfigRcPtr *config_, + float xyz_to_scene_linear[3][3]) { ConstConfigRcPtr config = (*(ConstConfigRcPtr *)config_); /* Default to ITU-BT.709 in case no appropriate transform found. * Note XYZ is defined here as having a D65 white point. */ - memcpy(xyz_to_rgb, OCIO_XYZ_TO_REC709, sizeof(OCIO_XYZ_TO_REC709)); + memcpy(xyz_to_scene_linear, OCIO_XYZ_TO_REC709, sizeof(OCIO_XYZ_TO_REC709)); /* Get from OpenColorO config if it has the required roles. */ if (!config->hasRole(ROLE_SCENE_LINEAR)) { @@ -326,17 +327,17 @@ void OCIOImpl::configGetXYZtoRGB(OCIO_ConstConfigRcPtr *config_, float xyz_to_rg if (config->hasRole("aces_interchange")) { /* Standard OpenColorIO role, defined as ACES AP0 (ACES2065-1). */ - float aces_to_rgb[3][3]; - if (to_scene_linear_matrix(config, "aces_interchange", aces_to_rgb)) { + float aces_to_scene_linear[3][3]; + if (to_scene_linear_matrix(config, "aces_interchange", aces_to_scene_linear)) { float xyz_to_aces[3][3]; invert_m3_m3(xyz_to_aces, OCIO_ACES_TO_XYZ); - mul_m3_m3m3(xyz_to_rgb, aces_to_rgb, xyz_to_aces); + mul_m3_m3m3(xyz_to_scene_linear, aces_to_scene_linear, xyz_to_aces); } } else if (config->hasRole("XYZ")) { /* Custom role used before the standard existed. */ - to_scene_linear_matrix(config, "XYZ", xyz_to_rgb); + to_scene_linear_matrix(config, "XYZ", xyz_to_scene_linear); } } diff --git a/intern/opencolorio/ocio_impl.h b/intern/opencolorio/ocio_impl.h index f8397c62e52..2c00eff6d6c 100644 --- a/intern/opencolorio/ocio_impl.h +++ b/intern/opencolorio/ocio_impl.h @@ -48,7 +48,8 @@ class IOCIOImpl { const char *view) = 0; virtual void configGetDefaultLumaCoefs(OCIO_ConstConfigRcPtr *config, float *rgb) = 0; - virtual void configGetXYZtoRGB(OCIO_ConstConfigRcPtr *config, float xyz_to_rgb[3][3]) = 0; + virtual void configGetXYZtoSceneLinear(OCIO_ConstConfigRcPtr *config, + float xyz_to_scene_linear[3][3]) = 0; virtual int configGetNumLooks(OCIO_ConstConfigRcPtr *config) = 0; virtual const char *configGetLookNameByIndex(OCIO_ConstConfigRcPtr *config, int index) = 0; @@ -167,7 +168,7 @@ class FallbackImpl : public IOCIOImpl { const char *view); void configGetDefaultLumaCoefs(OCIO_ConstConfigRcPtr *config, float *rgb); - void configGetXYZtoRGB(OCIO_ConstConfigRcPtr *config, float xyz_to_rgb[3][3]); + void configGetXYZtoSceneLinear(OCIO_ConstConfigRcPtr *config, float xyz_to_scene_linear[3][3]); int configGetNumLooks(OCIO_ConstConfigRcPtr *config); const char *configGetLookNameByIndex(OCIO_ConstConfigRcPtr *config, int index); @@ -257,7 +258,7 @@ class OCIOImpl : public IOCIOImpl { const char *view); void configGetDefaultLumaCoefs(OCIO_ConstConfigRcPtr *config, float *rgb); - void configGetXYZtoRGB(OCIO_ConstConfigRcPtr *config, float xyz_to_rgb[3][3]); + void configGetXYZtoSceneLinear(OCIO_ConstConfigRcPtr *config, float xyz_to_scene_linear[3][3]); int configGetNumLooks(OCIO_ConstConfigRcPtr *config); const char *configGetLookNameByIndex(OCIO_ConstConfigRcPtr *config, int index); diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 9d7d76f0bdb..3e3b30a2c1e 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -6277,7 +6277,7 @@ static int ui_do_but_COLOR(bContext *C, uiBut *but, uiHandleButtonData *data, co if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) { RNA_property_float_get_array(&but->rnapoin, but->rnaprop, target); - IMB_colormanagement_srgb_to_scene_linear_v3(target); + IMB_colormanagement_srgb_to_scene_linear_v3(target, target); } else if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR) { RNA_property_float_get_array(&but->rnapoin, but->rnaprop, target); @@ -6294,7 +6294,7 @@ static int ui_do_but_COLOR(bContext *C, uiBut *but, uiHandleButtonData *data, co } else if (but->rnaprop && RNA_property_subtype(but->rnaprop) == PROP_COLOR) { RNA_property_float_get_array(&but->rnapoin, but->rnaprop, color); - IMB_colormanagement_scene_linear_to_srgb_v3(color); + IMB_colormanagement_scene_linear_to_srgb_v3(color, color); BKE_brush_color_set(scene, brush, color); updated = true; } diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index 5b97a80d513..f14c6ad9924 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -1895,14 +1895,14 @@ static int drop_color_invoke(bContext *C, wmOperator *op, const wmEvent *event) if (RNA_property_subtype(but->rnaprop) == PROP_COLOR_GAMMA) { if (!gamma) { - IMB_colormanagement_scene_linear_to_srgb_v3(color); + IMB_colormanagement_scene_linear_to_srgb_v3(color, color); } RNA_property_float_set_array(&but->rnapoin, but->rnaprop, color); RNA_property_update(C, &but->rnapoin, but->rnaprop); } else if (RNA_property_subtype(but->rnaprop) == PROP_COLOR) { if (gamma) { - IMB_colormanagement_srgb_to_scene_linear_v3(color); + IMB_colormanagement_srgb_to_scene_linear_v3(color, color); } RNA_property_float_set_array(&but->rnapoin, but->rnaprop, color); RNA_property_update(C, &but->rnapoin, but->rnaprop); diff --git a/source/blender/editors/interface/interface_region_color_picker.cc b/source/blender/editors/interface/interface_region_color_picker.cc index ab0a6039cdc..db1e5e653de 100644 --- a/source/blender/editors/interface/interface_region_color_picker.cc +++ b/source/blender/editors/interface/interface_region_color_picker.cc @@ -116,7 +116,7 @@ void ui_scene_linear_to_perceptual_space(uiBut *but, float rgb[3]) * assuming it is more perceptually linear than the scene linear * space for intuitive color picking. */ if (!ui_but_is_color_gamma(but)) { - IMB_colormanagement_scene_linear_to_color_picking_v3(rgb); + IMB_colormanagement_scene_linear_to_color_picking_v3(rgb, rgb); ui_color_picker_rgb_round(rgb); } } @@ -124,7 +124,7 @@ void ui_scene_linear_to_perceptual_space(uiBut *but, float rgb[3]) void ui_perceptual_to_scene_linear_space(uiBut *but, float rgb[3]) { if (!ui_but_is_color_gamma(but)) { - IMB_colormanagement_color_picking_to_scene_linear_v3(rgb); + IMB_colormanagement_color_picking_to_scene_linear_v3(rgb, rgb); ui_color_picker_rgb_round(rgb); } } @@ -208,7 +208,7 @@ static void ui_update_color_picker_buts_rgb(uiBut *from_but, * (coming from other applications, web, etc) */ copy_v3_v3(rgb_hex, rgb_scene_linear); if (from_but && !ui_but_is_color_gamma(from_but)) { - IMB_colormanagement_scene_linear_to_srgb_v3(rgb_hex); + IMB_colormanagement_scene_linear_to_srgb_v3(rgb_hex, rgb_hex); ui_color_picker_rgb_round(rgb_hex); } @@ -291,7 +291,7 @@ static void ui_colorpicker_hex_rna_cb(bContext *UNUSED(C), void *bt1, void *hexc /* Hex code is assumed to be in sRGB space (coming from other applications, web, etc) */ if (!ui_but_is_color_gamma(but)) { - IMB_colormanagement_srgb_to_scene_linear_v3(rgb); + IMB_colormanagement_srgb_to_scene_linear_v3(rgb, rgb); ui_color_picker_rgb_round(rgb); } @@ -777,7 +777,7 @@ static void ui_block_colorpicker(uiBlock *block, copy_v3_v3(rgb_hex, rgba_scene_linear); if (!ui_but_is_color_gamma(from_but)) { - IMB_colormanagement_scene_linear_to_srgb_v3(rgb_hex); + IMB_colormanagement_scene_linear_to_srgb_v3(rgb_hex, rgb_hex); ui_color_picker_rgb_round(rgb_hex); } diff --git a/source/blender/editors/sculpt_paint/paint_image.cc b/source/blender/editors/sculpt_paint/paint_image.cc index 572e5b78b74..a313489885d 100644 --- a/source/blender/editors/sculpt_paint/paint_image.cc +++ b/source/blender/editors/sculpt_paint/paint_image.cc @@ -359,9 +359,7 @@ void paint_brush_color_get(struct Scene *scene, } /* Gradient / Color-band colors are not considered #PROP_COLOR_GAMMA. * Brush colors are expected to be in sRGB though. */ - IMB_colormanagement_scene_linear_to_srgb_v3(color_gr); - - copy_v3_v3(color, color_gr); + IMB_colormanagement_scene_linear_to_srgb_v3(color, color_gr); } else { copy_v3_v3(color, BKE_brush_color_get(scene, br)); diff --git a/source/blender/editors/sculpt_paint/paint_vertex.cc b/source/blender/editors/sculpt_paint/paint_vertex.cc index 747295f3de0..f13c34e2030 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.cc +++ b/source/blender/editors/sculpt_paint/paint_vertex.cc @@ -331,8 +331,7 @@ static Color vpaint_get_current_col(Scene *scene, VPaint *vp, bool secondary) float color[4]; const float *brush_color = secondary ? BKE_brush_secondary_color_get(scene, brush) : BKE_brush_color_get(scene, brush); - copy_v3_v3(color, brush_color); - IMB_colormanagement_srgb_to_scene_linear_v3(color); + IMB_colormanagement_srgb_to_scene_linear_v3(color, brush_color); color[3] = 1.0f; /* alpha isn't used, could even be removed to speedup paint a little */ diff --git a/source/blender/editors/sculpt_paint/sculpt_expand.c b/source/blender/editors/sculpt_paint/sculpt_expand.c index 46940b619e6..644f14905ba 100644 --- a/source/blender/editors/sculpt_paint/sculpt_expand.c +++ b/source/blender/editors/sculpt_paint/sculpt_expand.c @@ -2001,7 +2001,7 @@ static void sculpt_expand_cache_initial_config_set(bContext *C, BKE_curvemapping_init(expand_cache->brush->curve); copy_v4_fl(expand_cache->fill_color, 1.0f); copy_v3_v3(expand_cache->fill_color, BKE_brush_color_get(ss->scene, expand_cache->brush)); - IMB_colormanagement_srgb_to_scene_linear_v3(expand_cache->fill_color); + IMB_colormanagement_srgb_to_scene_linear_v3(expand_cache->fill_color, expand_cache->fill_color); expand_cache->scene = CTX_data_scene(C); expand_cache->mtex = &expand_cache->brush->mtex; diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_color.c b/source/blender/editors/sculpt_paint/sculpt_filter_color.c index f71a814aff4..26d18823b37 100644 --- a/source/blender/editors/sculpt_paint/sculpt_filter_color.c +++ b/source/blender/editors/sculpt_paint/sculpt_filter_color.c @@ -298,7 +298,7 @@ static int sculpt_color_filter_modal(bContext *C, wmOperator *op, const wmEvent float fill_color[3]; RNA_float_get_array(op->ptr, "fill_color", fill_color); - IMB_colormanagement_srgb_to_scene_linear_v3(fill_color); + IMB_colormanagement_srgb_to_scene_linear_v3(fill_color, fill_color); if (filter_strength < 0.0 && !ss->filter_cache->pre_smoothed_color) { sculpt_color_presmooth_init(ss); diff --git a/source/blender/editors/sculpt_paint/sculpt_ops.c b/source/blender/editors/sculpt_paint/sculpt_ops.c index 5aa1dbef74c..8df1cc458d3 100644 --- a/source/blender/editors/sculpt_paint/sculpt_ops.c +++ b/source/blender/editors/sculpt_paint/sculpt_ops.c @@ -780,8 +780,7 @@ static int sculpt_sample_color_invoke(bContext *C, wmOperator *op, const wmEvent } float color_srgb[3]; - copy_v3_v3(color_srgb, active_vertex_color); - IMB_colormanagement_scene_linear_to_srgb_v3(color_srgb); + IMB_colormanagement_scene_linear_to_srgb_v3(color_srgb, active_vertex_color); BKE_brush_color_set(scene, brush, color_srgb); WM_event_add_notifier(C, NC_BRUSH | NA_EDITED, brush); diff --git a/source/blender/editors/sculpt_paint/sculpt_paint_color.c b/source/blender/editors/sculpt_paint/sculpt_paint_color.c index 7a8a6e8e484..ac05652b058 100644 --- a/source/blender/editors/sculpt_paint/sculpt_paint_color.c +++ b/source/blender/editors/sculpt_paint/sculpt_paint_color.c @@ -124,7 +124,7 @@ static void do_paint_brush_task_cb_ex(void *__restrict userdata, copy_v3_v3(brush_color, ss->cache->invert ? BKE_brush_secondary_color_get(ss->scene, brush) : BKE_brush_color_get(ss->scene, brush)); - IMB_colormanagement_srgb_to_scene_linear_v3(brush_color); + IMB_colormanagement_srgb_to_scene_linear_v3(brush_color, brush_color); BKE_pbvh_vertex_iter_begin (ss->pbvh, data->nodes[n], vd, PBVH_ITER_UNIQUE) { SCULPT_orig_vert_data_update(&orig_data, &vd); diff --git a/source/blender/imbuf/IMB_colormanagement.h b/source/blender/imbuf/IMB_colormanagement.h index 94036da9d22..50af946cd95 100644 --- a/source/blender/imbuf/IMB_colormanagement.h +++ b/source/blender/imbuf/IMB_colormanagement.h @@ -76,13 +76,17 @@ BLI_INLINE unsigned char IMB_colormanagement_get_luminance_byte(const unsigned c /** * Conversion between scene linear and other color spaces. */ -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]); -BLI_INLINE void IMB_colormanagement_rec709_to_rgb(float rgb[3], const float rec709[3]); -BLI_INLINE void IMB_colormanagement_rgb_to_rec709(float rec709[3], const float rgb[3]); -BLI_INLINE void IMB_colormanagement_aces_to_rgb(float rgb[3], const float aces[3]); -BLI_INLINE void IMB_colormanagement_rgb_to_aces(float aces[3], const float rgb[3]); -const float *IMB_colormanagement_get_xyz_to_rgb(void); +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); /** \} */ @@ -196,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 fd70c633f83..23b3f0191b7 100644 --- a/source/blender/imbuf/intern/IMB_colormanagement_intern.h +++ b/source/blender/imbuf/intern/IMB_colormanagement_intern.h @@ -18,12 +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_xyz_to_aces[3][3]; -extern float imbuf_aces_to_xyz[3][3]; -extern float imbuf_xyz_to_rec709[3][3]; -extern float imbuf_rec709_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 f189614e61c..35601abab6e 100644 --- a/source/blender/imbuf/intern/colormanagement.c +++ b/source/blender/imbuf/intern/colormanagement.c @@ -73,12 +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}}; -float imbuf_xyz_to_rec709[3][3] = {{0.0f}}; -float imbuf_rec709_to_xyz[3][3] = {{0.0f}}; -float imbuf_xyz_to_aces[3][3] = {{0.0f}}; -float imbuf_aces_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 @@ -577,12 +577,14 @@ static void colormanage_load_config(OCIO_ConstConfigRcPtr *config) OCIO_configGetDefaultLumaCoefs(config, imbuf_luma_coefficients); /* Load standard color spaces. */ - OCIO_configGetXYZtoRGB(config, imbuf_xyz_to_rgb); - invert_m3_m3(imbuf_rgb_to_xyz, imbuf_xyz_to_rgb); - copy_m3_m3(imbuf_xyz_to_rec709, OCIO_XYZ_TO_REC709); - invert_m3_m3(imbuf_rec709_to_xyz, imbuf_xyz_to_rec709); - copy_m3_m3(imbuf_aces_to_xyz, OCIO_ACES_TO_XYZ); - invert_m3_m3(imbuf_xyz_to_aces, imbuf_aces_to_xyz); + 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) @@ -1424,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]; } /** \} */ @@ -2319,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. */ @@ -2341,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. */ @@ -2368,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_rec709, 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_rec709_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 4c632da1520..668307ec802 100644 --- a/source/blender/imbuf/intern/colormanagement_inline.c +++ b/source/blender/imbuf/intern/colormanagement_inline.c @@ -27,38 +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_rgb(float rgb[3], const float rec709[3]) +void IMB_colormanagement_rec709_to_scene_linear(float scene_linear[3], const float rec709[3]) { - mul_v3_m3v3(rgb, imbuf_rec709_to_xyz, rec709); - mul_v3_m3v3(rgb, imbuf_xyz_to_rgb, rgb); + mul_v3_m3v3(scene_linear, imbuf_rec709_to_scene_linear, rec709); } -void IMB_colormanagement_rgb_to_rec709(float rec709[3], const float rgb[3]) +void IMB_colormanagement_scene_linear_to_rec709(float rec709[3], const float scene_linear[3]) { - mul_v3_m3v3(rec709, imbuf_rgb_to_xyz, rgb); - mul_v3_m3v3(rec709, imbuf_xyz_to_rec709, rec709); + mul_v3_m3v3(rec709, imbuf_scene_linear_to_rec709, scene_linear); } -void IMB_colormanagement_aces_to_rgb(float rgb[3], const float aces[3]) +void IMB_colormanagement_scene_linear_to_srgb_v3(float srgb[3], const float scene_linear[3]) { - mul_v3_m3v3(rgb, imbuf_aces_to_xyz, aces); - mul_v3_m3v3(rgb, imbuf_xyz_to_rgb, rgb); + mul_v3_m3v3(srgb, imbuf_scene_linear_to_rec709, scene_linear); + linearrgb_to_srgb_v3_v3(srgb, srgb); } -void IMB_colormanagement_rgb_to_aces(float aces[3], const float rgb[3]) +void IMB_colormanagement_srgb_to_scene_linear_v3(float scene_linear[3], const float srgb[3]) { - mul_v3_m3v3(aces, imbuf_rgb_to_xyz, rgb); - mul_v3_m3v3(aces, imbuf_xyz_to_aces, aces); + 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__ */ diff --git a/source/blender/nodes/shader/node_shader_util.cc b/source/blender/nodes/shader/node_shader_util.cc index c47b69e6b69..059d7800fc5 100644 --- a/source/blender/nodes/shader/node_shader_util.cc +++ b/source/blender/nodes/shader/node_shader_util.cc @@ -329,7 +329,7 @@ void node_shader_gpu_tex_mapping(GPUMaterial *mat, void get_XYZ_to_RGB_for_gpu(XYZ_to_RGB *data) { - const float *xyz_to_rgb = IMB_colormanagement_get_xyz_to_rgb(); + const float *xyz_to_rgb = IMB_colormanagement_get_xyz_to_scene_linear(); data->r[0] = xyz_to_rgb[0]; data->r[1] = xyz_to_rgb[3]; data->r[2] = xyz_to_rgb[6]; diff --git a/source/blender/python/mathutils/mathutils_Color.c b/source/blender/python/mathutils/mathutils_Color.c index 1495a465432..0fcde229907 100644 --- a/source/blender/python/mathutils/mathutils_Color.c +++ b/source/blender/python/mathutils/mathutils_Color.c @@ -87,8 +87,8 @@ PyDoc_STRVAR(Color_from_scene_linear_to_srgb_doc, " :rtype: :class:`Color`\n"); static PyObject *Color_from_scene_linear_to_srgb(ColorObject *self) { - float col[3] = {self->col[0], self->col[1], self->col[2]}; - IMB_colormanagement_scene_linear_to_srgb_v3(col); + float col[3]; + IMB_colormanagement_scene_linear_to_srgb_v3(col, self->col); return Color_CreatePyObject(col, Py_TYPE(self)); } @@ -101,8 +101,8 @@ PyDoc_STRVAR(Color_from_srgb_to_scene_linear_doc, " :rtype: :class:`Color`\n"); static PyObject *Color_from_srgb_to_scene_linear(ColorObject *self) { - float col[3] = {self->col[0], self->col[1], self->col[2]}; - IMB_colormanagement_srgb_to_scene_linear_v3(col); + float col[3]; + IMB_colormanagement_srgb_to_scene_linear_v3(col, self->col); return Color_CreatePyObject(col, Py_TYPE(self)); } @@ -116,7 +116,7 @@ PyDoc_STRVAR(Color_from_scene_linear_to_xyz_d65_doc, static PyObject *Color_from_scene_linear_to_xyz_d65(ColorObject *self) { float col[3]; - IMB_colormanagement_rgb_to_xyz(col, self->col); + IMB_colormanagement_scene_linear_to_xyz(col, self->col); return Color_CreatePyObject(col, Py_TYPE(self)); } @@ -130,7 +130,7 @@ PyDoc_STRVAR(Color_from_xyz_d65_to_scene_linear_doc, static PyObject *Color_from_xyz_d65_to_scene_linear(ColorObject *self) { float col[3]; - IMB_colormanagement_xyz_to_rgb(col, self->col); + IMB_colormanagement_xyz_to_scene_linear(col, self->col); return Color_CreatePyObject(col, Py_TYPE(self)); } @@ -144,7 +144,7 @@ PyDoc_STRVAR(Color_from_scene_linear_to_aces_doc, static PyObject *Color_from_scene_linear_to_aces(ColorObject *self) { float col[3]; - IMB_colormanagement_rgb_to_aces(col, self->col); + IMB_colormanagement_scene_linear_to_aces(col, self->col); return Color_CreatePyObject(col, Py_TYPE(self)); } @@ -158,7 +158,7 @@ PyDoc_STRVAR(Color_from_aces_to_scene_linear_doc, static PyObject *Color_from_aces_to_scene_linear(ColorObject *self) { float col[3]; - IMB_colormanagement_aces_to_rgb(col, self->col); + IMB_colormanagement_aces_to_scene_linear(col, self->col); return Color_CreatePyObject(col, Py_TYPE(self)); } @@ -172,7 +172,7 @@ PyDoc_STRVAR(Color_from_scene_linear_to_rec709_linear_doc, static PyObject *Color_from_scene_linear_to_rec709_linear(ColorObject *self) { float col[3]; - IMB_colormanagement_rgb_to_rec709(col, self->col); + IMB_colormanagement_scene_linear_to_rec709(col, self->col); return Color_CreatePyObject(col, Py_TYPE(self)); } @@ -186,7 +186,7 @@ PyDoc_STRVAR(Color_from_rec709_linear_to_scene_linear_doc, static PyObject *Color_from_rec709_linear_to_scene_linear(ColorObject *self) { float col[3]; - IMB_colormanagement_rec709_to_rgb(col, self->col); + IMB_colormanagement_rec709_to_scene_linear(col, self->col); return Color_CreatePyObject(col, Py_TYPE(self)); } -- cgit v1.2.3