Unity VideoPlayer and Android

Hi all. Hope you're doing well.

Story scribe is progressing smoothly. Today I spent most of the day working on an interesting bug which I decided to share some thoughts on.

In our game we show an animation of a book landing on a table. The animation itself is actually a Webm with a VP8 codec and a transparent background. That's a good way to do transparent video according to the unity docs a least.

We ran into the interesting problem with that particular video though... On Android devices when we had the "keep alpha" setting on on the webm for transparency the video lagged horribly. It usually managed to show only a frame or two of the almost 4 sec long video.

I didn't manage to find a reason as to why the video lagged so much with transparency and all the different settings I tried and smaller fixes did nothing. Without the transparency the video played in great quality and without lagging at all.

That's when it hit me. I thought I'd approach the issue from a completely different angle and I did. I used the same video but instead of having a transparent background the background was completely black. I then nabbed a shader online (link below to source) for a green screen style chroma keyed transparency. With that the video worked like a charm and with some minor adjustments it looks excellent now!

So now we have a VideoPlayer -component with a render texture target and the render texture target has a material with the chroma key shader. Simple setup but works really well for our fullscreen video on top of UI.

Hopefully this shader and the mentioned VideoPlayer setup can be of use to you


With regards,

 - Pullis, Ticca programmer

Leave a comment

Log in with itch.io to leave a comment.