Hi, @tommyzenth . I found your tool and I tried (without success) to create a DCTL IDT for AWG4 LogC4. My skills to DCTL coding are none, so I just tried to adapt the code from the ARRI IDT in CTL to DCTL following your code. However, I don’t know where I’m failing, but I am.
CTL Code
// <ACEStransformID>urn:ampas:aces:transformId:v1.5:IDT.ARRI.ARRI-LogC4.a1.v1</ACEStransformID>
// <ACESuserName>ACES 1.0 Input - ARRI LogC4 </ACESuserName>
// ARRI IDT for ARRI LogC4
// LogC4 Curve Decoding Function
float normalizedLogC4ToRelativeSceneLinear( float x) {
// Constants
const float a = (pow(2.0, 18.0) - 16.0) / 117.45;
const float b = (1023.0 - 95.0) / 1023.0;
const float c = 95.0 / 1023.0;
const float s = (7.0 * log(2.0) * pow(2.0, 7.0 - 14.0 * c / b)) / (a * b);
const float t = (pow(2.0, 14.0 * (-c / b) + 6.0) - 64.0) / a;
if (x < 0.0) {
return x * s + t;
}
float p = 14.0 * (x - c) / b + 6.0;
return (pow(2.0, p) - 64.0) / a;
}
void main
( input varying float rIn,
input varying float gIn,
input varying float bIn,
input varying float aIn,
output varying float rOut,
output varying float gOut,
output varying float bOut,
output varying float aOut)
{
float r_lin = normalizedLogC4ToRelativeSceneLinear(rIn);
float g_lin = normalizedLogC4ToRelativeSceneLinear(gIn);
float b_lin = normalizedLogC4ToRelativeSceneLinear(bIn);
// Matrix AWG4 D65 --CAT02--> ACES AP0 ACES White Point
rOut = r_lin * 0.750957362824734131 + g_lin * 0.144422786709757084 + b_lin * 0.104619850465508965;
gOut = r_lin * 0.000821837079380207 + g_lin * 1.007397584885003194 + b_lin * -0.008219421964383583;
bOut = r_lin * -0.000499952143533471 + g_lin * -0.000854177231436971 + b_lin * 1.001354129374970370;
aOut = 1.0;
}
My DCTL code
// ACES IDT AWG4 LogC4 to ACES(AP0) DCTL
__DEVICE__ inline float Log_to_linear(float inv)
{
float outv;
float A = ( _powf(2.0f, 18.0f ) - 16.0f ) / 117.45f;
float B = ( 1023.0f - 95.0f ) / 1023.0f;
float C = 95.0f / 1023.0f;
float S = ( 7.0f * _logf(2.0f) * _powf(2.0f, 7.0f - 14.0f * C / B) ) / (A * B);
float T = ( _powf(2.0f, 14.0f * (-C / B) + 6.0f ) - 64.0f) / A;
float P;
if (inv < 0.0f)
{
outv = inv * S + T;
}
else
{
P = 14.0f * (inv - C) / B + 6.0f;
outv = (_powf(2.0f, P) - 64.0f) / A;;
}
return outv;
}
__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 mtx[9] = {0.750957362824734131f,0.144422786709757084f,0.104619850465508965f,
0.000821837079380207f,1.007397584885003194f,-0.008219421964383583f,
-0.000499952143533471f,-0.000854177231436971f,1.001354129374970370f};
float r1 = Log_to_linear(p_R);
float g1 = Log_to_linear(p_G);
float b1 = Log_to_linear(p_B);
float r2 = r1 * mtx[0] + g1 * mtx[1] + b1 * mtx[2];
float g2 = r1 * mtx[3] + g1 * mtx[4] + b1 * mtx[5];
float b2 = r1 * mtx[6] + g1 * mtx[7] + b1 * mtx[8];
return make_float3(r2, g2, b2);
}
Could you implement in the tool, or help me with the code? Thanks in advance