Did you create the video, and if so, can you make it into like a PNG image sequence instead? If the video is short (like your studio logo), an image sequence would work fine.
The reason I'm asking is that while you can try to derive the alpha channel from the RGB channels, it's a lossy process.
If your background color is black and you want to have
soft degrees of transparency, this means that the darker a pixel is, the more transparent it'll be, and the only 100% opaque pixel is a fully white one -- anything less than white will have some level of transparency, especially dark colors, even if in the original scene they'd be opaque. So a dark but fully opaque object will end up looking transparent in your chroma-keyed video.
If you didn't create the video or if you can't have it as a PNG image sequence (that is, if you really need to derive alpha from RGB in a shader), then you can simply plug the Y component of the video into the alpha channel.
Löve internally uses 3 textures for a video, each for the Y, Cb and Cr components of the video, and the Y texture has the luma (the brightness) of each pixel in the video. That's your alpha channel.
You'd create a pixel shader with this code:
Code: Select all
void effect() {
vec4 videoColor = VideoTexel(VaryingTexCoord.xy) * VaryingColor;
float alpha = Texel(love_VideoYChannel, VaryingTexCoord.xy).r;
love_PixelColor = vec4(videoColor.xyz, alpha);
}
References: