Blender V5.3
eevee_colorspace_lib.bsl.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
8
9namespace colorspace {
10
11/* -------------------------------------------------------------------- */
14
16{
17 const float3x3 colorspace_tx = transpose(float3x3(float3(1, 2, 1), /* Y */
18 float3(2, 0, -2), /* Co */
19 float3(-1, 2, -1))); /* Cg */
20 return colorspace_tx * rgb_color;
21}
22
24{
25 return float4(YCoCg_from_scene_linear(rgba_color.rgb), rgba_color.a);
26}
27
29{
30 float Y = ycocg_color.x;
31 float Co = ycocg_color.y;
32 float Cg = ycocg_color.z;
33
34 float3 rgb_color;
35 rgb_color.r = Y + Co - Cg;
36 rgb_color.g = Y + Cg;
37 rgb_color.b = Y - Co - Cg;
38 return rgb_color * 0.25f;
39}
40
42{
43 return float4(scene_linear_from_YCoCg(ycocg_color.rgb), ycocg_color.a);
44}
45
47
48/* -------------------------------------------------------------------- */
53
55{
56 return log2(1.0f + color);
57}
59{
60 return float4(log_from_scene_linear(color.rgb), color.a);
61}
62
64{
65 return exp2(color) - 1.0f;
66}
68{
69 return float4(scene_linear_from_log(color.rgb), color.a);
70}
71
73
79{
80 return clamp(c, float4(0.0f), float4(1e20f));
81}
83{
84 return clamp(c, float3(0.0f), float3(1e20f));
85}
86
91{
92 return color * saturate(limit / max(1e-8f, reduce_max(abs(color))));
93}
95{
96 return float4(brightness_clamp_max(color.rgb, limit), color.a);
97}
98
99} // namespace colorspace
#define Y
btScalar max
#define exp2
#define log2
#define abs
MatBase< R, C > transpose(MatBase< C, R >) RET
constexpr T clamp(T, U, U) RET
float reduce_max(float2 a)
float3 scene_linear_from_log(float3 color)
float3 log_from_scene_linear(float3 color)
float4 safe_color(float4 c)
float3 scene_linear_from_YCoCg(float3 ycocg_color)
float3 YCoCg_from_scene_linear(float3 rgb_color)
float3 brightness_clamp_max(float3 color, float limit)
#define saturate(a)
Definition smaa.cc:319
float z
Definition sky_math.h:136
float y
Definition sky_math.h:136
float x
Definition sky_math.h:136