Antkeeper  0.0.1
aces.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2023 Christopher J. Howard
3  *
4  * This file is part of Antkeeper source code.
5  *
6  * Antkeeper source code is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * Antkeeper source code is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with Antkeeper source code. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #ifndef ANTKEEPER_COLOR_ACES_HPP
21 #define ANTKEEPER_COLOR_ACES_HPP
22 
23 #include <engine/color/rgb.hpp>
24 #include <engine/math/matrix.hpp>
25 #include <engine/math/vector.hpp>
26 
27 namespace color {
28 
31 
33 template <class T>
34 constexpr math::vec2<T> aces_white_point = {T{0.32168}, T{0.33767}};
35 
37 template <class T>
39 (
40  {T{0.7347}, T{ 0.2653}},
41  {T{0.0000}, T{ 1.0000}},
42  {T{0.0001}, T{-0.0770}},
43  aces_white_point<T>,
44  nullptr,
45  nullptr
46 );
47 
49 template <class T>
51 (
52  {T{0.713}, T{0.293}},
53  {T{0.165}, T{0.830}},
54  {T{0.128}, T{0.044}},
55  aces_white_point<T>,
56  nullptr,
57  nullptr
58 );
59 
68 template <class T>
69 [[nodiscard]] constexpr math::mat3<T> aces_adjust_saturation(T s, const math::vec3<T>& to_y) noexcept
70 {
71  const math::vec3<T> v = to_y * (T{1} - s);
72  return math::mat3<T>
73  {
74  v[0] + s, v[0], v[0],
75  v[1], v[1] + s, v[1],
76  v[2], v[2], v[2] + s
77  };
78 }
79 
81 template <class T>
82 constexpr math::mat3<T> aces_ap1_rrt_sat = aces_adjust_saturation(T{0.96}, aces_ap1<T>.to_y);
83 
85 template <class T>
86 constexpr math::mat3<T> aces_ap1_odt_sat = aces_adjust_saturation(T{0.93}, aces_ap1<T>.to_y);
87 
89 
90 } // namespace color
91 
92 #endif // ANTKEEPER_COLOR_ACES_HPP
Color science.
Definition: aces.hpp:27
constexpr rgb_color_space< T > aces_ap0({T{0.7347}, T{ 0.2653}}, {T{0.0000}, T{ 1.0000}}, {T{0.0001}, T{-0.0770}}, aces_white_point< T >, nullptr, nullptr)
ACES AP0 color space.
constexpr math::vec2< T > aces_white_point
CIE xy chromaticity coordinates of the ACES white point (~D60).
Definition: aces.hpp:34
constexpr math::mat3< T > aces_adjust_saturation(T s, const math::vec3< T > &to_y) noexcept
Constructs a saturation adjustment matrix.
Definition: aces.hpp:69
constexpr rgb_color_space< T > aces_ap1({T{0.713}, T{0.293}}, {T{0.165}, T{0.830}}, {T{0.128}, T{0.044}}, aces_white_point< T >, nullptr, nullptr)
ACES AP1 color space.
constexpr math::mat3< T > aces_ap1_odt_sat
ACES AP1 ODT saturation adjustment matrix.
Definition: aces.hpp:86
constexpr math::mat3< T > aces_ap1_rrt_sat
ACES AP1 RRT saturation adjustment matrix.
Definition: aces.hpp:82
RGB color space.
Definition: rgb.hpp:70
n by m column-major matrix.
Definition: math/matrix.hpp:44
n-dimensional vector.
Definition: vector.hpp:44