A single despill effect for improving efects of chroma keying. Works for Green, Blue and Red backgrounds, no other controls yet. Tested.
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
/***
|
||||
Despill - for cleaning up keying residue.
|
||||
Implementation by unfa for Olive-Editor Community
|
||||
***/
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -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>
|
||||
Reference in New Issue
Block a user