Index: source/blender/compositor/operations/COM_KeyingOperation.cpp =================================================================== --- source/blender/compositor/operations/COM_KeyingOperation.cpp (revision 51301) +++ source/blender/compositor/operations/COM_KeyingOperation.cpp (working copy) @@ -50,7 +50,7 @@ float val = screen_balance * pixelColor[min_channel] + (1.0f - screen_balance) * pixelColor[max_channel]; - return (pixelColor[primary_channel] - val) * fabsf(1.0f - val); + return pixelColor[primary_channel] - val; } KeyingOperation::KeyingOperation() : NodeOperation() @@ -87,35 +87,13 @@ int primary_channel = get_pixel_primary_channel(screenColor); - if (pixelColor[primary_channel] > 1.0f) { - /* overexposure doesn't happen on screen itself and usually happens - * on light sources in the shot, this need to be checked separately - * because saturation and falloff calculation is based on the fact - * that pixels are not overexposured - */ - output[0] = 1.0f; - } - else { - float saturation = get_pixel_saturation(pixelColor, this->m_screenBalance, primary_channel); - float screen_saturation = get_pixel_saturation(screenColor, this->m_screenBalance, primary_channel); + float saturation = get_pixel_saturation(pixelColor, this->m_screenBalance, primary_channel); + float screen_saturation = get_pixel_saturation(screenColor, this->m_screenBalance, primary_channel); - if (saturation < 0) { - /* means main channel of pixel is different from screen, - * assume this is completely a foreground - */ - output[0] = 1.0f; - } - else if (saturation >= screen_saturation) { - /* matched main channels and higher saturation on pixel - * is treated as completely background - */ - output[0] = 0.0f; - } - else { - /* nice alpha falloff on edges */ - float distance = 1.0f - saturation / screen_saturation; - - output[0] = distance; - } - } + float key = 1.0f - saturation / screen_saturation; + float dR = pixelColor[0] - screenColor[0]; + float dG = pixelColor[1] - screenColor[1]; + float dB = pixelColor[2] - screenColor[2]; + key = MAX4(key, dR, dG, dB); + output[0] = CLAMPIS(key, 0.0f, 1.0f); }