Skip to content

Instantly share code, notes, and snippets.

@bjin
Last active December 14, 2023 23:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjin/399cb23818ad210941725ef768893499 to your computer and use it in GitHub Desktop.
Save bjin/399cb23818ad210941725ef768893499 to your computer and use it in GitHub Desktop.
dynamic stretching filter for mpv, aiming to bring effects similar to GoPro SuperView. use along with '--no-keepaspect'
//!DESC hyperview
//!HOOK MAIN
//!WHEN OUTPUT.width OUTPUT.height / MAIN.width MAIN.height / / 0.667 >
//!WIDTH OUTPUT.width
//!BIND HOOKED
vec4 hook() {
float r = (target_size.x / target_size.y) / (HOOKED_size.x / HOOKED_size.y);
// y = (r - 1) * x^3 + x
float y = (HOOKED_pos.x - 0.5) * 2.0 * r;
float x = y / r;
x -= ((r - 1.0) * x * x * x + x - y) / (3 * (r - 1.0) * x * x + 1.0);
x -= ((r - 1.0) * x * x * x + x - y) / (3 * (r - 1.0) * x * x + 1.0);
x -= ((r - 1.0) * x * x * x + x - y) / (3 * (r - 1.0) * x * x + 1.0);
x -= ((r - 1.0) * x * x * x + x - y) / (3 * (r - 1.0) * x * x + 1.0);
x -= ((r - 1.0) * x * x * x + x - y) / (3 * (r - 1.0) * x * x + 1.0);
return HOOKED_tex(vec2(x / 2.0 + 0.5, HOOKED_pos.y));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment