Jump to: Board index » General » Fusion

Easy Way to On-Off things?

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

kalony

  • Posts: 46
  • Joined: Wed Apr 10, 2019 8:42 pm
  • Real Name: Thomas Baumgärtel

Easy Way to On-Off things?

PostTue May 11, 2021 8:20 am

Hey there,


I often use non-keyframed animations with fast noise, anim curves, shake and perturb modifier and so on...

but with what i always struggle is to have a randomized on-off action. Sure, i can blend in an effect and modify this with a perturb, but thats not on-of. there are a lot of values between 0 and 1.

Any suggestions? Maybe for an easy example. A white Background merged over a black background and i want the white one to show up non keyframed, randomized and always 0% or 100%

Thanks for any hints

Thomas
Online
User avatar

Bryan Ray

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

Re: Easy Way to On-Off things?

PostTue May 11, 2021 3:11 pm

A small expression combined with a modifier might give you what you need:

Code: Select all
{
   Tools = ordered() {
      RandomSwitch_2_1 = Dissolve {
         Transitions = {
            [0] = "DFTDissolve"
         },
         CtrlWZoom = false,
         NameSet = true,
         Inputs = {
            Mix = Input {
               Value = 0,
               Expression = ":t0=0; randomseed(RandomSeed); while t0<=time do off=random(MinimumOffTime,MaximumOffTime); on=random(MinimumOnTime,MaximumOnTime); t=time-t0; t0=t0+on+off; end; n=t0-on; if t>off then return 1; else return 0; end",
            },
            Comments = Input { Value = "Randomly switches the Mix control between 0 and 1. Adjust the frequency of switching using the Max and Min sliders. \r\n\r\nMuse Effects Elements Library, Glitch Tools Collection\r\nby Bryan Ray.\r\nwww.musevfx.com", },
            MinimumOffTime = Input { Expression = "controlPanel_timeStutter_1.MinOffTime", },
            MaximumOffTime = Input { Expression = "controlPanel_timeStutter_1.MaxOffTime", },
            MinimumOnTime = Input { Expression = "controlPanel_timeStutter_1.MinShuffleDuration", },
            MaximumOnTime = Input { Expression = "controlPanel_timeStutter_1.MaxShuffleDuration", },
            RandomSeed = Input {
               Value = 67,
               Expression = "controlPanel_timeStutter_1.RandomSeed+250",
            },
         },
         ViewInfo = OperatorInfo { Pos = { 0, 43.15 } },
         UserControls = ordered() {
            MinimumOffTime = {
               INP_MaxAllowed = 10000,
               INP_Integer = true,
               INPID_InputControl = "SliderControl",
               IC_ControlPage = 0,
               INP_MaxScale = 30,
               INP_Default = 3,
               INP_MinAllowed = 0,
               LINKID_DataType = "Number",
               LINKS_Name = "Minimum Off Time",
            },
            MaximumOffTime = {
               INP_MaxAllowed = 10000,
               INP_Integer = true,
               INPID_InputControl = "SliderControl",
               IC_ControlPage = 0,
               INP_MaxScale = 60,
               INP_Default = 10,
               INP_MinScale = 1,
               INP_MinAllowed = 0,
               LINKID_DataType = "Number",
               LINKS_Name = "Maximum Off Time",
            },
            MinimumOnTime = {
               INP_MaxAllowed = 10000,
               INP_Integer = true,
               INPID_InputControl = "SliderControl",
               IC_ControlPage = 0,
               INP_MaxScale = 30,
               INP_Default = 3,
               INP_MinAllowed = 0,
               LINKID_DataType = "Number",
               LINKS_Name = "Minimum On Time",
            },
            MaximumOnTime = {
               INP_MaxAllowed = 10000,
               INP_Integer = true,
               INPID_InputControl = "SliderControl",
               IC_ControlPage = 0,
               INP_MaxScale = 60,
               INP_Default = 10,
               INP_MinScale = 1,
               INP_MinAllowed = 0,
               LINKID_DataType = "Number",
               LINKS_Name = "Maximum On Time",
            },
            RandomSeed = {
               LINKID_DataType = "Number",
               LINKS_Name = "Random Seed",
               IC_ControlPage = 0,
               INPID_InputControl = "SliderControl",
               INP_Default = 0,
            }
         }
      }
   },
   ActiveTool = "RandomSwitch_2_1"
}


