chrishayesmu / Blender-Spritesheet-Renderer

MIT License
16 stars 4 forks source link

Constant framerate for animations #1

Closed adamscoble closed 3 years ago

adamscoble commented 3 years ago

Hi there!

Apologies if this is the wrong place for this, but I was wondering whether you think it would be possible (or time consuming) to build a constant animation framerate atop your Spritesheet Renderer? So instead of rendering predefined/key frames in the animation, you can render out animations at x second intervals?

Thanks!

chrishayesmu commented 3 years ago

In theory that should be pretty straightforward. The addon already asks for the animation's frame rate, so it's simple enough to calculate that "render every 0.1 seconds" means rendering frames 1, 4, 7, etc.

That actually sounds like an idea I might be interested in, so I might go about adding it anyway, but is this something you'd find useful (if you're already using the addon) or that would make the addon worth using for you?

adamscoble commented 3 years ago

Hey, thanks for the reply!

More so the latter. Variable frame lengths are great (and usually more efficient - fewer frames) in most games, however I’m currently working on a game that requires deterministic reproduction of animations. So the plan is that every animation frame’s is measured in fixed-frame updates.

Another useful feature here would be guaranteeing the first and last frames. In a looping animation this wouldn’t be important, because the fixed time step should make the loop seamless. But in a one shot animation, you might want to guarantee the final frame, even if it’s out of the time step? Could look weird though, hmm.

On Sun, 14 Mar 2021 at 6:34 am, chrishayesmu @.***> wrote:

In theory that should be pretty straightforward. The addon already asks for the animation's frame rate, so it's simple enough to calculate that "render every 0.1 seconds" means rendering frames 1, 4, 7, etc.

That actually sounds like an idea I might be interested in, so I might go about adding it anyway, but is this something you'd find useful (if you're already using the addon) or that would make the addon worth using for you?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/chrishayesmu/Blender-Spritesheet-Renderer/issues/1#issuecomment-798773056, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA2MU7JZUG2PGUW7NDYVR7TTDOV2RANCNFSM4ZDMR5BQ .

adamscoble commented 3 years ago

Hey again! Hope you don't mind the follow up. Did you end up making any progress on implementing this yourself? And/or do you still have plans to?

chrishayesmu commented 3 years ago

Hey Adam, sorry for the delayed response. I should have mentioned, my wife and I just had a baby a couple of months ago, so things are pretty hectic over here.

I have been working on this a little, and thinking about the problem you mentioned with guaranteeing the final frame (the first is pretty much always guaranteed since it's a natural starting point). Honestly, the cleanest solution I've thought of is to just warn the user if their time step will miss the final frame. The other option would be to automatically choose the closest time step that does get the last frame (e.g. if you enter 0.1s, but it would have to be 0.12s, use that instead). As you mentioned, just appending the final frame regardless of time step is going to look weird.

Any thoughts?

chrishayesmu commented 3 years ago

Actually, the more I think about this, the more I'm unsure what problem is being solved. You mentioned variable frame lengths, but the current version of the addon doesn't have those; each frame is always 1 / fps seconds long, or if you're using frame skipping, (1 + frame_skip) / fps seconds long. That should be sufficient for determinism.

Can you clarify if I've misunderstood something?

adamscoble commented 3 years ago

Hey Chris, congrats on the baby!

And nope, it's entirely possible I've misunderstood something! I think you're absolutely right, it seems to be already setup for that, I think I misunderstood some of the settings. Sorry to have wasted your time! I'll have a play around with it and see how I go.

Thanks for the plugin, by the way. It apparently solves the exact issue I had, in a surprisingly sparse topic!

chrishayesmu commented 3 years ago

Glad it's cleared up! I'll have to publish a new release - the latest here is missing a number of bug fixes, as well as being able to specify a frame skip for animations. I'll try to do that in the next few hours and let you know.

adamscoble commented 3 years ago

Oh that's great! Yeah I'd love to know when it's updated, thanks Chris!

chrishayesmu commented 3 years ago

I've just published the latest version as v2.2.0. Please feel free to open more issues with questions, feedback, etc. As far as I know you're the first person to use this addon, so I'm sure there are some rough edges.

adamscoble commented 3 years ago

Will do. That's great, thanks Chris!

adamscoble commented 3 years ago

Hey Chris!

So playing around with the exporter, it looks like my original request kind of still applies. It doesn't seem to matter what we set the FPS to (15, 30, 60) the output spritesheet is always identical, and just seems to be each of the keyframes.

Wheras my expectation for setting the fps to 15 would be that it fast-forwards 1/15 seconds, renders a frame, moves forward that amount again and repeats, completely independent of the keyframes themselves.

Am I still misunderstanding something? Haha. Apologies if so!

chrishayesmu commented 3 years ago

The renderer goes frame by frame (not just keyframes, but interpolated frames also). It's the same effect as opening the timeline in Blender, stepping through each frame, and rendering them manually. (Actually it's literally the same as this because it uses the same APIs as the timeline view.) If you have keyframed data on every animation frame then it'll look like you said; otherwise you should see both types in the spritesheet.

chrishayesmu commented 3 years ago

Whoops, hit submit too soon.

Anyway the net effect is that there is no "frame rate" concept in the addon. Even when using Blender's timeline view, the frame rate listed there is only for playback in the viewport. Likewise, once the frames are exported, they only have whatever frame rate you assign to them.

adamscoble commented 3 years ago

Hmm interesting. We're currently trying it out with Mixamo animations, and it does look like maybe Mixamo is adding a keyframe every single frame. Thanks for the reply! Right now we're just exporting at 30fps and deleting every second frame for 15fps, hehe.

chrishayesmu commented 3 years ago

FYI the latest addon versions have a "frame skip" option, which has the same effect as deleting every second frame with the advantage that they never get rendered in the first place, so your render times would improve.

adamscoble commented 3 years ago

Oh, that's awesome, thanks very much! If I can figure out keeping the individual sprites instead of deleting that folder it'll save a ton of time! Haha.