Hi,
I want to make a project with a LOT of video in it.
Thats not a huge problem, since the project will be saved on a DVD-R or DVD-DL , so plenty of space for video at acceptable bitrates.
Now I was wondering about the actual implementation.
On http://www.priveleraar.com I was able to put a static background and the squirrel movie actually has transparent background so you can see through it and see the background.
This is of course a flash movie and flash video does support a transparency channel.
I can produce quicktime .MOV files with transparency in them, but is the transparency channel usable in any way in unity3d ? In other words: Does ogg theora support a transparency channel in unity3d or would there be any other trick to have transparency in video ?
Kind regards,
Bart
If your alpha channel doesn’t change frame by frame you could use a shader that uses the movie texture for rgb and the alpha channel from a normal 2D texture.
Unfortunately, the alpha is not static.
Can I ask another question Joachim?
I have for example 10 such movies like the squirrel movie and they all start and end with the same still frame.
How would I have to implement in unity3d then that I would have for example 10 buttons (gui code) but when I press 1 of these then video should immediately start playing.
So for example I would have 3 videos
1 video of the squirrel idling a bit
1 video of the squirrel telling a joke
1 video of the squirrel telling another joke
So on startup I want to play the looping idle animation of the squirrel and then when for example I press a button, I want the idle animation to finish and after that start the animation where the squirrel tells joke 1. When joke 1 is finished, the squirrel should get back into his idling animation and loop again.
Is such a thing possible in unity without flicker ?
Could you help me a little on this please?
Thanks in advance,
Bart
.MOV files with transparency/alpha do work in Unity (doesn’t have to be a static mask). I haven’t tried it in 2.0, but at least in 1.6.2 you can create a plane and assign the .MOV file to a material on that plane. Set the material to alpha/diffuse. Then you need to assign an animated texture script to the plane object (don’t know if this is built in or something custom written by our programmer). If you aren’t able to figure out how to make such a script (I know I wouldn’t, but I’m an artist) I can ask if we’d be able to post ours. But with that setup you can have your movie play and the alpha dropped out to see whatever you have going on behind it.
If possible then please do let me know how you did it (the script I mean).
I don’t really see how it should be done in unity really, but its very important to me.
Also, I don’t know but I think I understood that ALL video (also quicktime) is now internally converted to ogg theora, so I don’t know if transparency is available in there.
So, please tell me how you did it. I am very willing to study hard just to get this working.
Regards,
Bart
Ok… attached or in-line is the script I used.
I don’t know about the internal ogg theora conversion, and I haven’t tried this in 2.0, but it does work for me in 1.6.2.
Again, to make it work all you need to do is create a plane (or use any existing object if you want), assign a material to it that points to your .MOV file with alpha. Set the material type to alpha/diffuse. Put the script onto the plane/object and tell it to use the .MOV file. That’s it, when you press play it will/should loop the animation from your .MOV file and whatever is black in the alpha will be dropped out and you can see anything behind it. If it’s still a no-go for you, I can try to make a sample project, but there’s nothing much to this.
----Pasted Script - (original filename: AnimatedTexture.js)----
public var texture : FileTexture;
public var framesPerSecond = 30.0;
public var animate : boolean = false;
function Update () {
if ( animate ) {
// Get Play Length And Time
var playLength : int = texture.frameCount / framesPerSecond;
var time : float = Mathf.Repeat (Time.time, playLength) / playLength;
// Update Frame
var frame : int = time * texture.frameCount;
texture.frame = Mathf.Clamp (frame, 0, texture.frameCount -1);
}
}
function Reset () {
if (renderer) {
texture = renderer.sharedMaterial.mainTexture;
}
}
// Getter Setter For Animate
function Animate ( val : boolean ) : void {
animate = val;
}
function Animate () : boolean {
return ( animate );
}
53305–1938–$animatedtexture_582.js (728 Bytes)
Thanks,
I can’t try right now since I sold my iMac and am awaiting my new macbookpro to arrive any time now.
So i’ll test it, but if I have problems I’ll re-contact you.
Anyway, many thanks in advance,
regards,
Bart
You can do the same in 2.0 by simply having a sequence of textures and assigning different textures to the material.
var myTextures : Texture2D[];
function Update (){
renderer.material.mainTexture = myTextures[someIndex]
}
Joachim,
I allready talked to David and internally everything in 2.0 seems to be converted to ogg theora, so video with transparent background is not possible in 2.0
With video I don’t mean a 20 frame loop, but for example a 5000 frames video lasting 200 seconds in the case of 5000 frames at 25fps
In flash9 it is now supported and it looks gorgeous, but obviously not (yet) in unity…
Maybe there could be enoded an extra channel using ogg teora and threat this channel as an alpha channel, but that would have to be built in in unity playback routines, its not something we can do by scripting.
This is a bit off track but: have you considered making the squirrel a model, instead? Sound sync may be an issue in that case however.
If the video codec supports parallel video tracks it should be possible… but probably only by UT.
Aaron,
I am indeed also trying to get this working.
But then I need to get some kind of blendshaping working.
I posted this http://forum.unity3d.com/viewtopic.php?t=7645 for this purpose.
Regards,
Bart
Gotcha. Yeah, blendshaping, unfortunately, is not really supported like other animation import features are. You could, of course, go for the facial animation via bones route as well. But all that is for the other thread.
Maybe this should be posted in the wish list:
Imported video with method for adding alpha/transparency.
Plus, hopefully a UT member will comment on this soon.
David allready told me that blendshapes is one of the features which most people are asking for unity to support it. So he made me understand (at least thats what I think to have understood) that blendshaping is highly requested and might eventually be added in one of the next updates.
It is always a guess because nobody knows if it will be in there, but it certainly would be a huge benefit for me and obviously also all the other people who sent in this feature request.
I understand that through bones it can also work, but thats just not the answer you expect when asking how to do (or fake) blendshaping 
Hope to get positive news about this thread from somebody @ UT
Drat! I’ve been following this post as I had the same situation come up where we were wanting to import a greenscreen .mov to use in unity. Now that I know it isn’t possible can I ask what changed in 2.0 to make this not possible?