In this tool, Number In 2 will return 0 if the value of Number In 1 is less than 0, and it will return 1 if the value of Number In 1 is greater than 0. In this example, I've modified Number In 1 with a Perturb. You'd then connect whatever tool you want to control to the Number In 2 control with this expression:

CustomTool1.NumberIn2

Here's a more elaborate controller that switches randomly between 0 and 1 with control over the minimum and maximum length of time that the control can remain static:

Code: Select all
{
   Tools = ordered() {
      RandomSwitch1 = Dissolve {
         Transitions = {
            [0] = "DFTDissolve"
         },
         CtrlWZoom = false,
         NameSet = true,
         Inputs = {
            Mix = Input { Expression = ":t0=0; randomseed(RandomSeed); while t0<=time do off=random(MinimumOffTime,MaximumOffTime); on=random(MinimumOnTime,MaximumOnTime); t=time-t0; t0=t0+on+off; end; n=t0-on; if t>off then return 1; else return 0; end", },
            Comments = Input { Value = "Randomly switches the Mix control between 0 and 1. Adjust the frequency of switching using the Max and Min sliders. \r\n\r\nMuse Effects Elements Library, Glitch Tools Collection\r\nby Bryan Ray.\r\nwww.musevfx.com", },
            RandomSeed = Input { Value = 67, },
         },
         ViewInfo = OperatorInfo { Pos = { 564, 34.6364 } },
         UserControls = ordered() {
            MinimumOffTime = {
               INP_MaxAllowed = 10000,
               INP_Integer = true,
               INPID_InputControl = "SliderControl",
               IC_ControlPage = 0,
               INP_MaxScale = 30,
               INP_Default = 3,
               INP_MinAllowed = 0,
               LINKID_DataType = "Number",
               LINKS_Name = "Minimum Off Time",
            },
            MaximumOffTime = {
               INP_MaxAllowed = 10000,
               INP_Integer = true,
               INPID_InputControl = "SliderControl",
               IC_ControlPage = 0,
               INP_MaxScale = 60,
               INP_Default = 10,
               INP_MinScale = 1,
               INP_MinAllowed = 0,
               LINKID_DataType = "Number",
               LINKS_Name = "Maximum Off Time",
            },
            MinimumOnTime = {
               INP_MaxAllowed = 10000,
               INP_Integer = true,
               INPID_InputControl = "SliderControl",
               IC_ControlPage = 0,
               INP_MaxScale = 30,
               INP_Default = 3,
               INP_MinAllowed = 0,
               LINKID_DataType = "Number",
               LINKS_Name = "Minimum On Time",
            },
            MaximumOnTime = {
               INP_MaxAllowed = 10000,
               INP_Integer = true,
               INPID_InputControl = "SliderControl",
               IC_ControlPage = 0,
               INP_MaxScale = 60,
               INP_Default = 10,
               INP_MinScale = 1,
               INP_MinAllowed = 0,
               LINKID_DataType = "Number",
               LINKS_Name = "Maximum On Time",
            },
            RandomSeed = {
               LINKID_DataType = "Number",
               INP_Default = 0,
               IC_ControlPage = 0,
               INPID_InputControl = "SliderControl",
               LINKS_Name = "Random Seed",
            }
         }
      }
   },
   ActiveTool = "RandomSwitch1"
}


Save that as a .setting file in your Macros folder, and you'll be able to recall it at any time. It's a Dissolve tool, so you could plug images into the Background and Foreground inputs to switch between them, or you can connect to it with an expression as with the previous tool with this expression:

RandomSwitch1.Mix
Bryan Ray
http://www.bryanray.name
http://www.sidefx.com
Offline

kalony

  • Posts: 46
  • Joined: Wed Apr 10, 2019 8:42 pm
  • Real Name: Thomas Baumgärtel

Re: Easy Way to On-Off things?

PostTue May 11, 2021 4:10 pm

I dont know what to say...both work as you said and its awesome! So easy now and i have a lot of ideas where those two evil nodes will help me a lot!

Thanks so much!

Thomas

Return to Fusion

Who is online

Users browsing this forum: Bryan Ray and 30 guests