Working with variable frame rate

Discussions about the use of Realflow
Post Reply
VirtualFM
Posts: 6
Joined: Tue Jun 19, 2007 1:03 pm

Working with variable frame rate

Post by VirtualFM » Wed Jul 15, 2015 10:59 am

Hello guys!

I am dealing with a simulation problem that I don't really know how I should approach: I have an imported animation from an character that is moving in slow-motion. There is no problem figuring out the framerate I should simulate the liguid splashes (the character is jumping out of water), I tested it and the slow motion water looks allright.

The problem is that the character was animated already with a variable framerate. So it start's by moving in slow-motion and keeps at it for a while, then it accelerates it's motion to normal speed. Of course that when it accelerates to normal speed, the realflow particle simulation looks all wrong, becasue it's still calculating like if it was in slow-motion and I can't see a way to animate the base frame rate.

I looked into the Retime Simulation tool, that would be great to retime a simulation animated from scratch inside Realflow, but doesn't seem to help here.

Any suggestions? Can we animate the frame rate through scripting or something like that? What I need is that, for example:

- Simulation runs at 300 FPS from the beginning up to frame 600
- Simulation starts to accelerate from 600 to 700 (the character is returning to normal speed)
- After frame 700 simulation becomes normal speed at 30 FPS

Like I said, if this was a brand new simulation from scratch inside Realflow, it would be solved with the Retime simulation, probably, but in here I have an object I have to interact with and it is already doing it's own framerate change...

Thanks a lot for any insight.

VirtualFM
Posts: 6
Joined: Tue Jun 19, 2007 1:03 pm

Re: Working with variable frame rate

Post by VirtualFM » Thu Jul 16, 2015 11:57 am

Hi again! I don't know if no one answered because it was a stupid question or because it was a complicated one!

Well, anyway... some head banging and testing later I think I found the solution. I never used a script before, so it was some hours of head banging and experimenting to end up with half-dozen lines of code... but works!
Basically, I put some conditions that would change the framerate depending on which frame the simulation was. So in my test, up to frame 90 it was simulating at 220FPS, then I decrease the frame rate bit by bit from 90 to 105, and from 105 on would set to 30 FPS.

So, in Simulation Flow:

def onSimulationBegin():
scene.setFps(220)

def onSimulationFrame():
currentframe = scene.getCurrentFrame()
if ((currentframe >= 90) and (currentframe < 105)):
newfps = (big formula that looks like crap and should be simplified but is decreasing framerate based on current frame)
scene.setFps(int(newfps))
if (currentframe >= 105):
scene.setFps(30)

I guess the hardest part was to find the "scene.setFps()" command!

chrispan
Posts: 118
Joined: Fri Jan 28, 2011 2:23 pm

Re: Working with variable frame rate

Post by chrispan » Thu Jul 16, 2015 1:39 pm

nice solution.
next time tell your animator to do the speed ramping after the simulation part is done.
creepy workflow ;)

VirtualFM
Posts: 6
Joined: Tue Jun 19, 2007 1:03 pm

Re: Working with variable frame rate

Post by VirtualFM » Thu Jul 16, 2015 5:30 pm

Tell me about it... It's obvious things were not thought in advance, unfortunately. The last guy coming to the production is the one trying to fix it, as always! :-)

Post Reply

Return to “Realflow”