Jump to: Board index » General » Fusion

Custom Tool - Serialization of the RGB Channel Operations

Learn about 3D compositing, animation, broadcast design and VFX workflows.
  • Author
  • Message
Offline

PourangKay

  • Posts: 13
  • Joined: Fri Dec 25, 2020 8:18 pm
  • Real Name: Pourang Kakouei

Custom Tool - Serialization of the RGB Channel Operations

PostThu Oct 21, 2021 7:17 pm

Hello,

How can I serialize Gamma, Offset, Lift, Gain operations (in that order) in the RGB Channel tab of the Custom Tool? I already know how each operation is represented mathematically (that is Lift = C1*(1-n1 )+n1) and I can apply each formula to all 3 channels and it works. But I can't unite all of them so that my Numbers (1 through 4 for each operation) correspond to GOLG respectively.

Thank you.
But all things excellent are as difficult as they are rare
Offline
User avatar

Bryan Ray

  • Posts: 2051
  • Joined: Mon Nov 28, 2016 5:32 am
  • Location: Los Angeles, CA, USA

Re: Custom Tool - Serialization of the RGB Channel Operation

PostThu Oct 21, 2021 7:38 pm

The expressions will follow the usual mathematical order of operations: Parenthesis, Exponents, Muliplication/Division, Addition/Subtraction (PEMDAS), and left-to-right. I usually find it easiest to work from last to first evaluation. That might just be an oddity of my psychology, though. I don't know.

Alternately, you could use individual tools (either CT or the must faster BrightnessContrast) in series and expression-link their controls to whichever CT you want to use for sliders, like so:

Code: Select all
{
   Tools = ordered() {
      lift = BrightnessContrast {
         NameSet = true,
         Inputs = {
            Lift = Input { Expression = "CustomTool1.NumberIn3", },
            Input = Input {
               SourceOp = "offset",
               Source = "Output",
            },
         },
         ViewInfo = OperatorInfo { Pos = { 440, 82.5 } },
      },
      gamma = BrightnessContrast {
         NameSet = true,
         Inputs = {
            Gamma = Input { Expression = "CustomTool1.NumberIn1", },
         },
         ViewInfo = OperatorInfo { Pos = { 220, 82.5 } },
      },
      offset = BrightnessContrast {
         NameSet = true,
         Inputs = {
            Brightness = Input { Expression = "CustomTool1.NumberIn2", },
            Input = Input {
               SourceOp = "gamma",
               Source = "Output",
            },
         },
         ViewInfo = OperatorInfo { Pos = { 330, 82.5 } },
      },
      gain = BrightnessContrast {
         CtrlWZoom = false,
         NameSet = true,
         Inputs = {
            Gain = Input { Expression = "CustomTool1.NumberIn4", },
            Input = Input {
               SourceOp = "lift",
               Source = "Output",
            },
         },
         ViewInfo = OperatorInfo { Pos = { 550, 82.5 } },
      },
      CustomTool1 = Custom {
         CtrlWZoom = false,
         Inputs = {
            NumberIn1 = Input { Value = 1, },
            NumberIn4 = Input { Value = 1, },
            LUTIn1 = Input {
               SourceOp = "CustomTool1LUTIn1",
               Source = "Value",
            },
            LUTIn2 = Input {
               SourceOp = "CustomTool1LUTIn2",
               Source = "Value",
            },
            LUTIn3 = Input {
               SourceOp = "CustomTool1LUTIn3",
               Source = "Value",
            },
            LUTIn4 = Input {
               SourceOp = "CustomTool1LUTIn4",
               Source = "Value",
            },
            NumberControls = Input { Value = 1, },
            NameforNumber1 = Input { Value = "Gamma", },
            NameforNumber2 = Input { Value = "Offset", },
            NameforNumber3 = Input { Value = "Lift", },
            NameforNumber4 = Input { Value = "Gain", },
            ShowNumber5 = Input { Value = 0, },
            ShowNumber6 = Input { Value = 0, },
            ShowNumber7 = Input { Value = 0, },
            ShowNumber8 = Input { Value = 0, },
            ShowPoint1 = Input { Value = 0, },
            ShowPoint2 = Input { Value = 0, },
            ShowPoint3 = Input { Value = 0, },
            ShowPoint4 = Input { Value = 0, },
            LUTControls = Input { Value = 1, },
            ShowLUT1 = Input { Value = 0, },
            ShowLUT2 = Input { Value = 0, },
            ShowLUT3 = Input { Value = 0, },
            ShowLUT4 = Input { Value = 0, },
            Image1 = Input {
               SourceOp = "gain",
               Source = "Output",
            },
         },
         ViewInfo = OperatorInfo { Pos = { 660, 82.5 } },
      },
      CustomTool1LUTIn1 = LUTBezier {
         KeyColorSplines = {
            [0] = {
               [0] = { 0, RH = { 0.333333333333333, 0.333333333333333 }, Flags = { Linear = true } },
               [1] = { 1, LH = { 0.666666666666667, 0.666666666666667 }, Flags = { Linear = true } }
            }
         },
         SplineColor = { Red = 204, Green = 0, Blue = 0 },
         NameSet = true,
      },
      CustomTool1LUTIn2 = LUTBezier {
         KeyColorSplines = {
            [0] = {
               [0] = { 0, RH = { 0.333333333333333, 0.333333333333333 }, Flags = { Linear = true } },
               [1] = { 1, LH = { 0.666666666666667, 0.666666666666667 }, Flags = { Linear = true } }
            }
         },
         SplineColor = { Red = 0, Green = 204, Blue = 0 },
         NameSet = true,
      },
      CustomTool1LUTIn3 = LUTBezier {
         KeyColorSplines = {
            [0] = {
               [0] = { 0, RH = { 0.333333333333333, 0.333333333333333 }, Flags = { Linear = true } },
               [1] = { 1, LH = { 0.666666666666667, 0.666666666666667 }, Flags = { Linear = true } }
            }
         },
         SplineColor = { Red = 0, Green = 0, Blue = 204 },
         NameSet = true,
      },
      CustomTool1LUTIn4 = LUTBezier {
         KeyColorSplines = {
            [0] = {
               [0] = { 0, RH = { 0.333333333333333, 0.333333333333333 }, Flags = { Linear = true } },
               [1] = { 1, LH = { 0.666666666666667, 0.666666666666667 }, Flags = { Linear = true } }
            }
         },
         SplineColor = { Red = 204, Green = 204, Blue = 204 },
         NameSet = true,
      }
   }
}
Bryan Ray
http://www.bryanray.name
http://www.musevfx.com
Offline

