Vuforia: it is possible play a Movie texture with alpha in iOS?

前端 未结 2 962
轮回少年
轮回少年 2021-01-25 17:07

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

2条回答
  •  迷失自我
    2021-01-25 17:51

    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

提交回复
热议问题