forked from rodrigomas/DCTLs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Log3G10_RWG_to_Rec709_linear.dctl
22 lines (16 loc) · 1.12 KB
/
Log3G10_RWG_to_Rec709_linear.dctl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
// RedWideGamutRGB Log3G10 to Rec.709 Linear
__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 RWGtoXYZ[9] = {0.735275f, 0.068609f, 0.146571f, 0.286694f, 0.842979f, -0.129673f, -0.079681f, -0.347343f, 1.516082f};
const float XYZto709[9] = {3.2406f, -1.5372f, -0.4986f, -0.9689f, 1.8758f, 0.0415f, 0.0557f, -0.2040f, 1.0570f};
float lr = ((_powf(10.0f, p_R / 0.224282f) - 1.0f) / 155.975327f) - 0.01f;
float lg = ((_powf(10.0f, p_G / 0.224282f) - 1.0f) / 155.975327f) - 0.01f;
float lb = ((_powf(10.0f, p_B / 0.224282f) - 1.0f) / 155.975327f) - 0.01f;
float xr = RWGtoXYZ[0] * lr + RWGtoXYZ[1] * lg + RWGtoXYZ[2] * lb;
float xg = RWGtoXYZ[3] * lr + RWGtoXYZ[4] * lg + RWGtoXYZ[5] * lb;
float xb = RWGtoXYZ[6] * lr + RWGtoXYZ[7] * lg + RWGtoXYZ[8] * lb;
const float r = XYZto709[0] * xr + XYZto709[1] * xg + XYZto709[2] * xb;
const float g = XYZto709[3] * xr + XYZto709[4] * xg + XYZto709[5] * xb;
const float b = XYZto709[6] * xr + XYZto709[7] * xg + XYZto709[8] * xb;
return make_float3(r, g, b);
}