PourangKay

  • Posts: 13
  • Joined: Fri Dec 25, 2020 8:18 pm
  • Real Name: Pourang Kakouei

Re: Custom Tool - Serialization of the RGB Channel Operation

PostThu Oct 21, 2021 7:42 pm

Bryan Ray wrote:The expressions will follow the usual mathematical order of operations: Parenthesis, Exponents, Muliplication/Division, Addition/Subtraction (PEMDAS), and left-to-right. I usually find it easiest to work from last to first evaluation. That might just be an oddity of my psychology, though. I don't know.

Alternately, you could use individual tools (either CT or the must faster BrightnessContrast) in series and expression-link their controls to whichever CT you want to use for sliders, like so:

Code: Select all
{
   Tools = ordered() {
      lift = BrightnessContrast {
         NameSet = true,
         Inputs = {
            Lift = Input { Expression = "CustomTool1.NumberIn3", },
            Input = Input {
               SourceOp = "offset",
               Source = "Output",
            },
         },
         ViewInfo = OperatorInfo { Pos = { 440, 82.5 } },
      },
      gamma = BrightnessContrast {
         NameSet = true,
         Inputs = {
            Gamma = Input { Expression = "CustomTool1.NumberIn1", },
         },
         ViewInfo = OperatorInfo { Pos = { 220, 82.5 } },
      },
      offset = BrightnessContrast {
         NameSet = true,
         Inputs = {
            Brightness = Input { Expression = "CustomTool1.NumberIn2", },
            Input = Input {
               SourceOp = "gamma",
               Source = "Output",
            },
         },
         ViewInfo = OperatorInfo { Pos = { 330, 82.5 } },
      },
      gain = BrightnessContrast {
         CtrlWZoom = false,
         NameSet = true,
         Inputs = {
            Gain = Input { Expression = "CustomTool1.NumberIn4", },
            Input = Input {
               SourceOp = "lift",
               Source = "Output",
            },
         },
         ViewInfo = OperatorInfo { Pos = { 550, 82.5 } },
      },
      CustomTool1 = Custom {
         CtrlWZoom = false,
         Inputs = {
            NumberIn1 = Input { Value = 1, },
            NumberIn4 = Input { Value = 1, },
            LUTIn1 = Input {
               SourceOp = "CustomTool1LUTIn1",
               Source = "Value",
            },
            LUTIn2 = Input {
               SourceOp = "CustomTool1LUTIn2",
               Source = "Value",
            },
            LUTIn3 = Input {
               SourceOp = "CustomTool1LUTIn3",
               Source = "Value",
            },
            LUTIn4 = Input {
               SourceOp = "CustomTool1LUTIn4",
               Source = "Value",
            },
            NumberControls = Input { Value = 1, },
            NameforNumber1 = Input { Value = "Gamma", },
            NameforNumber2 = Input { Value = "Offset", },
            NameforNumber3 = Input { Value = "Lift", },
            NameforNumber4 = Input { Value = "Gain", },
            ShowNumber5 = Input { Value = 0, },
            ShowNumber6 = Input { Value = 0, },
            ShowNumber7 = Input { Value = 0, },
            ShowNumber8 = Input { Value = 0, },
            ShowPoint1 = Input { Value = 0, },
            ShowPoint2 = Input { Value = 0, },
            ShowPoint3 = Input { Value = 0, },
            ShowPoint4 = Input { Value = 0, },
            LUTControls = Input { Value = 1, },
            ShowLUT1 = Input { Value = 0, },
            ShowLUT2 = Input { Value = 0, },
            ShowLUT3 = Input { Value = 0, },
            ShowLUT4 = Input { Value = 0, },
            Image1 = Input {
               SourceOp = "gain",
               Source = "Output",
            },
         },
         ViewInfo = OperatorInfo { Pos = { 660, 82.5 } },
      },
      CustomTool1LUTIn1 = LUTBezier {
         KeyColorSplines = {
            [0] = {
               [0] = { 0, RH = { 0.333333333333333, 0.333333333333333 }, Flags = { Linear = true } },
               [1] = { 1, LH = { 0.666666666666667, 0.666666666666667 }, Flags = { Linear = true } }
            }
         },
         SplineColor = { Red = 204, Green = 0, Blue = 0 },
         NameSet = true,
      },
      CustomTool1LUTIn2 = LUTBezier {
         KeyColorSplines = {
            [0] = {
               [0] = { 0, RH = { 0.333333333333333, 0.333333333333333 }, Flags = { Linear = true } },
               [1] = { 1, LH = { 0.666666666666667, 0.666666666666667 }, Flags = { Linear = true } }
            }
         },
         SplineColor = { Red = 0, Green = 204, Blue = 0 },
         NameSet = true,
      },
      CustomTool1LUTIn3 = LUTBezier {
         KeyColorSplines = {
            [0] = {
               [0] = { 0, RH = { 0.333333333333333, 0.333333333333333 }, Flags = { Linear = true } },
               [1] = { 1, LH = { 0.666666666666667, 0.666666666666667 }, Flags = { Linear = true } }
            }
         },
         SplineColor = { Red = 0, Green = 0, Blue = 204 },
         NameSet = true,
      },
      CustomTool1LUTIn4 = LUTBezier {
         KeyColorSplines = {
            [0] = {
               [0] = { 0, RH = { 0.333333333333333, 0.333333333333333 }, Flags = { Linear = true } },
               [1] = { 1, LH = { 0.666666666666667, 0.666666666666667 }, Flags = { Linear = true } }
            }
         },
         SplineColor = { Red = 204, Green = 204, Blue = 204 },
         NameSet = true,
      }
   }
}


