Creative Coding With DCTL: Part 5

August 3, 2021

In part 5 of his ongoing series on coding DCTLs, Cullen starts to get into the thick of the tool he's creating - exploring how to define and code contrast.


Series

Playing With Contrast

Now that we’ve started building practical tools in Part 4 of this series, it’s time to turn our attention to the practical tool we’re ultimately looking to build in this series: the Filmic Contrast tool. We’ve seen this tool in action in Part 1, but let’s review the summary I’ve written up for it.

This tool, called Filmic Contrast, will apply a user-specified amount of contrast uniformly to the R, G, and B channels, followed by a user-specified mixture and intensity of cool colors to the shadows and warm colors to the highlights.

This summary is a good start: it’s clear, concise, and complete. But as you’ll almost always find when planning out new tools, answers to problems often lead to additional questions, because before we can begin coding, we need exact definitions of everything we’ll be doing.

In order to answer these additional questions, we’re going to focus today’s Insight on understanding the different forms of contrast, and how we can invoke them within a DCTL.

Together in the video below, we’re going to cover:

  • Why there’s no single objective definition of contrast
  • The key forms of tonal contrast
  • Implementing tonal contrast as a linear function
  • Implementing tonal contrast as a piecewise power function using conditionals
  • Creating additional functions to keep our main function efficient and legible

Let’s dive in!

Member Content

Sorry... the rest of this content is for members only. You'll need to login or sign up to continue (we hope you do!).

Membership options
Member Login

Comments

Homepage Forums Creative Coding With DCTL: Part 5

Viewing 10 reply threads

    • charles w rodriguez
      Guest

      Interesting that limiting the contrast scale to a max value of 2.0 does not reach 100% contrast. I played with upping the max value to 5.0, and, it’s better but still not 100%.Meanwhile, a minimim value of 0.0 is truly 0%.The function is a log(power) scale, I guess?


    • Cullen Kelly
      Guest

      Hey Charles! Are you referring to the linear or power-function contrast formula? Also, how are you defining 100% contrast?


    • Kevin O
      Guest

      Holy crap, Cullen, this is awesome! So excited for this to keep going!


    • Jim Robinson
      Guest

      Not hard to set up – but following along closely – didn’t see when the Template_Interactive was introduced. I am not confused but I can see how someone might be confused when a file comes out of nowhere.


    • Jim Robinson
      Guest

      hey Cullen – hasn’t anyone written a code validation app for this? It seems a little slow to close and load Resolve all the time. I used to write code and could validate in the software it was written in. You would think that BMD would have something that just displays the DCTL UI window and then runs the code for validation.
      Anyway, thanks in advance?
      Jim Robinson


    • Robbie Carman
      Guest

      I think it more has to do with the OFX/plug-in pipeline that’s nessasary for applying the DCTL more than any single DCTL. Every single DCTL I’ve ever used is sluggish on load and close. I have several in my node tree but keep those nodes disabled until I’m using them for this reason.

      It would be nice to not have to run a DCTL thru that pipe – more like how you can run python scripts directly in Resolve.


    • Jim Robinson
      Guest

      Hey thanks Robbie, getting frustrated I guess. I have coded exactly as cullen has here and starting and stopping Resolve just to check syntax, whenever I think there must be an easier way there usually is. I wonder if Cullen swapped files at some point in the video. I used to be a coder in Coldfusion and I have looked at my code word by word etc. and the UI shows up, but it doesn’t work – something wrong with the function.

      _DEVICE_ float apply_contrast(float in, float contrast, float pivot)
      {
      float out;

      out = (in - pivot) * contrast + pivot;

      return out;

      }

      DEFINE_UI_PARAMS(contrast, Contrast, DCTLUI_SLIDER_FLOAT, 1.0, 0.0, 2.0, 0.1)
      DEFINE_UI_PARAMS(pivot, Pivot, DCTLUI_SLIDER_FLOAT, .435, 0.0, 1.0, 0.1)

      __DEVICE__ float3 transform(int p_Width, int p_Height, int p_X, int p_Y, float p_R, float p_G, float p_B)
      {

      float3 in = {p_R, p_G, p_B};
      float3 out;

      out.x = apply_contrast(in.x, contrast, pivot);
      out.y = apply_contrast(in.y, contrast, pivot);
      out.z = apply_contrast(in.z, contrast, pivot);
      return out;
      }

      Not sure if Cullen checks these forums – but just in case.


    • Robbie Carman
      Guest

      he does indeed. I’m not sure of the exact syntax here but I’m sure Cullen will chime in shortly – I’ve forwarded your comment to him so its at the top of his inbox


    • Cullen Kelly
      Guest

      Hey Jim! Unfortunately there’s no validation app. I know it’s frustrating! Though to be clear, you only need to close and relaunch Resolve following the creation of a brand new interactive DCTL. New static DCTLs can be pulled in just by refreshing your LUT directory, and OpenFX DCTLs can be refreshed after changes to their code with the “Reload DCTL” button.


    • Cullen Kelly
      Guest

      Remember to check the console so you can see where things are getting tripped up! And here’s a GitFront link which includes a working version of the S-Curve tool: https://gitfront.io/r/cullenkelly/7d044328c5cb6d8439cc0c623edb9e9c6b3d3777/Creative-Coding-with-DCTL/


    • Cullen Kelly
      Guest

      FYI — we covered Template_Interactive in Part 4

Viewing 10 reply threads
  • You must be logged in to reply to this topic.

Hundreds of Free Tutorials

Get full access to our entire library of 900+ color tutorials for an entire week!


Start Your Free Trial
Loading...