0-100 thresholds + invert checkboxes

Removes the need for piping the effect between Invert effects, which makes a unnecessary performance hit.
This commit is contained in:
oc1024
2019-01-25 09:13:24 -02:00
committed by GitHub
parent ac12a73486
commit e6df7de6bc
4 changed files with 26 additions and 18 deletions
+9 -8
View File
@@ -10,6 +10,7 @@ varying vec2 vTexCoord;
uniform float loc;
uniform float hic;
uniform int compo;
uniform bool invert;
float rgb2luma(vec3 c) {
return (max(max(c.r,c.g), c.b) + min(min(c.r,c.g), c.b))/2.0;
@@ -63,27 +64,27 @@ void main(void) {
switch(compo) {
case 0 :
toCheck = rgb2luma(color);
toCheck = rgb2luma(color)*100.0;
break;
case 4 :
toCheck = color.r;
toCheck = color.r*100.0;
break;
case 5 :
toCheck = color.g;
toCheck = color.g*100.0;
break;
case 6 :
toCheck = color.b;
toCheck = color.b*100.0;
break;
case 1 :
toCheck = rgb2hsv(color).z;
toCheck = rgb2hsv(color).z*100.0;
break;
case 2 :
toCheck = rgb2hsv(color).x/360.0;
toCheck = rgb2hsv(color).x/3.6;
break;
case 3 :
toCheck = rgb2hsv(color).y;
toCheck = rgb2hsv(color).y*100.0;
break;
}
tc.a = isNotIncreasingSequence(loc, toCheck, hic) ? 0.0 : tc.a;
tc.a = isNotIncreasingSequence(loc, toCheck, hic) ? (invert ? tc.a : 0.0) : (invert ? 0.0 : tc.a);
gl_FragColor = tc;
}
+5 -2
View File
@@ -12,10 +12,13 @@
</field>
</row>
<row name="Lower Limit">
<field type="double" min="0" default="0" max="1" id="loc"/>
<field type="double" min="0" default="0" max="100" id="loc"/>
</row>
<row name="Upper Limit">
<field type="double" min="0" default="1" max="1" id="hic"/>
<field type="double" min="0" default="100" max="100" id="hic"/>
</row>
<row name="Invert">
<field type="bool" min="0" default="100" max="100" id="invert"/>
</row>
<shader vert="common.vert" frag="colorsel.frag"/>
</effect>
+6 -5
View File
@@ -7,6 +7,7 @@ varying vec2 vTexCoord;
uniform float loc;
uniform float hic;
uniform bool invert;
void main(void) {
vec4 texture_color = texture2D(tex,vTexCoord);
@@ -15,12 +16,12 @@ void main(void) {
luma /= 2.0;
if (luma > hic) {
texture_color.a = 1.0;
} else if (luma < loc) {
texture_color.a = 0.0;
if (luma > hic/100.0) {
texture_color.a = (invert ? 0.0 : 1.0);
} else if (luma < loc/100.0) {
texture_color.a = (invert ? 1.0 : 0.0);
} else {
texture_color.a = luma;
texture_color.a = (invert ? 1.0-luma : luma);
}
gl_FragColor = texture_color;
+6 -3
View File
@@ -1,10 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<effect name="Luma Key" category="Keying">
<row name="Lower Limit">
<field type="double" min="0" default="0" max="1" id="loc"/>
<field type="double" min="0" default="0" max="100" id="loc"/>
</row>
<row name="Upper Limit">
<field type="double" min="0" default="1" max="1" id="hic"/>
<field type="double" min="0" default="100" max="100" id="hic"/>
</row>
<row name="Invert">
<field type="bool" min="0" default="100" max="100" id="invert"/>
</row>
<shader vert="common.vert" frag="lumakey.frag"/>
</effect>
</effect>