Merge pull request #887 from sobotka/patch-3

Update coefficients from busted up REC.601
This commit is contained in:
itsmattkc
2019-05-02 21:26:14 +10:00
committed by GitHub
3 changed files with 79 additions and 6 deletions
+59
View File
@@ -0,0 +1,59 @@
/***
Despill - for cleaning up keying residue.
Written by unfa for Olive Video Editor.
***/
uniform sampler2D tex;
varying vec2 uTexCoord;
uniform vec2 resolution;
uniform int channel;
const vec2 renderScale = vec2(1,1);
void main(void)
{
vec2 uv = gl_FragCoord.xy/resolution.xy;
vec4 col = texture2D(tex, uv);
// separate channels
float r = col.r;
float g = col.g;
float b = col.b;
float a = col.a;
// Select despilled channel: 0 = RED; 1 = GREEN; 2 = BLUE;
if (channel == 0) // RED
{
// replace new green channel by avaraging between existing red and blue channels
float r2 = (g + b) * 0.5;
// now composite the original and new gree channel using the "darken" mode
r = min(r, r2);
}
if (channel == 1) // GREEN
{
// replace new green channel by avaraging between existing red and blue channels
float g2 = (r + b) * 0.5;
// now composite the original and new gree channel using the "darken" mode
g = min(g, g2);
}
if (channel == 2) // BLUE
{
// replace new green channel by avaraging between existing red and blue channels
float b2 = (r + g) * 0.5;
// now composite the original and new gree channel using the "darken" mode
b = min(b, b2);
}
// and return the result
gl_FragColor = vec4(r, g, b, a);
}
+11
View File
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<effect name="Despill" category="Keying">
<row name="Channel">
<field type="combo" default="1" id="channel">
<option>Red</option>
<option>Green</option>
<option>Blue</option>
</field>
</row>
<shader vert="../COMMON/common.vert" frag="despill.frag"/>
</effect>
+9 -6
View File
@@ -12,6 +12,9 @@ uniform float tola;
uniform float tolb;
uniform bool opt;
uniform int mode;
float rgb2y (vec3 c) {
/*a utility function to convert colors in RGB into YCbCr*/
// This isnt colour managed and is a huge mess, but in the
// short term, using correct weights will give significantly
@@ -20,18 +23,18 @@ uniform int mode;
// The coefficients for YCbCr are calculated off of the
// REC.709 values.
return (0.2126*c.r + 0.7152*c.g + 0.0722*c.b);
}
}
float rgb2cb (vec3 c) {
/*a utility function to convert colors in RGB into YCbCr*/
return (0.5 + -0.1145721061*c.r - 0.3854278939*c.g + 0.5*c.b);
}
}
float rgb2cr (vec3 c) {
/*a utility function to convert colors in RGB into YCbCr*/
return (0.5 + 0.5*c.r - 0.4541529083*c.g - 0.0458470917*c.b);
}
}
float colorclose(float Cb_p,float Cr_p,float Cb_key,float Cr_key,float tola,float tolb) {
/*decides if a color is close to the specified hue*/
float temp = sqrt(((Cb_key-Cb_p)*(Cb_key-Cb_p))+((Cr_key-Cr_p)*(Cr_key-Cr_p)));