← Back

ofxAnime4K

github.com/hanasaan/ofxAnime4K · @hanasaan
OF 0.12 Shaders Rendering Graphics

Real-time GLSL upscaler addon for openFrameworks based on Anime4K and mpv

0 0 Last commit 11mo ago Created 11mo ago

README

ofxAnime4K



Real-time GLSL upscaler addon for openFrameworks based on Anime4K and mpv

Tested on openFrameworks 0.12.1 on macOS and Windows.

---

Usage



0. Copy shader file to bin/data

In shaders directory, some of the GLSL shaders from Anime4K is included. To use this in your app, please copy these .glsl files to yourApp/bin/data directory. Theoretically, any MPV compatible shaders should work as well in https://github.com/iwalton3/default-shader-pack .

1. Load an image and the shader



void ofApp::setup() {
    ofSetFrameRate(60);
    ofDisableArbTex();                           // important for proper sampling
    inputImage.load("Earnest_dog_in_the_grass_(Unsplash).jpg");
    anime4k.setupShader("shaders/Anime4K_Upscale_GAN_x2_S.glsl"); // please make sure this glsl file is copied into your bin/data directory.
}
Note: this photo is shared under CC0 by https://commons.wikimedia.org/wiki/File:Earnest_dog_in_the_grass_(Unsplash).jpg

2. Draw upscaled



void ofApp::draw() {
    anime4k.drawUpscale(inputImage.getTexture(),
                        0, 0,
                        ofGetWidth(), ofGetHeight());
}


drawUpscale(...) will:

1. set up FBOs for each parsed pass (if not ready), 2. run the whole pipeline on the input texture, 3. draw the final FBO to your screen.

3. Debug output (optional)



if (debugDraw) {
    anime4k.debugDraw();                // shows each pass
    ofDrawBitmapString(anime4k.getDebugInfo(), 300, 20);
}


This is useful when your GLSL has multiple //!HOOKs and you want to see the intermediate textures.

---

Limitations / Notes



Designed for GL2.1: compute shaders in the GLSL (//!COMPUTE) are ignored with a warning. Assumes input is GL_TEXTURE_2D; it will log an error otherwise. The example hard-codes 2× upscaling as the common case (Anime4K x2). You can change upscaleFactor in the addon if you need to.

---

License



Get this addon

HTTPS
SSH