Anime4K icon indicating copy to clipboard operation
Anime4K copied to clipboard

[Question] How do I use this in WebGL in libraries like Seriously.js and VideoContext?

Open stroberrysugar opened this issue 3 years ago • 2 comments

With VideoContext, we get code like this. It's similar to what Seriously.js has:

var monochromeDescription = {
    title:"Monochrome",
    description: "Change images to a single chroma (e.g can be used to make a black & white filter). Input color mix and output color mix can be adjusted.",
    vertexShader : `
        attribute vec2 a_position;
        attribute vec2 a_texCoord;
        varying vec2 v_texCoord;
        void main() {
            gl_Position = vec4(vec2(2.0,2.0)*a_position-vec2(1.0, 1.0), 0.0, 1.0);
            v_texCoord = a_texCoord;
        }`,
    fragmentShader : `
        precision mediump float;
        uniform sampler2D u_image;
        uniform vec3 inputMix;
        uniform vec3 outputMix;
        varying vec2 v_texCoord;
        varying float v_mix;
        void main(){
            vec4 color = texture2D(u_image, v_texCoord);
            float mono = color[0]*inputMix[0] + color[1]*inputMix[1] + color[2]*inputMix[2];
            color[0] = mono * outputMix[0];
            color[1] = mono * outputMix[1];
            color[2] = mono * outputMix[2];
            gl_FragColor = color;
        }`,
    properties:{
        "inputMix":{type:"uniform", value:[0.4,0.6,0.2]},
        "outputMix":{type:"uniform", value:[1.0,1.0,1.0]}
    },
    inputs:["u_image"]
};

How do I use the Anime4K GLSL shaders with this? I have no experience with working with shaders.

stroberrysugar avatar Apr 02 '21 12:04 stroberrysugar

I'm not sure what you are trying to do but this might be relevant: https://github.com/pinnouse/ani-ss

Jules-A avatar Apr 02 '21 14:04 Jules-A

@Jules-A That looks really promising, thanks!

stroberrysugar avatar Apr 02 '21 14:04 stroberrysugar