Appreciated! :-)
But all things excellent are as difficult as they are rare
Offline

PourangKay

  • Posts: 13
  • Joined: Fri Dec 25, 2020 8:18 pm
  • Real Name: Pourang Kakouei

Re: Custom Tool - Serialization of the RGB Channel Operation

PostFri Oct 22, 2021 7:23 pm

My ultimate goal is to create 1 Custom Tool that takes these 4 formulas (Gamma, Offset, Lift, Gain), and links them to the Number Controls; in that way, I can represent Gamma, Offset, Lift, and Gain, all in one node.

Here are the formulas:
Gamma: (C1 ^ (1/N1) )
Offset: (C1 + N2)
Lift: (C1*(1-n3 )+n3)
Gain: ( c1*N4)

The RGB Channel in Custom Tool accepts only 1 Formula per channel, so I'm not sure how to link them.
But all things excellent are as difficult as they are rare
Offline
User avatar

Bryan Ray

  • Posts: 2051
  • Joined: Mon Nov 28, 2016 5:32 am
  • Location: Los Angeles, CA, USA

Re: Custom Tool - Serialization of the RGB Channel Operation

PostFri Oct 22, 2021 11:49 pm

Well, as I said, it'll follow PEMDAS, and I like to start with whatever will evaluate last. So since you want Gain to happen at the end, we'll start there:
n4 * c1

The operation you want before that is Lift, so we'll sub that in for the channel value (c1):
n4 * (c1*(1-n3)+n3)

And then Offset:
n4 * ((c1+n2)*(1-n3)+n3))

And finally Gamma:
n4*(((c1^(1/n1))+n2)*(1-n3)+n3))

