Welcome to WSL!

Make yourself at home, but before posting, please may I ask you to read the following topics.


Posting 101
Server space, screenshots, and you

Thank you!

PS. please pretty please:


Image

Euler Filter script

Idea ID:
11
Author:
Midgardsormr
Posted:
Wed Feb 05, 2020 12:28 pm
Rating:
Status:
New
Discussion Topic:
WSL-4124
User avatar
Midgardsormr
Fusionator
Posts: 1975
Joined: Wed Nov 26, 2014 8:04 pm
Answers: 19
Location: Los Angeles, CA, USA
Been thanked: 153 times
Contact:

Euler Filter script

#1

Post by Midgardsormr » Wed Feb 05, 2020 12:28 pm

As pointed out in viewtopic.php?f=16&t=3759&p=28927 , Fusion doesn't understand rotations beyond 360 degrees. We therefore wind up in a situation where rotating objects suddenly make a complete rotation, sometimes flipping back and forth repeatedly across the threshold, which creates quite a problem when motion blur is turned on.

For one or two objects, this is reasonably easy to fix, but if you have dozens, or hundreds, of 3d objects it can become prohibitive to address them all.

An Euler Filter script could detect incorrect rotational windup and repair it by adding or subtracting 360 from keyframes where adjacent keyframes are found to have differences close to 360.

https://en.wikipedia.org/wiki/Euler_filter
Last edited by Midgardsormr on Wed May 20, 2020 9:49 pm, edited 1 time in total.

User avatar
SirEdric
Fusionator
Posts: 2345
Joined: Tue Aug 05, 2014 10:04 am
Answers: 12
Real name: Eric Westphal
Been thanked: 50 times
Contact:

Re: Euler Filter script

#2

Post by SirEdric » Sat Feb 08, 2020 11:26 am

Since this happens in all sorts of scenarios related to importing/exporting 3D files
(heck....animate some 360+° rotation in Fusion, export as FBX, import again, and the same thing happens!)
10 thumbs up!

howiem
Posts: 34
Joined: Fri Jun 07, 2019 3:08 am
Been thanked: 6 times

Re: Euler Filter script

#3

Post by howiem » Tue Feb 18, 2020 2:31 am

Ha! Just hitting the ole' Euler discontinuity thing with my Houdini --> Fusion camera exporter thingy.

Seems there are two issues: wrapping at 360 degrees, and the axis-flipping thing that comes from decomposing matrices or quats.

Discontinuities:
If anyone can point me at some pseudo-code, that'd be extremely helpful; I've found lots of mentions of Euler filters but no actual procedure. It looks like it's a case of adding or subtracting 180 degrees from all the axes once you've noticed a bigger-than-something jump in the values.

Is it as simple as just "for each rot channel, if the channel's frame-to-frame delta exceeds some threshold value (say, 90 degrees), then add or subtract 180 according to the sign of the delta"?

I was coming up with an overly complicated algorithm trying to work out how the sign of the delta in x-rotation ought to affect the sign of the correction in the other two axes, and a system of flagging whether there had been a previous correction, but I'm wondering whether that's actually necessary. After all, if a discontinuity happens and you correct it for that frame, that'll effectively push the discontinuity on by one frame, where it'll get handled again in the same way.

So as long as your threshold is set appropriately so it doesn't get triggered by intended animation values, just doing a dumb "oh this axis has suddenly rotated by +178 deg so let's knock 180 off it" oughta work. No need to remember whether a correction is in place from frame to frame.

360 degree wrapping:
Same kinda deal, surely? No need to do any flaggy semaphory state stuff, just correct this frame and push the problem onto the next one.


Or is this approach naive? (I like to flip between naive and over-engineered as often as possible in any given working day)

User avatar
Midgardsormr
Fusionator
Posts: 1975
Joined: Wed Nov 26, 2014 8:04 pm
Answers: 19
Location: Los Angeles, CA, USA
Been thanked: 153 times
Contact:

Re: Euler Filter script

#4

Post by Midgardsormr » Tue Feb 18, 2020 7:00 am

Hmmm.... You're going to be doing a comparison between two points at every keyframe either way. And you're going to add a number to each offending point either way. I can't see where a point-by-point approach is going to be any slower than flag-and-correct.

I haven't encountered any actual algorithms, either. I haven't looked really hard, but a cursory search only turned up other people asking for one. Or descriptions of how to use a filter already included with software.

Added in 59 seconds:
Since it sounds like you're already thinking about it, do you want to go ahead and hit the "add" button up there in the original post to start a Dev topic?

howiem
Posts: 34
Joined: Fri Jun 07, 2019 3:08 am
Been thanked: 6 times

Re: Euler Filter script

#5

