Skip to content

aki-null/MotionFrame

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

62 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MotionFrame

MotionFrame is a Python tool designed to analyze flipbook images and generate motion vector textures for use with motion blend shaders.

The problem with flipbook textures is that the texture size becomes very large if you want smooth animation. The motion blend technique makes animation smoother with fewer frames by providing an extra motion vector texture.

Sample Renders

Fade Blend Motion Blend
Explosion Fade Explosion Motion
Smoke Fade Smoke Motion

Key Features

  • GUI Frontend
  • Cross-Platform:
    • Supports macOS, Windows, and likely Linux.
  • Skipped Frame Analysis:
    • Enhances motion analysis precision with high frame rate input.
    • Analyzes every input frame and accumulates skipped frames into each motion vector frame.
    • Ideal for animations with fast movements, which are challenging for image-based motion analysis.
  • Motion Vector Stagger Packing:
    • Motion vector textures use 2 channels, but this may not be optimal for some platforms.
    • Packing them into 4 channels reduces texture size by half and compresses well with formats like ASTC.
  • Color Atlas Packing
  • Motion Visualization
  • Free and Open Source

See the reference shader implementation (MIT) for shaders to render this.

Installation

Self Contained Binary

Releases

Setup

Windows

git clone https://github.com/aki-null/MotionFrame.git
cd MotionFrame
python -m venv .venv
source .venv/Scripts/activate
cd app
pip install -r requirements.txt
python3 MotionFrame.py

macOS

git clone https://github.com/aki-null/MotionFrame.git
cd MotionFrame
python -m venv .venv
source .venv/bin/activate
cd app
pip install -r requirements.txt
python3 MotionFrame.py

Usage

Main Window

  • Drag and drop image sequence file
    • Folder works too
    • The tool tries its best to determine how your image sequence file names are formatted
  • Configure options
    • Frame skips are important if your input frame count is not exactly the same as the desired output frames
    • The output motion vector quality improves if you can provide more input frames
  • Generate
    • The tabs on the right displays various output
    • Visualization tab shows how the tool interpreted the motion in each frame with arrows
  • Save to files
    • The output is in TGA
    • Color, motion vector, and JSON metadata are exported

License

GPL v3.0

MotionFrame
Copyright (C) 2024  Akihiro Noguchi

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <https://www.gnu.org/licenses/>.
  • Downloading this tool and using the generated texture for your game doesn't contaminate your software with GPL v3.0 license. I would be happy if you credit me though :)

Notes

  • Make sure you import the motion vector texture as linear (non-sRGB) in your game engine
    • In Unity, uncheck sRGB (Color Textire) in texture settings
  • The output includes a JSON file which contains some metadata that are useful for various shader parameters
    • You can take a look at the JSON file if you forget some properties of the output like the motion strength and total number of frames

Appendix

Textures used to render the sample animations.

Color Atlas Motion Atlas
Explosion Color Atlas Explosion Motion Atlas
Smoke Color Atlas Smoke Motion Atlas

References

About

Generate motion vector for flipbook animation

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages