Jump to: Board index » General » Fusion

Expression to toggle opacity every nth frame

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

thefisher86

  • Posts: 1
  • Joined: Wed Dec 08, 2021 10:51 pm
  • Real Name: Aaron Fisher

Expression to toggle opacity every nth frame

PostWed Dec 08, 2021 11:02 pm

I have spent wayy too long trying to figure out the answer myself and I've gotten nowhere. I've been trying to better understand how the Simple Expression scripting works but have not been able to find a ton of resources outside the Scripting Guide for Fusion 8.

All I want to do is programmatically toggle back and forth between 2 clips based on the current frame. So V2 has opacity=1 for 10 frames, then the opacity moves to 0 for 10 frames so V1 is showing underneath. I know I can do this by cutting the clip myself but I need to do this often and across 20+ minutes of footage so manually would take forever.

So far I've figured out that I can get the current frame with
Code: Select all
time
but I can't seem to figure out how to set a variable in a simple expression within an if/then statement. Here's the pseudo-code for what I want to do:
Code: Select all
myFramesVar = 25;
myOpacityVar = 1;

If (time - myFramesVar < 0){
   myFramesVar = myFramesVar+ 25;
   If (myOpacityVar = 1){
      myOpacityVar = 0;
      Else{myOpacityVar = 1;
}

So a couple things about my pseudo-code. I'm pretty sure this IS NOT the proper formatting to be using in Resolve/LUA. However I'm new to LUA and Resolve so I'm pretty sure I just need to know how to "say" this in the right formatting.

If the above code doesn't work what I'm really doing is asking "If the current frame - 25 is < 0 then add 25 to myFramesVar and toggle the Opacity to 0 if it's currrently 1 or 1 if it's currently 0.

Expectation is that every 25 frames the opacity toggles itself and now I have a reusable method to strobe a clip above another.

Thank you for any help anyone can provide.
Offline

xunile

  • Posts: 3075
  • Joined: Mon Apr 23, 2018 5:21 am
  • Real Name: Eric Eisenmann

Re: Expression to toggle opacity every nth frame

PostThu Dec 09, 2021 4:38 am

This is the code I used for a 30 fps timeline to toggle every 30 frames between two tracks. I used a Dissolve node and used it for the expression of the Background/Foreground parameter.

Code: Select all
iif(time % 60 < 30,0,1)
Attachments
2021-12-08 (3).png
2021-12-08 (3).png (967.78 KiB) Viewed 505 times
2021-12-08 (4).jpg
2021-12-08 (4).jpg (214.19 KiB) Viewed 505 times
Win 10 Home | Intel i7 - 10700f 64 GB 1 TB GB SSD 2 TB SSD
RTX-3060 12 GB | Resolve Studio 18.6.6| Fusion Studio 18.6.6

Win 10 Home | Intel Core I7-7700HQ 32 GB 1 TB NVME SSD 1 TB SATA SSD
GTX-1060-6GB | Resolve 17.4.6

Return to Fusion

Who is online

Users browsing this forum: No registered users and 30 guests