There's one unnecessary set of brackets, so it could simplify slightly to this:
n4*((c1^(1/n1)+n2)*(1-n3)+n3))
Bryan Ray
http://www.bryanray.name
http://www.musevfx.com
Offline

PourangKay

  • Posts: 13
  • Joined: Fri Dec 25, 2020 8:18 pm
  • Real Name: Pourang Kakouei

Re: Custom Tool - Serialization of the RGB Channel Operation

PostSat Oct 23, 2021 12:22 am

Bryan Ray wrote:Well, as I said, it'll follow PEMDAS, and I like to start with whatever will evaluate last. So since you want Gain to happen at the end, we'll start there:
n4 * c1

The operation you want before that is Lift, so we'll sub that in for the channel value (c1):
n4 * (c1*(1-n3)+n3)

And then Offset:
n4 * ((c1+n2)*(1-n3)+n3))

And finally Gamma:
n4*(((c1^(1/n1))+n2)*(1-n3)+n3))

There's one unnecessary set of brackets, so it could simplify slightly to this:
n4*((c1^(1/n1)+n2)*(1-n3)+n3))


Thank you, Bryan.
But all things excellent are as difficult as they are rare
Offline

Stuart MacKinnon

Blackmagic Design

  • Posts: 59
  • Joined: Fri Sep 09, 2016 7:10 am

Re: Custom Tool - Serialization of the RGB Channel Operation

PostSun Oct 24, 2021 2:29 am

Bryan Ray wrote:Well, as I said, it'll follow PEMDAS, and I like to start with whatever will evaluate last. So since you want Gain to happen at the end, we'll start there:
n4 * c1

The operation you want before that is Lift, so we'll sub that in for the channel value (c1):
n4 * (c1*(1-n3)+n3)

And then Offset:
n4 * ((c1+n2)*(1-n3)+n3))

And finally Gamma:
n4*(((c1^(1/n1))+n2)*(1-n3)+n3))

There's one unnecessary set of brackets, so it could simplify slightly to this:
n4*((c1^(1/n1)+n2)*(1-n3)+n3))

The way Fusion's BC, CG, CC etc. do Lift and Gain, they're almost like a single combined operation, so that Lift and Gain define where 0.0 and 1.0 get scaled to. eg. if you have a simple 0..1 gradient, Lift = 0.5 and Gain = 1.5 would give you a 0.5..1.5 gradient. The formula above with Lift = 0.5 and Gain = 1.5 would turn a 0..1 gradient into 0.75..1.5 gradient because Lift gets scaled by Gain.

If you'd prefer the BC/CG/CC way, that simplifies Lift and Gain to just:
c1 * (n4 - n3) + n3

with offset:
(c1 + n2) * (n4 - n3) + n3

and with gamma:
((c1 ^ (1 / n1)) + n2) * (n4 - n3) + n3
Offline

PourangKay

  • Posts: 13
  • Joined: Fri Dec 25, 2020 8:18 pm
  • Real Name: Pourang Kakouei

Re: Custom Tool - Serialization of the RGB Channel Operation

PostSun Oct 24, 2021 12:40 pm

Stuart MacKinnon wrote:
Bryan Ray wrote:Well, as I said, it'll follow PEMDAS, and I like to start with whatever will evaluate last. So since you want Gain to happen at the end, we'll start there:
n4 * c1

The operation you want before that is Lift, so we'll sub that in for the channel value (c1):
n4 * (c1*(1-n3)+n3)

And then Offset:
n4 * ((c1+n2)*(1-n3)+n3))

And finally Gamma:
n4*(((c1^(1/n1))+n2)*(1-n3)+n3))

There's one unnecessary set of brackets, so it could simplify slightly to this:
n4*((c1^(1/n1)+n2)*(1-n3)+n3))


The way Fusion's BC, CG, CC etc. do Lift and Gain, they're almost like a single combined operation, so that Lift and Gain define where 0.0 and 1.0 get scaled to. eg. if you have a simple 0..1 gradient, Lift = 0.5 and Gain = 1.5 would give you a 0.5..1.5 gradient. The formula above with Lift = 0.5 and Gain = 1.5 would turn a 0..1 gradient into 0.75..1.5 gradient because Lift gets scaled by Gain.

If you'd prefer the BC/CG/CC way, that simplifies Lift and Gain to just:
c1 * (n4 - n3) + n3

with offset:
(c1 + n2) * (n4 - n3) + n3

and with gamma:
((c1 ^ (1 / n1)) + n2) * (n4 - n3) + n3


Thank you.
But all things excellent are as difficult as they are rare

Return to Fusion

Who is online

Users browsing this forum: Tomek Kosiorek and 11 guests