Game Development Community

Animation with transparency in ogg, ogv or any supported format ?

by Vlad I · in Torque Game Builder · 08/04/2012 (1:55 am) · 7 replies

I don't think it is possible, but better ask people.

I've made an animation I want to use in T2D, but the dimensions are quite big to cut it in separate sprites as .png and make it work in the old way as sprite animation.

I know that I could play an animation as .ogg or .ogv file.
But can you have transparency in it ? Do any video files support it?


#1
08/04/2012 (9:43 am)
I'm not aware of any video formats with alpha channel.

It is often possible to fit fairly big animation into a texture. You can decrease animation resolution, by two or even four times from it's true size - motion will compensate for the lack of details. Framerate is also not as important, even 12 fps is more than people usually get with 2D animations.

And it might actually be possible to implement transparent videos in T2D. Just add 1/3 to the frame height, store alpha information there at the bottom, and use it to build RGBA texture when frame is loaded. Now that is something I must try.
#2
08/04/2012 (1:50 pm)
The real question should be "Can I play video and make it look like it has a transparent background?" Yes you can. That's the good news. The bad news is I haven't the foggiest idea how that is done, only that it may require masking. This is way outside my scope, however. Someone here surely knows how to do it.
#3
08/04/2012 (1:54 pm)
Then how do you know you can?
Any video sample?
#4
08/04/2012 (2:06 pm)
what is the list of all video file formats supported by TGB?
#5
08/05/2012 (6:30 am)
Well, the "mask" term is raster-graphics equivalent of "alpha channel". The problem is that ogv doesn't support masks, so some hackwork is required to blend videotextured sprite into a game.

I've seen games that drop an unmasked video rectangle over a scene. If the video has the same background it will blend in well. But you can't have animation behind the video sprite, can't move it around, and the quality of the surrounding sprites must be decreased to match the quality of the compressed video. This in my understanding beats the purpose of video animations.

Static, single image mask can be used to limit area of the video we want to display, and smooth out transition between the video and surrounding sprites. Still, part of background must be rendered into the video, so it will be pinned in place and limit layering possibilities.

This second approach would also require some changes to the engine. We would have to assign image and apply it to each frame texture, which is just one step away from retrieving and applying per-frame dynamic mask from decompressed video frame.
There's still a question of how one would add this alpha information to the video file, but it shouldn't be too hard to figure out I think.
#6
08/05/2012 (6:47 am)
Rpahut you are correct. So as I thought it is not possible to do it in TGB with any video format.

Although I read somewhere guys using Unity3D managed to do it by using additional video with a mask, like a black and white video. And then used it as a shader to cancel out the part they wanted to make transparent.
So, additionally you'd have to have 2 video files to load, which is itself not ideal.

Has anyone done something like that? It might take some source editing.
#7
08/05/2012 (6:48 am)
oh btw .mov supports alpha, but TGb only uses .ogg and .ogv