问题
I'm trying to use a video with alpha channel, but all I get is the alpha channel as color black.
I'm using the Vuforia video playback example.
I hope I'm not missing any relevant info.
Thanks in advance, any help will be appreciated :)
回答1:
Vuforia plays video by using the built-in system video players (on iOS and Android) by setting them to output to a render texture.
The system players do not support alpha channel video.
You need to apply a chroma-key shader on the render texture to remove say green or purple.
There is some discussion in the vuforia forums:
playing-video-alpha-channel-videosample-demo-project
回答2:
You need to make a "special video" like the pic, in a power of two like: 256x512 format
pic of special video to be used
Then use this custom shader:
Properties{
_MainTex("Color (RGB)", 2D) = "white"
}
SubShader{
Tags{ "Queue" = "Transparent" "RenderType" = "Transparent" }
CGPROGRAM
#pragma surface surf NoLighting alpha
fixed4 LightingNoLighting(SurfaceOutput s, fixed3 lightDir, fixed atten) {
fixed4 c;
c.rgb = s.Albedo;
c.a = s.Alpha;
return c;
}
struct Input {
float2 uv_MainTex;
};
sampler2D _MainTex;
void surf(Input IN, inout SurfaceOutput o) {
o.Emission = tex2D(_MainTex, IN.uv_MainTex).rgb;
if(IN.uv_MainTex.y <= 0.5){
o.Alpha=0;
}
else{
o.Alpha = tex2D(_MainTex, float2(IN.uv_MainTex.x, IN.uv_MainTex.y-0.5)).rgb;
}
}
ENDCG
}
}
Also you can see my post in: http://answers.unity3d.com/questions/833537/how-to-play-alpha-video-in-unity.html#answer-1094012
来源:https://stackoverflow.com/questions/27239136/vuforia-it-is-possible-play-a-movie-texture-with-alpha-in-ios