diff --git a/effects/chromakey.frag b/effects/chromakey.frag index 0365badc7..a94b03f79 100644 --- a/effects/chromakey.frag +++ b/effects/chromakey.frag @@ -11,45 +11,51 @@ uniform vec3 key_color; 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*/ - return (0.299*c.r + 0.587*c.g + 0.114*c.b); + /*a utility function to convert colors in RGB into YCbCr*/ + return (0.299*c.r + 0.587*c.g + 0.114*c.b); } float rgb2cb (vec3 c) { - /*a utility function to convert colors in RGB into YCbCr*/ - return (0.5 + -0.168736*c.r - 0.331264*c.g + 0.5*c.b); + /*a utility function to convert colors in RGB into YCbCr*/ + return (0.5 + -0.168736*c.r - 0.331264*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.418688*c.g - 0.081312*c.b); + /*a utility function to convert colors in RGB into YCbCr*/ + return (0.5 + 0.5*c.r - 0.418688*c.g - 0.081312*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))); - if (temp < tola) {return (0.0);} - if (temp < tolb) {return ((temp-tola)/(tolb-tola));} - return (1.0); + /*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))); + if (temp < tola) {return (0.0);} + if (temp < tolb) {return ((temp-tola)/(tolb-tola));} + return (1.0); } void main(void) { - float cb_key = rgb2cb(key_color); - float cr_key = rgb2cr(key_color); - - vec4 texture_color = texture2D(tex, vTexCoord); + float cb_key = rgb2cb(key_color); + float cr_key = rgb2cr(key_color); + + vec4 texture_color = texture2D(tex, vTexCoord); - float cb = rgb2cb(texture_color.rgb); - float cr = rgb2cr(texture_color.rgb); - float mask = colorclose(cb, cr, cb_key, cr_key, (tola/100.0), (tolb/100.0)); - float submask = 1.0-mask; + float cb = rgb2cb(texture_color.rgb); + float cr = rgb2cr(texture_color.rgb); + float mask = colorclose(cb, cr, cb_key, cr_key, (tola/100.0), (tolb/100.0)); - texture_color.r = max(texture_color.r - submask*key_color.r, 0.0) + submask; - texture_color.g = max(texture_color.g - submask*key_color.g, 0.0) + submask; - texture_color.b = max(texture_color.b - submask*key_color.b, 0.0) + submask; - texture_color.a *= mask; - - gl_FragColor = texture_color; + if (mode == 0) { // composite + float submask = 1.0-mask; + texture_color.r = max(texture_color.r - submask*key_color.r, 0.0) + submask; + texture_color.g = max(texture_color.g - submask*key_color.g, 0.0) + submask; + texture_color.b = max(texture_color.b - submask*key_color.b, 0.0) + submask; + texture_color.a *= mask; + } else if (mode == 1) { // alpha + texture_color.rgb = vec3(mask); + } else if (mode == 2) { // original + } + + gl_FragColor = texture_color; } \ No newline at end of file diff --git a/effects/chromakey.xml b/effects/chromakey.xml index 0ee7c9dbf..9c72859c7 100644 --- a/effects/chromakey.xml +++ b/effects/chromakey.xml @@ -1,5 +1,12 @@ + + + + + + + diff --git a/ui/colorbutton.cpp b/ui/colorbutton.cpp index 8ba2fbfc2..026d1c42d 100644 --- a/ui/colorbutton.cpp +++ b/ui/colorbutton.cpp @@ -31,7 +31,7 @@ void ColorButton::set_button_color() { } void ColorButton::open_dialog() { - QColor new_color = QColorDialog::getColor(color, NULL); + QColor new_color = QColorDialog::getColor(color, NULL, "Set Color"); if (new_color.isValid() && color != new_color) { set_color(new_color); set_button_color();