Blender V5.0
OCIO_matrix.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2025 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
8
9namespace blender::ocio {
10
11/* Standard XYZ (D65) to linear Rec.709 transform. */
12/* Use four-digit constants instead of higher precisions to match sRGB and Rec.2020 standards.
13 * See PR #141027 for details. */
14static const float3x3 XYZ_TO_REC709{{3.2409699f, -0.9692436f, 0.0556301f},
15 {-1.5373832f, 1.8759675f, -0.2039770f},
16 {-0.4986108f, 0.0415551f, 1.0569715f}};
17
18/* Standard XYZ (D65) to linear Rec.2020 transform. */
19/* Use four-digit constants instead of higher precisions to match sRGB and Rec.2020 standards.
20 * See PR #141027 for details. */
21static const float3x3 XYZ_TO_REC2020{{1.7166512f, -0.6666844, 0.0176399f},
22 {-0.3556708f, 1.6164812f, -0.0427706f},
23 {-0.2533663f, 0.0157685f, 0.9421031f}};
24
25/* Standard ACES to XYZ (D65) transform.
26 * Matches OpenColorIO builtin transform: UTILITY - ACES-AP0_to_CIE-XYZ-D65_BFD. */
27static const float3x3 ACES_TO_XYZ = {{0.938280f, 0.337369f, 0.001174f},
28 {-0.004451f, 0.729522f, -0.003711f},
29 {0.016628f, -0.066890f, 1.091595f}};
30
31/* Standard ACEScg to XYZ (D65) transform.
32 * Matches OpenColorIO builtin transform: UTILITY - ACES-AP1_to_CIE-XYZ-D65_BFD. */
33static const float3x3 ACESCG_TO_XYZ = {{0.652238f, 0.267672f, -0.005382f},
34 {0.128237f, 0.674340f, 0.001369f},
35 {0.169983f, 0.057988f, 1.093071f}};
36
37/* Double precision variations that match OpenColorIO to cancel out transforms accurately. */
39 {3.2409699419045217, -0.96924363628087973, 0.055630079696993649, 0},
40 {-1.5373831775700935, 1.8759675015077204, -0.20397695888897652, 0},
41 {-0.49861076029300355, 0.041555057407175626, 1.0569715142428788, 0},
42 {0, 0, 0, 1}};
43
44static const double4x4 OCIO_XYZ_TO_P3 = {
45 {2.690225911625598, -0.82008218427349111, 0.03624575465400464, 0},
46 {-1.0940019373661367, 1.7504809082920574, -0.07858083680558868, 0},
47 {-0.4250823476747525, 0.026601954212205722, 0.95874699366098559, 0},
48 {0, 0, 0, 1}};
49
51 {1.716651187971268, -0.66668435183248875, 0.01763985744531079, 0},
52 {-0.35567078377639244, 1.6164812366349386, -0.04277061325780853, 0},
53 {-0.25336628137365991, 0.015768545813911128, 0.94210312123547435, 0},
54 {0, 0, 0, 1}};
55
56} // namespace blender::ocio
static const float3x3 ACES_TO_XYZ
static const float3x3 XYZ_TO_REC2020
static const double4x4 OCIO_XYZ_TO_P3
static const double4x4 OCIO_XYZ_TO_REC2020
static const float3x3 ACESCG_TO_XYZ
static const double4x4 OCIO_XYZ_TO_REC709
static const float3x3 XYZ_TO_REC709
MatBase< float, 3, 3 > float3x3
MatBase< double, 4, 4 > double4x4