ACES IDT DCTL Generator

Thanks for the insights, @Hook.

I know it must be the billionth time you’ve been asked, but is there any chance of white papers on your colour encodings? Fair enough that the earlier variants have “primaries” that are just backed out of a matrix, so you may not want to publish those, but for gen 4 and 5 you have defined primaries. And your transfer functions are mathematically defined for all of them. Leaving these unpublished creates problems for your customers.

I know Blackmagic wants to take over the world, and have people never step outside the Resolve ecosystem :wink: . But that’s not the world your customers work in!

Gen 5 is in a particular limbo state at the moment. Any camera updated to the latest firmware (like my Pocket 4K) is outputting v5 log. And Resolve 17 can decode BRAW to the same. But it is not possible to build even a reverse engineered IDT for it, because it is not included in RCM or the CST plugin.

3 Likes

Ditto! Would contribute to saving us some time also!

is there any chance of white papers on your colour encodings

Can’t say much publicly at the moment, but hopefully. :crossed_fingers:t2:

it is not possible to build even a reverse engineered IDT for it, because it is not included in RCM or the CST plugin.

On that topic it should be finally available (unless something changes) in the next Resolve release (17.2). But as alluded to, if all goes as hoped that won’t be needed to reverse an IDT for Gen 5.

3 Likes

Very pleased to see that at least the Gen 5 encoding is detailed in a white paper included with the Blackmagic RAW 2.1 SDK.

1 Like

Yes, thanks for that!

Cheers,

Thomas

seems like the domain http://acesidtdctl.tcolorscience.com/ has expired , I really loved using the generator .would be amazing to get this fixed?

Thx for notifying me. I just fixed it.

1 Like

Thank you so much, really great!

Interesting, this is how it looks like on my end for at least a couple of months:

I’m sorry for the inconvenience. It should work fine for now. I saw the previous post about adding cct transformation. Paul’s tools are great. I will consider adding more features for the generator when I have time.

1 Like

Thanks! It still opens the same site on my end though. But I guess this is because it will take some time until my provider update DNS records.

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

1 Like

I found that the CTL implementation math in the LogC4 whitepaper is for converting LogC4 encoded values to Relative Scene Linear Values, so the outv of a Logc4 encoded value of 1:
inv = 1 → outv = 469.8

which doesn’t give a linearized value between 0 and 1.

That is correct. The output of an IDT linearisation is not supposed to be ranged 0-1. It is scaled so a correctly exposed 18% grey card is represented by 0.18; 1.0 represents a perfect diffuse reflector; and highlights and specular will be values above 1.0.

What I found is that if in the DCTL posted I change
P = 14.0f * (inv - C) / B + 6.0f
to, for example,
P = 10.0f * (inv - C) / B + 6.0f

I get a tone mapping inside ACEScct that could make sense, and “similar” to an IDT of Alexa LogC3. With a value of 14.0f the values explode to white.

In the Log-C whitepaper they make formula constant distinctions from “ALEXA (SUP 3.x) Log C signal and linear scene exposure factor” and “ALEXA (SUP 3.x) Log C signal and normalized sensor signal.”

I am slightly confused. Your DCTL posted earlier works exactly as it should. It matches the built in LogC4 IDT in Resolve 18.1. I assume you must be in a position where you have to use an older version of Resolve, as otherwise you could use the built in IDT and have no need of the DCTL.

I’m confused again! ACEScct should not have any tone mapping. It is a logarithmic scene-referred encoding, designed as a working space for grading. The output needs to be viewed through an appropriate ACES Output Transform.

Remember an IDT transforms to linear AP0, so to construct a manual ACES pipeline when not in ACES mode, you would need your DCTL as the first node, followed by an ACES Transform from “No Input Transform” i.e. ACES2065-1 (linear AP0) to ACEScct. That would be followed by whatever nodes you needed for grading, and finally another ACES Transform from ACEScct to e.g. Rec.709 to apply the Output Transform. This last one could be applied in a Timeline node.

Thank you for your response. I was doing my tests in an ACES project and loading the DCTL in the first node instead of input LUT. That was my mistake. Tried the DCTL in YRGB ACES node tree, and everything works as expected. Thank you very much.