Alpha on chroma key?
I'm having some issues with some green screen stuff I'm trying to get working. This is with video, but I believe the issue would be the same for still images. I have two videos, one a greenscreen that I want overlay over the second. The green screen video has some transparency, so, for example, an image that fades from 100% opacity at the top to 50% near the bottom. You can see the "fade" in the greenscreen video, where pure transparency is replaced by green.
Problem is that those alpha values don't seem to be picked up by the GPUImageChromaKeyBlendFilter. The filter seems to just eat up anything with an alpha less than 1, so all of the lower opacity parts of the image simply disappear.
Is there a way to tweak the chroma key filter to better "honor" transparency, or is there some other way to transform the green levels into alpha levels? Note that in my case, I'm working with black and white (grayscale) effect videos, so I probably have more leeway in stripping green values out, but the principle issue still remains.
Thanks!
Unfortunately, I don't have anything I could use for testing this. Could you try replacing the appropriate line in the chroma key blend's fragment shader with the following:
float blendValue = (1.0 - smoothstep(thresholdSensitivity, thresholdSensitivity + smoothing, distance(vec2(Cr, Cb), vec2(maskCr, maskCb)))) * textureColor.a;
and see if that produces the effect you want? The above calculation should add the alpha channel into the mix for the keying.
Hmm, that doesn't seem to help. The translucent part is showing up pretty green, still. Interestingly if you use a multiplier using textureColor.g instead of textureColor.a, the transparency works a bit better, but it's still all green (instead of gray, as in the source chroma video). If it helps, I can send screenshots and a demo greenscreen video.
Thanks again, your help is MUCH appreciated.
On Aug 5, 2012, at 2:05 PM, Brad Larson [email protected] wrote:
Unfortunately, I don't have anything I could use for testing this. Could you try replacing the appropriate line in the chroma key blend's fragment shader with the following:
float blendValue = (1.0 - smoothstep(thresholdSensitivity, thresholdSensitivity + smoothing, distance(vec2(Cr, Cb), vec2(maskCr, maskCb)))) * textureColor.a;and see if that produces the effect you want? The above calculation should add the alpha channel into the mix for the keying.
Reply to this email directly or view it on GitHub: https://github.com/BradLarson/GPUImage/issues/353#issuecomment-7513112
I believe what you want is now handled well by the new GPUImageChromaKeyFilter (different from the GPUImageChromaKeyBlendFilter), which turns the keyed color transparent in the source image.