Log in or register to post comments

Alpha video...

October 25, 2013 - 11:47am #1

I know it's not something unity does natively but I've been able to work around with a texture mask, rendering 2 videos, one color and one with the alpha as a mask. 


Now I want to implement it in vuforia but on the video playback it seems the guts are running in the plugin and not unity. Is there a simple way to initialize a second video to start/stop with the color video that I can feed into my shader's mask property?


I'm thinking now I should just use 1 video 2x as tall and have the color frame on the top half and mask frame on the bottom. Then on the material I can adjust the uv's to show only the color video half minus the matte area....


As a png sequence, unity takes an empty png and allocates the same size as if it were full of data, a 250 frame (10 sec @ 25 fps) long animation is like 50mb+ on mobile, while the same thing as a 10 sec video is only 1.5mb lol 


What do you guys recommend?

Alpha video...

November 1, 2013 - 9:55am #5

In the DefaultTrackableEventHandler.cs script inside OnTrackableStateChanged() instead of calling ontrackingfound and OnTrackingLost I start/stop coroutines.


If the tracker is found it plays an "intro" coroutine and if it's lost it plays "exit" coroutine.


public void OnTrackableStateChanged(
                                    TrackableBehaviour.Status previousStatus,
                                    TrackableBehaviour.Status newStatus)
        if (newStatus == TrackableBehaviour.Status.DETECTED ||
            newStatus == TrackableBehaviour.Status.TRACKED)
           // OnTrackingLost();


Then in the intro coroutine I start the video, let it play then spawn the other stuff after some delays:

IEnumerator Intro(){
		DOORVID.SetActive(true); //my video plane
		yield return new WaitForSeconds(3.7f);
		Garage.SetActive(true);   //turn 3d garage object on
		Rider.SetActive(true);    //turn motorcycle rider on
		yield return new WaitForSeconds(1.2f);
		lightfx.SetActive(true);   //turn his headlight on, animation plays automatically 
		doorFrameOpen.SetActive(true); //a still frame of the door open
		DOORVID.SetActive(false); //hide doorvideo plane
	IEnumerator Exit(){
		yield return new WaitForSeconds(0.2f);
		yield return new WaitForSeconds(0.1f);
		movietex.Stop();  //STOP THE VIDEO


Alpha video...

November 1, 2013 - 9:04am #4

Thanks lmbarns. 

I succeeded in your way. removed VideoPlaybackBehaviour.cs then add MobileMovieTexture.cs to video object. it works! 

One more question, how to control the video with MobileMovieTexture.cs?  for example, when target found, video plays, when target missing, video pause. 

Thank you!

Alpha video...

October 31, 2013 - 4:39pm #3

I ended up getting it working after buying a $75 plugin that has 2 shaders that can either chroma key (remove based on color) or can mask off the color video based on an alpha matte. 


You have to structure the videos differently (color frame on top, alpha matte below it for each frame), but it took my png sequences from > 50mb+ each down to 250kb each which is huge, cut my build size and load times down drastically and it performs better than trying to draw a hundreds of pngs in a sequence...


It plays video on the texture on phones rather than fullscreen. This is the plugin https://www.assetstore.unity3d.com/#/content/2449  



EDIT:: I made an example of how the video has to be to mask off using alpha which you can see here- http://www.youtube.com/watch?v=iMWleWooJJ8


And here's an example of it being used in vuforia: http://www.youtube.com/watch?v=swCpGr7kNug&feature=player_detailpage

Alpha video...

October 29, 2013 - 12:58am #2

I have the same question.

Log in or register to post comments