Jump to: Board index » General » Fusion

Quick way to mirror an animation in reverse

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

ResolveNoob

  • Posts: 85
  • Joined: Wed Jul 31, 2019 1:42 pm
  • Real Name: Tumelo Mogale

Quick way to mirror an animation in reverse

PostThu May 18, 2023 9:44 am

Not sure if this has been discussed here before but I think I just found a single node, keyframe free and dynamic way to mirror an animation in reverse as a way to animate out.

How I did it was using a time stretcher node and enabling an expression on source time. Then I used the expression:

iif(time< comp.RenderEnd/2, time, comp.RenderEnd - time)

The expression makes the composition run forwards for the first half of the playback and reverse for the second half of the playback.

I've seen other people achieve the same thing by using a time speed node set to reverse and then a dissolve node to switch between the forwards playback and the reversed playback. This is a single node alternative for that.

Just felt excited to share. Hope this helps someone.
Offline

Sander de Regt

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

Re: Quick way to mirror an animation in reverse

PostThu May 18, 2023 10:19 am

This is definitely a good trick. I can only think of one downside: AFAIK expressions aren't cached, because Fusion can't tell in advance what the expression will do. So animating with keyframes or modifiers is usually slightly more efficient. But neat trick nonetheless!
Sander de Regt

ShadowMaker SdR
The Netherlands
Offline

ResolveNoob

  • Posts: 85
  • Joined: Wed Jul 31, 2019 1:42 pm
  • Real Name: Tumelo Mogale

Re: Quick way to mirror an animation in reverse

PostThu May 18, 2023 4:54 pm

Sander de Regt wrote:This is definitely a good trick. I can only think of one downside: AFAIK expressions aren't cached, because Fusion can't tell in advance what the expression will do. So animating with keyframes or modifiers is usually slightly more efficient. But neat trick nonetheless!


Thanks Sander. I understand what you mean.

I guess there are pros and cons for both methods and one should make a selection based on the application. If, for example, you're doing a text graphic that you will repeat and vary the duration based on the amount of text, an expression based approach can save you a lot of time in the end.
Offline

Sander de Regt

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

Re: Quick way to mirror an animation in reverse

PostThu May 18, 2023 6:20 pm

For cases like your text example both the animcurves and keystretcher modifiers are also a good choice.
The keyframe stretcher will allow you to keep the in and out animation the same while stretching the part inbetween (the text)
Sander de Regt

ShadowMaker SdR
The Netherlands
Offline

ResolveNoob

  • Posts: 85
  • Joined: Wed Jul 31, 2019 1:42 pm
  • Real Name: Tumelo Mogale

Re: Quick way to mirror an animation in reverse

PostFri May 19, 2023 1:51 am

Sander de Regt wrote:For cases like your text example both the animcurves and keystretcher modifiers are also a good choice.
The keyframe stretcher will allow you to keep the in and out animation the same while stretching the part inbetween (the text)


The keystretcher mod (and the keyframe stretcher) is a strong contender. There are perhaps 2 issues worth noting with that.

1. It's not a true mirror. If you are trying to mirror a complex text animation with several different keyframes from different nodes, you will still have to repeat those keyframes in reverse... which is what we want to avoid.
2. I have found myself breaking the keyframe stretcher sometimes. It happens when I move the fusion clip around in the edit page and the frame numbers change. It's also a problem with my original expression but I have since updated it to cover that case as well.

Can anim curves be used to reverse an animation? That would be interesting. How would I go about that?
Offline

Hendrik Proosa

  • Posts: 3015
  • Joined: Wed Aug 22, 2012 6:53 am
  • Location: Estonia

Re: Quick way to mirror an animation in reverse

PostFri May 19, 2023 6:42 am

Sander de Regt wrote:AFAIK expressions aren't cached, because Fusion can't tell in advance what the expression will do.

Expression doesn’t need to be cached, expression result is what determines whether cache result is still valid or not. Lets say frame X is in cache. When hitting frame Y, if that frame produces equal hash (expression result being part of its calculation), it means that frame X cache can be pulled as they are the same thing. Or doesn’t Fusion’s caching system do these comparisons?
I do stuff.
Offline

Sander de Regt

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

Re: Quick way to mirror an animation in reverse

PostFri May 19, 2023 10:41 am

As far as I know - but this info might be outdated - Fusion always evaluates the expression on every frame - which means it renders that frame - so there's nothing to compare it to.
Sander de Regt

ShadowMaker SdR
The Netherlands
Offline

Sander de Regt

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

Re: Quick way to mirror an animation in reverse

PostFri May 19, 2023 10:50 am

If you are trying to mirror a complex text animation with several different keyframes from different nodes, you will still have to repeat those keyframes in reverse... which is what we want to avoid.

You're absolutely right, but personally I usally don't actually mirror my animations, but build on them so they do the reverse but in a slightly adapted way. So for lower thirds etc the keyframe stretcher works better for me personally. But like I said: your way is a very good way to do this and pretty elegant in its simplicity.
Sander de Regt

ShadowMaker SdR
The Netherlands
Offline

Hendrik Proosa

  • Posts: 3015
  • Joined: Wed Aug 22, 2012 6:53 am
  • Location: Estonia

Re: Quick way to mirror an animation in reverse

PostFri May 19, 2023 2:07 pm

