Blender V4.3
BLI_math_color.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2022 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
11#include <cmath>
12#include <type_traits>
13
14#include "BLI_color.hh"
15#include "BLI_math_base.hh"
17
18namespace blender::math {
19
20template<eAlpha Alpha>
23 const float t)
24{
25 return {math::interpolate(a.r, b.r, t),
26 math::interpolate(a.g, b.g, t),
27 math::interpolate(a.b, b.b, t),
28 math::interpolate(a.a, b.a, t)};
29}
30
31template<eAlpha Alpha>
35 const float t)
36{
37 return {math::interpolate(a.r, b.r, t),
38 math::interpolate(a.g, b.g, t),
39 math::interpolate(a.b, b.b, t),
40 math::interpolate(a.a, b.a, t)};
41}
42
43float3 whitepoint_from_temp_tint(float temperature, float tint);
44
45bool whitepoint_to_temp_tint(const float3 &white, float &temperature, float &tint);
46
47/* Computes a matrix to perform chromatic adaption from a source white point (given in the form of
48 * temperature and tint) to a target white point (given as its XYZ values).
49 * The resulting matrix operates on XYZ values, the caller is responsible for RGB conversion. */
50float3x3 chromatic_adaption_matrix(const float3 &from_XYZ, const float3 &to_XYZ);
51
52} // namespace blender::math
local_group_size(16, 16) .push_constant(Type b
float3 whitepoint_from_temp_tint(float temperature, float tint)
bool whitepoint_to_temp_tint(const float3 &white, float &temperature, float &tint)
T interpolate(const T &a, const T &b, const FactorT &t)
float3x3 chromatic_adaption_matrix(const float3 &from_XYZ, const float3 &to_XYZ)