brunoherbelin / vimix

Live Video Mixer
GNU General Public License v3.0
259 stars 25 forks source link

Luma key white #113

Closed MoorPoor closed 6 months ago

MoorPoor commented 7 months ago

As far as I can tell, it's quite difficult to key white from a source. Lumakey removes black well, but there is no option for white. I couldn't get any good results under Chromykey either. I think another threshold for bright parts should be added at Lumakey. What do you think?

this is how Lumakey is solved in OBS - just as an example
(Video background is white) Bildschirmfoto vom 2023-11-17 18-42-50

brunoherbelin commented 7 months ago

Thanks for the suggestion!

I added a 'Luminance' parameter to the Lumakey filter: white lumakey with Luminance = 1.0

If you try version Beta 657b05d077a480a1fc89dada6af6b56905c6c211, you can access the new parameter; image

Alternatively, you can create a custom filter with the following code:

void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
    float Luminance = 1.0;
    float Threshold = 0.5;
    float Tolerance = 0.5;

    vec2 fragPos =  fragCoord.xy / iResolution.xy;
    vec3 RGB = texture(iChannel0, fragPos).rgb;
    float L = dot(RGB, vec3(0.299, 0.587, 0.114));

    fragColor = vec4( RGB, smoothstep( Threshold, Threshold + Tolerance * Tolerance, abs(Luminance - L) ) );
}
MoorPoor commented 7 months ago

thanks. works great so far! grafik

MoorPoor commented 6 months ago

I checked the beta with alpha key now. works perfectly as far as I can tell

brunoherbelin commented 6 months ago

NB: see #117 for update (bug fix)