Expression to change a value in frame intervals

Get answers to your questions about color grading, editing and finishing with DaVinci Resolve.
  • Author
  • Message
Offline

Roland_Thebard

  • Posts: 4
  • Joined: Wed Aug 04, 2021 12:19 am
  • Real Name: matthew s fowler

Expression to change a value in frame intervals

PostWed Aug 04, 2021 3:51 am

HI!

i'm sure this must have been asked before but i searched and could not find anything about it. i might not be using the correct terms as i am very new to resolve/fusion and video editing in general.

what i want to be able to do is basically make neon light turn on for x amount of frames then turn off for x amount and repeat. i know i can do this by manually key framing the merge blend, and copy and pasting in the splines page can speed that up as well, but, i thought maybe an expression could speed things up.

like something about time changing the blend to number value 1 then switch to number value 2 after the right amount of frames then it goes back to num 1 etc. any help to this newbie would be much appreciated!
Offline

Andy Mees

  • Posts: 3259
  • Joined: Wed Aug 22, 2012 7:48 am

Re: Expression to change a value in frame intervals

PostWed Aug 04, 2021 9:49 am

Try setting Blend to 'Modify With > Perturb' ... page 211 in the DaVinci-Resolve-17-Fusion-Visual-Effects.pdf
Let's have a return to the glory days, when press releases for new versions included text like "...with over 300 new features and improvements that professional editors and colorists have asked for."
Offline

Sander de Regt

  • Posts: 3588
  • Joined: Thu Nov 13, 2014 10:09 pm

Re: Expression to change a value in frame intervals

PostWed Aug 04, 2021 12:30 pm

You can also use an expression with a modulo component, but my math is terrible, so I don't know how that works. In the spline editor you can also set up you keyframes once and then instead of copy/pasting just set the spline to loop. This way you only have to adjust two to three keyframes and it will ripple through your whole animation.
Sander de Regt

ShadowMaker SdR
The Netherlands
Offline
User avatar

TheBloke

  • Posts: 1905
  • Joined: Sat Nov 02, 2019 11:49 pm
  • Location: UK
  • Real Name: Tom Jobbins

Re: Expression to change a value in frame intervals

PostWed Aug 04, 2021 1:42 pm

Here's an example expression using the modulo method as Sander explained:
Code: Select all
iif(time % 10 == 0, 1, 0)
That will set the field to 1 if the current frame number is divisible exactly by 10 (including frame 0), and 0 if it's not.

So if this expression was added to a Merge Blend field, the merge foreground will display on frames 0, 10, 20, 30, etc, and not on any of the others. Change the '10' in the expression to display after a different number of frames.