Sander de Regt wrote:As far as I know - but this info might be outdated - Fusion always evaluates the expression on every frame - which means it renders that frame - so there's nothing to compare it to.

Evaluation of frame hash in a lot faster than render, so if that hash matches already existing frame (any frame) in cache that can be pulled. If it doesn’t work like this it is pretty inefficient.
I do stuff.
Offline

Sander de Regt

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

Re: Quick way to mirror an animation in reverse

PostFri May 19, 2023 2:14 pm

Since you're starting to throw around technical terms now, it's clear that I am out of my depth in discussing this. I'm going to step away from this part of the conversation now, since you obviously know more about this stuff than I do.
Sander de Regt

ShadowMaker SdR
The Netherlands
Offline

birdseye

  • Posts: 347
  • Joined: Fri Jun 12, 2020 2:36 pm
  • Real Name: Iain Fisher

Re: Quick way to mirror an animation in reverse

PostFri May 19, 2023 4:34 pm

Can anim curves be used to reverse an animation? That would be interesting. How would I go about that?


I'm wondering why you wouldn't just stick a TimeStretcher after any group of nodes you want to mirror, keyframe the first and last frame of the animation's duration, open the Spline Graph, drag select the keyframes you want to repeat and hit Ping Pong. You can then use the resulting graph to judge your new render length at the number of repeats you desire and the whole lot will play forwards then backwards again and again. You can move the keyframes around in the spline editor and the forward reverse will persist although you may end up with fractional frames unless you take care. Sorry if your question was about something more complicated than that but that's what I inferred from your question.
Offline

Hendrik Proosa

  • Posts: 3015
  • Joined: Wed Aug 22, 2012 6:53 am
  • Location: Estonia

Re: Quick way to mirror an animation in reverse

PostSun May 21, 2023 7:34 pm

Sander de Regt wrote:Since you're starting to throw around technical terms now, it's clear that I am out of my depth in discussing this. I'm going to step away from this part of the conversation now, since you obviously know more about this stuff than I do.

It’s off topic but maybe of interest so I’ll explain a bit about what I mean. Each frame is produced from a limited set of parameters. These include the current context (view, proxy setting etc), all knob values which change the node result, and node inputs. All these can be compounded together to create a value (hash) that describes this unique combination. The hash of node is used as part of hash of every node which has it connected as input. This cascading hashing uniquely defines a render result without need to render. Each cached frame should include the hash of last node and check for whether frame exists in cache is done by checking the hashes. If they match, result is also the same (if it doesn’t work, some changing params are not properly accounted for or system is not deterministic). Expressions are evaluated to their final values before render and these final values are what get hashed together. So if expression evaluates to same result, rendered frame also matches.

For loaders, match is in part determined by file path. This is also the reason why for read inputs cache must be explicitly invalidated when file is overwritten with new content unless there is a check into file metadata, like modification time etc. Matching the actual content isn’t feasible because that would mean duplicating the whole frame somewhere and doing a time-consuming pixel by pixel matching test which is a lot slower than just reading it again.
I do stuff.
Offline

ResolveNoob

  • Posts: 85
  • Joined: Wed Jul 31, 2019 1:42 pm
  • Real Name: Tumelo Mogale

Re: Quick way to mirror an animation in reverse

PostFri May 26, 2023 2:40 am

birdseye wrote:
Can anim curves be used to reverse an animation? That would be interesting. How would I go about that?


I'm wondering why you wouldn't just stick a TimeStretcher after any group of nodes you want to mirror, keyframe the first and last frame of the animation's duration, open the Spline Graph, drag select the keyframes you want to repeat and hit Ping Pong. You can then use the resulting graph to judge your new render length at the number of repeats you desire and the whole lot will play forwards then backwards again and again. You can move the keyframes around in the spline editor and the forward reverse will persist although you may end up with fractional frames unless you take care. Sorry if your question was about something more complicated than that but that's what I inferred from your question.


This actually is a decent solution as well. I tried it and there are 2 notes to report back.
1. The fractional frames. Since the count is in decimals between keyframes, you get motion trails. This is however, easily rectified if you change the interpolation mode to nearest.
2. The ping pong works the first time you do it and if you're only mirroring once, that's OK. If you hope to reuse the animation or adjust the length of your clip in the edit page, you will then have to go back to fusion and adjust the keyframes.
This method requires a bit more manual intervention than the expression which pretty much takes all the thinking out of it.
Offline

birdseye

  • Posts: 347
  • Joined: Fri Jun 12, 2020 2:36 pm
  • Real Name: Iain Fisher

Re: Quick way to mirror an animation in reverse

PostFri May 26, 2023 1:24 pm

Maybe fractional frames was the wrong description, uneven playback would have been better, either way that's what you are likely to get if your new fps is lower and isn't a factor of your output/timeline fps.
I see you are using Resolve so I guess regardless of what frame rate Fusion exports, the edit timeline will dictate how it produces the number of FPS it needs out of what Fusion feeds to it.
There are a few tools in Reactor that deal with retiming that may interest you, I don't know how compatable they are when used in Resolve Fusion but some other posters seem to prefer them to the standard TimeSpeed and TimeStretcher nodes.

Return to Fusion

Who is online

Users browsing this forum: Majestic-12 [Bot] and 32 guests