Jump to: Board index » General » Fusion

Cyclically fade in and out

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

JeffreyWalther

  • Posts: 324
  • Joined: Sat Jan 30, 2016 12:41 pm

Cyclically fade in and out

PostWed Dec 16, 2020 11:17 pm

Hello,

I would like to have a background including a mask (i.e. a shape) cyclically fade in and out. But the whole thing without manually animated values. I just want to specify the pulse duration somehow and then it should run by itself.

What is the best way to implement this in Fusion?

Thank you.

Jeff
DaVinci Resolve Studio V18
Fusion V18
Windows 10 Pro, 64 GB RAM
AMD Ryzen 9 3900X (12x 3.8 GHz), MSI X570 Unify
GeForce RTX 4070 Super 12 GB
Offline
User avatar

Bryan Ray

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

Re: Cyclically fade in and out

PostWed Dec 16, 2020 11:58 pm

(cos((time*2*pi)/ [duration] ))/2+0.5

That expression will cycle endlessly from 1 - 0 - 1, with a full cycle taking however many frames you use for the duration value. Put it on the Blend of a Merge, or of a Boolean in Clear mode, or whatever you like.

The 2*pi part normalizes the cycle so that you can just use the desired duration in the denominator, and it will work. You could have it cycle 0 - 1 - 0 instead by inverting the expression:

