Jump to: Board index » General » Fusion

Expressions and key framing

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

sackboydad

  • Posts: 112
  • Joined: Sat Mar 21, 2020 6:36 pm
  • Real Name: Stacy Rothwell

Expressions and key framing

PostThu Apr 02, 2020 12:53 am

Hi

Making the transition from AE to Resolve/Fusion. Have, what I'm sure is a very simple question for a lot of you... but it's just eluding me at the moment.

I have a rectangle that's being used to mask a background (to make a transparent color for text to sit on top).
The rectangle shape needs to animate in. It does so by simply changing its height to something small to make it appear to be a thin line. When the thin line comes onscreen, the height keyframe changes to a certain value to "open" the box up.

Yes, I can easily just copy and paste the fusion clip and modify a couple keyframes to change to the desired height, but I've turned this into a Edit/title template so it's easy for other people to make these titles. They aren't going to know what to do modifying keyframes. So I thought of using expressions.

On paper, it seems easy. Make a "null" rectangle shape, make its height parameter visible in the title template, then have the "real" rectangle just look at the null on keyframe 2 and 3. This way, the height value I want is easy for anyone to dial in on the title template.

However, it appears I can't have individual keyframes with their own expressions. Is there any way to do what I want? Basically just having certain keyframes look elsewhere for the value to use?
Offline
User avatar

Bryan Ray

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

Re: Expressions and key framing

PostThu Apr 02, 2020 2:28 pm

You can add sliders to a node using the Edit Controls dialog. Right-click on the tool and choose Edit Controls... Or you can just use a CustomTool's sliders to hold the animation. Set the keyframes on one slider and use a second one as your exposed control slider.

In your Rectangle, use an Expression to multiply the two sliders together. Here's an example:

Code: Select all
{
   Tools = ordered() {
      Rectangle1 = RectangleMask {
         CtrlWZoom = false,
         Inputs = {
            Filter = Input { Value = FuID { "Fast Gaussian" }, },
            MaskWidth = Input { Value = 1920, },
            MaskHeight = Input { Value = 1080, },
            PixelAspect = Input { Value = { 1, 1 }, },
            ClippingMode = Input { Value = FuID { "None" }, },
            Width = Input { Value = 1, },
            Height = Input {
               Value = 0,
               Expression = "Animation*HeightControl",
            },
            Animation = Input {
               SourceOp = "Rectangle1Animation",
               Source = "Value",
            },
            HeightControl = Input { Value = 0.504, },
         },
         ViewInfo = OperatorInfo { Pos = { 486, 85.5454 } },
         UserControls = ordered() {
            Animation = {
               LINKS_Name = "Animation",
               LINKID_DataType = "Number",
               INPID_InputControl = "SliderControl",
               INP_Integer = false,
               INP_MinScale = 0,
               INP_MaxScale = 1,
            },
            HeightControl = {
               LINKS_Name = "Height Control",
               LINKID_DataType = "Number",
               INPID_InputControl = "SliderControl",
               INP_Integer = false,
               INP_MinScale = 0,
               INP_MaxScale = 1,
            }
         }
      },
      Rectangle1Animation = BezierSpline {
         SplineColor = { Red = 8, Green = 231, Blue = 163 },
         NameSet = true,
         KeyFrames = {
            [0] = { 0, RH = { 7.33333333333333, 0 }, Flags = { Linear = true } },
            [22] = { 1, LH = { 10.6, 1.392 }, RH = { 24.0221126780209, 0.930467704404897 } },
            [26] = { 1, LH = { 24.6666666666667, 1 } }
         }
      }
   },
   ActiveTool = "Rectangle1"
}


The controls are on the added User tab.
Bryan Ray
http://www.bryanray.name
http://www.sidefx.com
Offline

sackboydad

  • Posts: 112
  • Joined: Sat Mar 21, 2020 6:36 pm
  • Real Name: Stacy Rothwell

Re: Expressions and key framing

PostFri Apr 03, 2020 1:27 pm

Thank you. I'll take a look at this... of course, trying to figure this out, a new fire that has to be put out RIGHT NOW just happened. I do appreciate the response.

Stacy
Offline

krivanek.jirka

  • Posts: 6
  • Joined: Tue Sep 06, 2022 8:48 am
  • Real Name: Jiri Krivanek

Re: Expressions and key framing

PostTue Sep 06, 2022 9:03 am

Hello, it is probably too late in this thread, but I will try my chances.

Bryan Ray, where do you put that code you mentioned above?

I am total newbie to scripting of Fusion. On the other hand, I am a programmer. Although Lua is new for me too, it is just another programming language, so I can easily learn it. What is a problem to me is the leak of documentation showing how to integrate scripts with the Fusion (I am actually using it only from DaVinci Resolve, never standalone).

Expressions are just a single line, not suitable for writing complex code, including functions, variables, ...

I also tried to put it to the "Start Render Scripts" but it does not seem to work.

My goal is to create a reusable template which contains some script to arrange things which I am failing to do without scripting.

In my case, I need to set keyframes to the parametrised (user control) times relative to the start and end of the clip.

Also I am still trying to figure out how to do this without scripting at all.
Offline

carbonat

  • Posts: 2
  • Joined: Sat Nov 26, 2022 9:14 am
  • Real Name: Joan Lluch

Re: Expressions and key framing

PostWed May 03, 2023 5:43 pm

Bryan Ray wrote:You can add sliders to a node using the Edit Controls dialog. Right-click on the tool and choose Edit Controls... Or you can just use a CustomTool's sliders to hold the animation. Set the keyframes on one slider and use a second one as your exposed control slider.

In your Rectangle, use an Expression to multiply the two sliders together. Here's an example:

(code)

The controls are on the added User tab.

I've been looking for such functionality for some time. Thank you very much. Extending on this idea you can do really cool templates. That's genius
Offline
User avatar

Bryan Ray

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

Re: Expressions and key framing

PostWed May 03, 2023 9:54 pm

krivanek.jirka wrote:Bryan Ray, where do you put that code you mentioned above?


Wow, didn't see that question for a few months! Copy and paste it into the nodes view—it's just a description of the nodes and will reconstruct them in your Fusion. I'm sure you've figured it out by now, of course! :lol:
Bryan Ray
http://www.bryanray.name
http://www.sidefx.com

Return to Fusion

Who is online

Users browsing this forum: No registered users and 63 guests