Blender V5.3
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, dumped from OpenColorIO so it matches
12 * those transforms exactly. Use four-digit constants instead of higher precisions to
13 * match sRGB and Rec.2020 standards.
14 * See PR #141027 for details. */
15static const float3x3 XYZ_TO_REC709{{3.2409699f, -0.9692436f, 0.0556301f},
16 {-1.5373832f, 1.8759675f, -0.2039770f},
17 {-0.4986108f, 0.0415551f, 1.0569715f}};
18
19/* Standard XYZ (D65) to linear Rec.2020 transform. */
20/* Use four-digit constants instead of higher precisions to match sRGB and Rec.2020 standards.
21 * See PR #141027 for details. */
22static const float3x3 XYZ_TO_REC2020{{1.7166512f, -0.6666844, 0.0176399f},
23 {-0.3556708f, 1.6164812f, -0.0427706f},
24 {-0.2533663f, 0.0157685f, 0.9421031f}};
25
26/* Standard ACES to XYZ (D65) transform.
27 * Matches OpenColorIO builtin transform: UTILITY - ACES-AP0_to_CIE-XYZ-D65_BFD. */
28static const float3x3 ACES_TO_XYZ = {{0.938280f, 0.337369f, 0.001174f},
29 {-0.004451f, 0.729522f, -0.003711f},
30 {0.016628f, -0.066890f, 1.091595f}};
31
32/* Standard ACEScg to XYZ (D65) transform.
33 * Matches OpenColorIO builtin transform: UTILITY - ACES-AP1_to_CIE-XYZ-D65_BFD. */
34static const float3x3 ACESCG_TO_XYZ = {{0.652238f, 0.267672f, -0.005382f},
35 {0.128237f, 0.674340f, 0.001369f},
36 {0.169983f, 0.057988f, 1.093071f}};
37
38/* Double precision variations that match OpenColorIO to cancel out transforms accurately. */
40 {3.2409699419045217, -0.96924363628087973, 0.055630079696993649, 0},
41 {-1.5373831775700935, 1.8759675015077204, -0.20397695888897652, 0},
42 {-0.49861076029300355, 0.041555057407175626, 1.0569715142428788, 0},
43 {0, 0, 0, 1}};
44
45static const double4x4 OCIO_XYZ_TO_P3 = {
46 {2.690225911625598, -0.82008218427349111, 0.03624575465400464, 0},
47 {-1.0940019373661367, 1.7504809082920574, -0.07858083680558868, 0},
48 {-0.4250823476747525, 0.026601954212205722, 0.95874699366098559, 0},
49 {0, 0, 0, 1}};
50
52 {1.716651187971268, -0.66668435183248875, 0.01763985744531079, 0},
53 {-0.35567078377639244, 1.6164812366349386, -0.04277061325780853, 0},
54 {-0.25336628137365991, 0.015768545813911128, 0.94210312123547435, 0},
55 {0, 0, 0, 1}};
56
57} // 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