-
Notifications
You must be signed in to change notification settings - Fork 57
/
Copy pathRec709_Linear_to_Log3G10_RWG.dctl
executable file
·26 lines (19 loc) · 1.22 KB
/
Rec709_Linear_to_Log3G10_RWG.dctl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// Rec.709 Linear to Log3G10 RedWideGamutRGB
__DEVICE__ float3 transform(int p_Width, int p_Height, int p_X, int p_Y, float p_R, float p_G, float p_B)
{
const float RectoXYZ[9] = {0.4124f, 0.3576f, 0.1805f, 0.2126f, 0.7152f, 0.0722f, 0.0193f, 0.1192f, 0.9505f};
const float XYZtoRWG[9] = {1.412807f, -0.177522f, -0.151770f, -0.486203f, 1.290696f, 0.157400f, -0.037139f, 0.286376f, 0.687680f};
float xr = RectoXYZ[0] * p_R + RectoXYZ[1] * p_G + RectoXYZ[2] * p_B;
float xg = RectoXYZ[3] * p_R + RectoXYZ[4] * p_G + RectoXYZ[5] * p_B;
float xb = RectoXYZ[6] * p_R + RectoXYZ[7] * p_G + RectoXYZ[8] * p_B;
float rr = XYZtoRWG[0] * xr + XYZtoRWG[1] * xg + XYZtoRWG[2] * xb;
float rg = XYZtoRWG[3] * xr + XYZtoRWG[4] * xg + XYZtoRWG[5] * xb;
float rb = XYZtoRWG[6] * xr + XYZtoRWG[7] * xg + XYZtoRWG[8] * xb;
rr = rr + 0.01f;
rg = rg + 0.01f;
rb = rb + 0.01f;
const float r = rr < 0.0f ? rr * 15.1927f : 0.224282f * _log10f((rr * 155.975327f) + 1.0f);
const float g = rg < 0.0f ? rg * 15.1927f : 0.224282f * _log10f((rg * 155.975327f) + 1.0f);
const float b = rb < 0.0f ? rb * 15.1927f : 0.224282f * _log10f((rb * 155.975327f) + 1.0f);
return make_float3(r, g, b);
}