Post by howiem » Tue Feb 18, 2020 7:22 am

Yup. Point by point wins by simplicity for me.

I'm probably gonna incorporate filtering into my Houdini exporter rather than try getting my head round Lua, at least for now. I'll post it here once tidied; the Houdini exporter works fine but is sooo hacky, so childishly coded, it'd basically make me unemployable on sight

User avatar
Midgardsormr
Fusionator
Posts: 1975
Joined: Wed Nov 26, 2014 8:04 pm
Answers: 19
Location: Los Angeles, CA, USA
Been thanked: 153 times
Contact:

Re: Euler Filter script

#6

Post by Midgardsormr » Tue Feb 18, 2020 7:25 am

lol. I'm looking forward to seeing it! I handle Houdini-Fusion interface, too, so anything I can learn will be of benefit.

howiem
Posts: 34
Joined: Fri Jun 07, 2019 3:08 am
Been thanked: 6 times

Re: Euler Filter script

#7

Post by howiem » Fri Mar 20, 2020 4:13 am

I've updated my Houdini-Fusion script so it now handles
- Rotation wind-up
- Euler flipping (albeit crudely - it seems to work on my limited set of tests; it'd be could to have some test data that breaks it)
- Redundant keyframe culling

https://gist.github.com/howiemnet/9ab71 ... dfdbdf4385

The Euler flipping thing is one of those "bass-player skills" things, it seems; easy to get it working okayish but to do it properly is going to take a fair bit of effort. Interesting to note that the Euler Filter CHOP within Houdini asks for a rotation hint - a set of Euler axis rotations to use as a starting point for its filtering.

My current project has the camera rotating on all axes, but I'd imagine Euler filtering could be made a lot more reliable if you were able to tell it, say, "I need yaw and pitch but no roll". More work to be done on this at some point... but for now it's time to wash the hands and keep working while I can

User avatar
Midgardsormr
Fusionator
Posts: 1975
Joined: Wed Nov 26, 2014 8:04 pm
Answers: 19
Location: Los Angeles, CA, USA
Been thanked: 153 times
Contact:

Re: Euler Filter script

#8

Post by Midgardsormr » Tue May 19, 2020 7:21 am

So... How exactly does one change the Status? This one's In Progress, but the only thing I can update is the link to the dev topic.

User avatar
SecondMan
Site Admin
Posts: 4607
Joined: Thu Jul 31, 2014 5:31 pm
Answers: 28
Location: Vancouver, Canada
Been thanked: 138 times
Contact:

Re: Euler Filter script

#9

Post by SecondMan » Tue May 19, 2020 5:39 pm

Hm. I need to look into the code it seems - I always assumed that the author of an idea would be able to change its status... apparently not?

I can change it for you, but I won't so I can test this at some point if that's OK with you :)

User avatar
Midgardsormr
Fusionator
Posts: 1975
Joined: Wed Nov 26, 2014 8:04 pm
Answers: 19
Location: Los Angeles, CA, USA
Been thanked: 153 times
Contact:

Re: Euler Filter script

#10

Post by Midgardsormr » Wed May 20, 2020 7:07 am

Fine by me. Test at your leisure!

User avatar
SecondMan
Site Admin
Posts: 4607
Joined: Thu Jul 31, 2014 5:31 pm
Answers: 28
Location: Vancouver, Canada
Been thanked: 138 times
Contact:

Re: Euler Filter script

#11

Post by SecondMan » Wed May 20, 2020 8:32 pm

Can you change it now?

User avatar
Midgardsormr
Fusionator
Posts: 1975
Joined: Wed Nov 26, 2014 8:04 pm
Answers: 19
Location: Los Angeles, CA, USA
Been thanked: 153 times
Contact:

Re: Euler Filter script

#12

Post by Midgardsormr » Wed May 20, 2020 9:50 pm

No, there's no way to commit the change. The Idea pane isn't attached to the first post in the thread.

User avatar
SecondMan
Site Admin
Posts: 4607
Joined: Thu Jul 31, 2014 5:31 pm
Answers: 28
Location: Vancouver, Canada
Been thanked: 138 times
Contact:

Re: Euler Filter script

#13

Post by SecondMan » Wed May 20, 2020 10:39 pm

Not sure I understand - you shouldn't have to commit anything. It doesn't look like this, to you?

Image

User avatar
Midgardsormr
Fusionator
Posts: 1975
Joined: Wed Nov 26, 2014 8:04 pm
Answers: 19
Location: Los Angeles, CA, USA
Been thanked: 153 times
Contact:

Re: Euler Filter script

#14

Post by Midgardsormr » Thu May 21, 2020 6:52 am

Nope. I can choose the new status, but it doesn't update.

edit: I'm in Chrome, btw, if that makes a difference.