1-((cos((time*2*pi)/ [duration] ))/2+0.5

For more options, you could install the Extended Wave Modifier Fuse, available from Reactor. (I thought there was a Wave Modifier that came with Fusion, but apparently it's vanished.) With that installed, right-click on the parameter you want to control, choose Modify With > ExtendedWave. Then switch over to the Modifiers view to adjust the parameters.
Bryan Ray
http://www.bryanray.name
http://www.sidefx.com
Offline

UserNoah

  • Posts: 461
  • Joined: Fri Oct 04, 2019 3:32 pm
  • Location: Germany
  • Real Name: Noah Hähnel

Re: Cyclically fade in and out

PostThu Dec 17, 2020 7:52 am

If you need to have a different kind of animation you could also animate the fade in and out manually and then use the Loop mode in the Spline Editor.
Offline

JeffreyWalther

  • Posts: 324
  • Joined: Sat Jan 30, 2016 12:41 pm

Re: Cyclically fade in and out

PostThu Dec 17, 2020 11:06 am

UserNoah wrote:If you need to have a different kind of animation you could also animate the fade in and out manually and then use the Loop mode in the Spline Editor.


Thank you! This was quite easy.

Bryan Ray wrote:(cos((time*2*pi)/ [duration] ))/2+0.5

That expression will cycle endlessly from 1 - 0 - 1, with a full cycle taking however many frames you use for the duration value. Put it on the Blend of a Merge, or of a Boolean in Clear mode, or whatever you like.

The 2*pi part normalizes the cycle so that you can just use the desired duration in the denominator, and it will work. You could have it cycle 0 - 1 - 0 instead by inverting the expression:

1-((cos((time*2*pi)/ [duration] ))/2+0.5

For more options, you could install the Extended Wave Modifier Fuse, available from Reactor. (I thought there was a Wave Modifier that came with Fusion, but apparently it's vanished.) With that installed, right-click on the parameter you want to control, choose Modify With > ExtendedWave. Then switch over to the Modifiers view to adjust the parameters.


Thank you, too. But I did not get it work as modifier on "Alpha".
But that is due to my lack of knowledge about expressions. My fault.
DaVinci Resolve Studio V18
Fusion V18
Windows 10 Pro, 64 GB RAM
AMD Ryzen 9 3900X (12x 3.8 GHz), MSI X570 Unify
GeForce RTX 4070 Super 12 GB
Offline
User avatar

Bryan Ray

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

Re: Cyclically fade in and out

PostThu Dec 17, 2020 3:40 pm

There wasn't quite enough information about what you were doing to say exactly what you should do. You could put the expression or animation on a Blend slider of a Merge, or you could use a ChannelBooleans in Clear mode and put it on the Blend slider of that. Or you could use a BrightnessContrast, put it on the Gain control, and tick Alpha in addition to the RGB switches. Or none of those might be appropriate if you're doing something that I haven't thought of.

Or it could be that you just don't know how to apply an expression to a control. To do that, right-click the control you want to put the expression on and choose "Expression." Or type a "=" sign in the value field and tap Enter, which will also open the Expression field.
Bryan Ray
http://www.bryanray.name
http://www.sidefx.com
Offline

JeffreyWalther

  • Posts: 324
  • Joined: Sat Jan 30, 2016 12:41 pm

Re: Cyclically fade in and out

PostFri Dec 18, 2020 9:39 am

Bryan Ray wrote:There wasn't quite enough information about what you were doing to say exactly what you should do. You could put the expression or animation on a Blend slider of a Merge, or you could use a ChannelBooleans in Clear mode and put it on the Blend slider of that. Or you could use a BrightnessContrast, put it on the Gain control, and tick Alpha in addition to the RGB switches. Or none of those might be appropriate if you're doing something that I haven't thought of.

Or it could be that you just don't know how to apply an expression to a control. To do that, right-click the control you want to put the expression on and choose "Expression." Or type a "=" sign in the value field and tap Enter, which will also open the Expression field.


Hello Bryan, I had it this way, but it has no effect on the Alpha value:
Alpha.JPG
Alpha.JPG (30.16 KiB) Viewed 896 times


With Channel Boolean (Clear mode) it did not work as well:
Alpha2.JPG
Alpha2.JPG (42.94 KiB) Viewed 891 times


The value does not change or background fades
DaVinci Resolve Studio V18
Fusion V18
Windows 10 Pro, 64 GB RAM
AMD Ryzen 9 3900X (12x 3.8 GHz), MSI X570 Unify
GeForce RTX 4070 Super 12 GB
Offline
User avatar

Bryan Ray

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

Re: Cyclically fade in and out

PostFri Dec 18, 2020 3:19 pm

Whoops! The square brackets were meant to indicate that that was something that should be replaced in its entirety. My bad; I didn't explain that.

Try (cos((time*2*pi)/5))/2+0.5

You should get a 5-frame cycle.

To take it a step beyond, what I sometimes do is add a User Control to the tool that holds the variable. Suppose I used the Edit Controls feature to the node some new sliders called Duration, Min and Max (the latter two for defining the highest and lowest values of the cycle). Then the expression would look like this:

((cos((time*2*pi)/Duration))/2+0.5)*(Max-Min)+Min

So for instance, if we want a cycle that goes from 0.2 to 0.75, we get the normalized cycle as originally demonstrated, then we need to compress it to the value range—going from 0.2 to 0.75 is a range of 0.55, which we get by subtracting our desired Minimum from the desired Maximum. The number is now cycling from 0.0 to 0.55. Then we add Min to shift it all to where we want it.

Here's an example (the new controls are on the User page):

Code: Select all
{
   Tools = ordered() {
      Background1 = Background {
         CtrlWZoom = false,
         Inputs = {
            Width = Input { Value = 1920, },
            Height = Input { Value = 1080, },
            ["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
            TopLeftRed = Input { Value = 0.638, },
         },
         ViewInfo = OperatorInfo { Pos = { 158.667, 44.9394 } },
      },
      BrightnessContrast1 = BrightnessContrast {
         Inputs = {
            Alpha = Input { Value = 1, },
            Gain = Input {
               Value = 0.0954915028125213,
               Expression = "((cos((time*2*pi)/Duration))/2+0.5)*(Max-Min)+Min ",
            },
            Input = Input {
               SourceOp = "Background1",
               Source = "Output",
            },
         },
         ViewInfo = OperatorInfo { Pos = { 277.333, 49.1818 } },
         UserControls = ordered() {
            Duration = {
               LINKS_Name = "Duration",
               LINKID_DataType = "Number",
               INPID_InputControl = "SliderControl",
               INP_Default = 10,
               INP_Integer = false,
               INP_MinScale = 0.100000001490116,
               INP_MaxScale = 60,
               INP_MinAllowed = 9.99999974737875e-06,
               INP_MaxAllowed = 1000000,
            },
            Min = {
               LINKS_Name = "Min",
               LINKID_DataType = "Number",
               INPID_InputControl = "SliderControl",
               INP_Default = 0,
               INP_Integer = false,
               INP_MinScale = 0,
               INP_MaxScale = 1,
               INP_MinAllowed = -1000000,
               INP_MaxAllowed = 1000000,
            },
            Max = {
               LINKS_Name = "Max",
               LINKID_DataType = "Number",
               INPID_InputControl = "SliderControl",
               INP_Default = 1,
               INP_Integer = false,
               INP_MinScale = 0,
               INP_MaxScale = 1,
               INP_MinAllowed = -1000000,
               INP_MaxAllowed = 1000000,
            }
         }
      }
   }
}


Oh, and one more thing: Putting the expression on Alpha alone in the Background tool probably wouldn't do what you want—it would only fade out that one channel, but RGB would remain. If you want the image to vanish entirely you'd also need to use an AlphaMultiply to multiply the RGB by A.
Last edited by Bryan Ray on Sat Dec 19, 2020 3:50 pm, edited 1 time in total.
Bryan Ray
http://www.bryanray.name
http://www.sidefx.com
Offline

JeffreyWalther

  • Posts: 324
  • Joined: Sat Jan 30, 2016 12:41 pm

Re: Cyclically fade in and out

PostSat Dec 19, 2020 11:00 am

Hello Bryan,

Thank you very much for the code snippet which works like a charme. :)

Jeff
DaVinci Resolve Studio V18
Fusion V18
Windows 10 Pro, 64 GB RAM
AMD Ryzen 9 3900X (12x 3.8 GHz), MSI X570 Unify
GeForce RTX 4070 Super 12 GB
Offline

movalex

  • Posts: 110
  • Joined: Wed Sep 27, 2017 2:35 pm
  • Real Name: Alexey Bogomolov

Re: Cyclically fade in and out

PostTue Dec 22, 2020 8:02 am

If you want some extravaganza, you can animate a ChannelBooleans Clear operation Blend with a probe modifier, connected to an animated black/white gradient. And I bet there's a hundred ways more to do that in Fusion. To me Bryan's approach seems to be the most flexible.

Code: Select all
{
   Tools = ordered() {
      animated_gradient = Background {
         NameSet = true,
         Inputs = {
            Width = Input { Value = 1920, },
            Height = Input { Value = 1080, },
            ["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
            Type = Input { Value = FuID { "Gradient" }, },
            End = Input { Value = { 0.25, 0.5 }, },
            Gradient = Input {
               Value = Gradient {
                  Colors = {
                     [0] = { 0, 0, 0, 1 },
                     [0.5] = { 1, 1, 1, 1 },
                     [1] = { 0, 0, 0, 1 }
                  }
               },
            },
            Offset = Input {
               Value = 15.24,
               Expression = "time/50",
            },
            Repeat = Input { Value = FuID { "Repeat" }, },
         },
         ViewInfo = OperatorInfo { Pos = { 482.667, 110.061 } },
      },
      red_BG = Background {
         NameSet = true,
         Inputs = {
            Width = Input { Value = 1920, },
            Height = Input { Value = 1080, },
            ["Gamut.SLogVersion"] = Input { Value = FuID { "SLog2" }, },
            TopLeftRed = Input { Value = 0.638, },
         },
         ViewInfo = OperatorInfo { Pos = { 482.667, 52.2121 } },
      },
      probe_driven_pulse = ChannelBoolean {
         NameSet = true,
         Inputs = {
            Blend = Input {
               SourceOp = "Probe1",
               Source = "Result",
            },
            Operation = Input { Value = 12, },
            Background = Input {
               SourceOp = "red_BG",
               Source = "Output",
            },
         },
         ViewInfo = OperatorInfo { Pos = { 702.667, 52.2121 } },
      },
      Probe1 = Probe {
         CtrlWZoom = false,
         Inputs = {
            ImageToProbe = Input {
               SourceOp = "animated_gradient",
               Source = "Output",
            },
            ProbeRectangle = Input { Value = 1, },
            Width = Input { Value = 0.001125, },
            Height = Input { Value = 0.518518518518518, },
         },
      }
   }
}
Offline
User avatar

Bryan Ray

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

Re: Cyclically fade in and out

PostTue Dec 22, 2020 4:09 pm

I really think the Wave Modifier is the simplest solution. But I love math!
Bryan Ray
http://www.bryanray.name
http://www.sidefx.com

Return to Fusion

Who is online

Users browsing this forum: No registered users and 55 guests