Here's a trivial example composition demonstrating that:
Code: Select all
{
   Tools = ordered() {
      Merge1 = Merge {
         CtrlWZoom = false,
         Inputs = {
            Blend = Input { Expression = "iif(time % 10 == 0, 1, 0)", },
            Background = Input {
               SourceOp = "Background1",
               Source = "Output",
            },
            Foreground = Input {
               SourceOp = "Text1",
               Source = "Output",
            },
            PerformDepthMerge = Input { Value = 0, },
         },
         ViewInfo = OperatorInfo { Pos = { 1252.67, 212.212 } },
      },
      Background1 = Background {
         Inputs = {
            Width = Input { Value = 1920, },
            Height = Input { Value = 1080, },
            ["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
         },
         ViewInfo = OperatorInfo { Pos = { 1142.67, 212.212 } },
      },
      Text1 = TextPlus {
         Inputs = {
            Width = Input { Value = 1920, },
            Height = Input { Value = 1080, },
            ["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
            StyledText = Input { Value = "Example", },
            Font = Input { Value = "Open Sans", },
            Style = Input { Value = "Bold", },
            VerticalJustificationNew = Input { Value = 3, },
            HorizontalJustificationNew = Input { Value = 3, },
            ManualFontKerningPlacement = Input {
               Value = StyledText {
                  Array = {
                  },
                  Value = ""
               },
            },
         },
         ViewInfo = OperatorInfo { Pos = { 1210, 129.182 } },
      }
   }
}
Resolve Studio 17.4.3 and Fusion Studio 17.4.3 on macOS 11.6.1

Hackintosh:: X299, Intel i9-10980XE, 128GB DDR4, AMD 6900XT 16GB
Monitors: 1 x 3840x2160 & 3 x 1920x1200
Disk: 2TB NVMe + 4TB RAID0 NVMe; NAS: 36TB RAID6
BMD Speed Editor
Offline

Roland_Thebard

  • Posts: 4
  • Joined: Wed Aug 04, 2021 12:19 am
  • Real Name: matthew s fowler

Re: Expression to change a value in frame intervals

PostWed Aug 04, 2021 5:38 pm

Andy Mees wrote:Try setting Blend to 'Modify With > Perturb' ... page 211 in the DaVinci-Resolve-17-Fusion-Visual-Effects.pdf


that will make it a random value giving it a more candle/flame like effect. i want it to switch on and off at set intervals like in the case i was working on going from .25 blend on the merge from fram 0-19 then immediately switch to 1 at frame 20 and and hold there till 39 then back to .25, and repeat. unless there is a way to control the perturb i haven't learned!
Offline

Roland_Thebard

  • Posts: 4
  • Joined: Wed Aug 04, 2021 12:19 am
  • Real Name: matthew s fowler

Re: Expression to change a value in frame intervals

PostWed Aug 04, 2021 5:42 pm

Sander de Regt wrote:You can also use an expression with a modulo component, but my math is terrible, so I don't know how that works. In the spline editor you can also set up you keyframes once and then instead of copy/pasting just set the spline to loop. This way you only have to adjust two to three keyframes and it will ripple through your whole animation.



you can do that O.o. i will try it! that would do it!
Offline

Roland_Thebard

  • Posts: 4
  • Joined: Wed Aug 04, 2021 12:19 am
  • Real Name: matthew s fowler

Re: Expression to change a value in frame intervals

PostWed Aug 04, 2021 5:42 pm

TheBloke wrote:Here's an example expression using the modulo method as Sander explained:
Code: Select all
iif(time % 10 == 0, 1, 0)
That will set the field to 1 if the current frame number is divisible exactly by 10 (including frame 0), and 0 if it's not.

So if this expression was added to a Merge Blend field, the merge foreground will display on frames 0, 10, 20, 30, etc, and not on any of the others. Change the '10' in the expression to display after a different number of frames.

Here's a trivial example composition demonstrating that:
Code: Select all
{
   Tools = ordered() {
      Merge1 = Merge {
         CtrlWZoom = false,
         Inputs = {
            Blend = Input { Expression = "iif(time % 10 == 0, 1, 0)", },
            Background = Input {
               SourceOp = "Background1",
               Source = "Output",
            },
            Foreground = Input {
               SourceOp = "Text1",
               Source = "Output",
            },
            PerformDepthMerge = Input { Value = 0, },
         },
         ViewInfo = OperatorInfo { Pos = { 1252.67, 212.212 } },
      },
      Background1 = Background {
         Inputs = {
            Width = Input { Value = 1920, },
            Height = Input { Value = 1080, },
            ["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
         },
         ViewInfo = OperatorInfo { Pos = { 1142.67, 212.212 } },
      },
      Text1 = TextPlus {
         Inputs = {
            Width = Input { Value = 1920, },
            Height = Input { Value = 1080, },
            ["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
            StyledText = Input { Value = "Example", },
            Font = Input { Value = "Open Sans", },
            Style = Input { Value = "Bold", },
            VerticalJustificationNew = Input { Value = 3, },
            HorizontalJustificationNew = Input { Value = 3, },
            ManualFontKerningPlacement = Input {
               Value = StyledText {
                  Array = {
                  },
                  Value = ""
               },
            },
         },
         ViewInfo = OperatorInfo { Pos = { 1210, 129.182 } },
      }
   }
}


i knew this had to exist! thank you so much!

Return to DaVinci Resolve

Who is online

Users browsing this forum: panos_mts, Stephen Swaney, wfolta and 244 guests