X-Git-Url: http://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fplugins%2Fchromakeyhsv%2Fchromakey.sl;h=51cd1f3453f3fc434a4580a1b68dbbea62c25d55;hb=a4387a272874bd4ed9f010684976f336fa3d0190;hp=1ea5570a3a6ac4ad504378223091ae469b075844;hpb=30bdb85eb33a8ee7ba675038a86c6be59c43d7bd;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.1/plugins/chromakeyhsv/chromakey.sl b/cinelerra-5.1/plugins/chromakeyhsv/chromakey.sl index 1ea5570a..51cd1f34 100644 --- a/cinelerra-5.1/plugins/chromakeyhsv/chromakey.sl +++ b/cinelerra-5.1/plugins/chromakeyhsv/chromakey.sl @@ -34,17 +34,17 @@ void main() float alpha_saturation = 1.0; bool has_match = true; vec4 color2; - + /* Convert to HSV */ color2 = yuv_to_rgb(color); color2 = rgb_to_hsv(color2); /* Hue wrap */ if(color2.r <= hue_key - tolerance_in * 180.0) - color2.r += 360; + color2.r += 360.0; else if(color2.r >= hue_key + tolerance_in * 180.0) - color2.r -= 360; + color2.r -= 360.0; /* Hue is completely out of range */ if (tolerance == 0.0) @@ -52,32 +52,32 @@ void main() else if (abs(color2.r - hue_key) < tolerance_in * 180.0) alpha_hue = 0.0; - else - if ((out_slope != 0.0 ) && (abs(color2.r - hue_key) < tolerance * 180.0)) + else + if ((out_slope != 0.0 ) && (abs(color2.r - hue_key) < tolerance * 180.0)) /* If using slope, scale alpha between 0 and 1 / 2 */ - alpha_hue = abs(color2.r - hue_key) / tolerance / 360.0; - else - if (abs(color2.r - hue_key) < tolerance_out * 180.0) + alpha_hue = abs(color2.r - hue_key) / tolerance / 360.0; + else + if (abs(color2.r - hue_key) < tolerance_out * 180.0) /* If no slope, scale alpha between 1/2 and 1 */ - alpha_hue = abs(color2.r - hue_key) / tolerance_out / 360.0; + alpha_hue = abs(color2.r - hue_key) / tolerance_out / 360.0; else - has_match = false; + has_match = false; /* Test saturation */ - if (has_match) + if (has_match) { if (min_s == 0.0) alpha_saturation = 0.0; - else + else if ( color2.g - sat >= min_s_in ) alpha_saturation = 0.0; - else + else if ((out_slope != 0.0) && ( color2.g - sat > min_s ) ) alpha_saturation = (color2.g - sat - min_s) / (min_s * 2.0); - else - if ( color2.g - sat > min_s_out ) + else + if ( color2.g - sat > min_s_out ) alpha_saturation = (color2.g - sat - min_s_out) / (min_s_out * 2.0); - else + else has_match = false; } @@ -86,13 +86,13 @@ void main() { if (min_v == 0.0) alpha_value = 0.0; - else + else if ( color2.b >= min_v_in ) alpha_value = 0.0; - else + else if ((out_slope != 0.0) && ( color2.b > min_v ) ) alpha_value = (color2.b - min_v) / (min_v * 2.0); - else + else if ( color2.b > min_v_out ) alpha_value = (color2.b - min_v_out) / (min_v_out * 2.0); else @@ -104,13 +104,13 @@ void main() { if (max_v == 0.0) alpha_value_max = 1.0; - else + else if (color2.b <= max_v_in) alpha_value_max = 0.0; - else + else if ((out_slope != 0.0) && (color2.b < max_v)) alpha_value_max = (color2.b - max_v) / (max_v * 2.0); - else + else if (color2.b < max_v_out) alpha_value_max = (color2.b - max_v_out) / (max_v_out * 2.0); else @@ -122,14 +122,14 @@ void main() color2.a = max (max (alpha_hue, alpha_value), max (alpha_saturation, alpha_value_max)); /* Spill light processing */ - if ((abs(color2.r - hue_key) < spill_threshold * 180.0) || - ((abs(color2.r - hue_key) > 360.0) && + if ((abs(color2.r - hue_key) < spill_threshold * 180.0) || + ((abs(color2.r - hue_key) > 360.0) && (abs(color2.r - hue_key) - 360.0 < spill_threshold * 180.0))) { /* Modify saturation based on hue contribution */ - color2.g = color2.g * - spill_amount * - abs(color2.r - hue_key) / + color2.g = color2.g * + spill_amount * + abs(color2.r - hue_key) / (spill_threshold * 180.0); /* convert back to native colormodel */