hi,
i want to play video in unity with alpha channel.
i tried with this shader to play main video and mask to remove bg.
Shader "MovieWithSeperateAlpha" {
Properties
{
_MainTex ("Base (RGB)", 2D) = "white" {}
_Mask ("Culling Mask", 2D) = "white" {}
_Cutoff ("Cutoff", Range (0,1)) = .5
}
SubShader
{
Tags {"Queue"="Transparent"}
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
Pass
{
CGPROGRAM
// Upgrade NOTE: excluded shader from OpenGL ES 2.0 because it does not contain a surface program or both vertex and fragment programs.
#pragma exclude_renderers gles
#pragma fragment frag
#include "UnityCG.cginc"
sampler2D _MainTex;
sampler2D _Mask;
struct v2f
{
float4 pos : POSITION;
float4 uv : TEXCOORD0;
};
half4 frag (v2f i) : COLOR
{
half4 color = tex2D(_MainTex, i.uv.xy);
half4 color2 = tex2D(_Mask, i.uv.xy);
return half4(color.r, color.g, color.b, color2.r);
}
ENDCG
}
}
Fallback "Transparent/Diffuse"
}
And then i use this script to play both main and mask channel at the same time.
var maintexture : MovieTexture;
var mask : MovieTexture;
function Start ()
{
maintexture = renderer.material.GetTexture ("_MainTex");
mask = renderer.material.GetTexture ("_Mask");
}
function Update ()
{
if (Input.GetButtonDown ("Jump"))
{
maintexture.Play();
mask.Play();
}
}
this code and Shader is working fine but my problem is i am getting bit of delay in playing both movie texture simultaneously.
is there anyway that i can sync both at the same time. or execute play at the same time.
thanx