From 3d2ec7aee3a0457b1abb81d49dadadda9334193c Mon Sep 17 00:00:00 2001 From: oc1024 Date: Wed, 30 Jan 2019 00:30:38 -0200 Subject: [PATCH] Premultiply alpha + GLSL1.1 Support for Olive's new blend-mode infrastructure. Plus, `switch (compo) {` has been replaced with `if {} else if {}` in Color Finder so it runs on OpenGL 2.0 hardware. --- effects/colorsel.frag | 35 ++++++++++++++--------------------- effects/lumakey.frag | 1 + 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/effects/colorsel.frag b/effects/colorsel.frag index 05ddff90d..903e4a0f8 100644 --- a/effects/colorsel.frag +++ b/effects/colorsel.frag @@ -2,7 +2,7 @@ Based on Edward Cannon's Simple Chroma Key (adaptation by Olive Team) RGB to HSV based on MattKC's toonify source code Feel free to modify and use at will */ -#version 150 +#version 110 uniform sampler2D tex; varying vec2 vTexCoord; @@ -58,33 +58,26 @@ bool isNotIncreasingSequence(float a, float b, float c) { } void main(void) { - vec4 tc = texture2D(tex,vTexCoord); - vec3 color = tc.rgb; + vec4 texture_color = texture2D(tex,vTexCoord); + vec3 color = texture_color.rgb; float toCheck = 0.0; - switch(compo) { - case 0 : + if (compo == 0) { toCheck = rgb2luma(color)*100.0; - break; - case 4 : + } else if (compo == 4) { toCheck = color.r*100.0; - break; - case 5 : + } else if (compo == 5) { toCheck = color.g*100.0; - break; - case 6 : + } else if (compo == 6) { toCheck = color.b*100.0; - break; - case 1 : + } else if (compo == 1) { toCheck = rgb2hsv(color).z*100.0; - break; - case 2 : + } else if (compo == 2) { toCheck = rgb2hsv(color).x/3.6; - break; - case 3 : + } else if (compo == 3) { toCheck = rgb2hsv(color).y*100.0; - break; - } - tc.a = isNotIncreasingSequence(loc, toCheck, hic) ? (invert ? tc.a : 0.0) : (invert ? 0.0 : tc.a); - gl_FragColor = tc; + } + texture_color.a = isNotIncreasingSequence(loc, toCheck, hic) ? (invert ? texture_color.a : 0.0) : (invert ? 0.0 : texture_color.a); + texture_color.rgb *= texture_color.a; + gl_FragColor = texture_color; } diff --git a/effects/lumakey.frag b/effects/lumakey.frag index d8092c4cb..16dfdfa08 100644 --- a/effects/lumakey.frag +++ b/effects/lumakey.frag @@ -24,5 +24,6 @@ void main(void) { texture_color.a = (invert ? 1.0-luma : luma); } + texture_color.rgb *= texture_color.a; gl_FragColor = texture_color; }