X-Git-Url: https://git.cinelerra-gg.org/git/?a=blobdiff_plain;f=cinelerra-5.1%2Fplugins%2Fchromakeyhsv%2Fchromakey.sl;fp=cinelerra-5.1%2Fplugins%2Fchromakeyhsv%2Fchromakey.sl;h=25ca2d041b1a80266c8715257e8298a010828c98;hb=21c2e6b36d6a96c2f662a89459d607b5a387f4eb;hp=1ea5570a3a6ac4ad504378223091ae469b075844;hpb=5a1b2bb96f2bd6b7ef4f8031763683726c02219d;p=goodguy%2Fhistory.git diff --git a/cinelerra-5.1/plugins/chromakeyhsv/chromakey.sl b/cinelerra-5.1/plugins/chromakeyhsv/chromakey.sl index 1ea5570a..25ca2d04 100644 --- a/cinelerra-5.1/plugins/chromakeyhsv/chromakey.sl +++ b/cinelerra-5.1/plugins/chromakeyhsv/chromakey.sl @@ -34,7 +34,7 @@ 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); @@ -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 */