filters icon indicating copy to clipboard operation
filters copied to clipboard

[REQUEST] OutlineFIlter Support : draw outline only

Open finscn opened this issue 6 years ago • 2 comments

draw outline only, don't draw the content of the original texture.

finscn avatar Apr 17 '19 10:04 finscn

I implement in my fork version :

varying vec2 vTextureCoord;
uniform sampler2D uSampler;

uniform vec2 thickness;
uniform vec4 outlineColor;
uniform vec4 filterClamp;
uniform bool outlineOnly;

const float DOUBLE_PI = 3.14159265358979323846264 * 2.;

void main(void) {
    vec4 ownColor = texture2D(uSampler, vTextureCoord);

    if (outlineOnly && ownColor.a > 0.0){
        float a = 1.0 - ownColor.a;
        gl_FragColor = vec4(outlineColor.rgb * a, a);
        return;
    }

    vec4 curColor;
    float maxAlpha = 0.;
    vec2 displaced;
    for (float angle = 0.; angle <= DOUBLE_PI; angle += ${angleStep}) {
        displaced.x = vTextureCoord.x + thickness.x * cos(angle);
        displaced.y = vTextureCoord.y + thickness.y * sin(angle);
        curColor = texture2D(uSampler, clamp(displaced, filterClamp.xy, filterClamp.zw));
        maxAlpha = max(maxAlpha, curColor.a);
    }
    float resultAlpha = max(maxAlpha, ownColor.a);

    gl_FragColor = vec4((ownColor.rgb + outlineColor.rgb * (1. - ownColor.a)) * resultAlpha, resultAlpha);
}

the kye code is

    if (outlineOnly && ownColor.a > 0.0){
        float a = 1.0 - ownColor.a;
        gl_FragColor = vec4(outlineColor.rgb * a, a);
        return;
    }

But I don't know any thing about v5 , so I can't create a PR.

finscn avatar Apr 17 '19 11:04 finscn

"knockout" mode, yeah

ivanpopelyshev avatar Apr 23 '19 20:04 ivanpopelyshev