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

前端 未结 2 961
轮回少年
轮回少年 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

    0 讨论(0)
  • 2021-01-25 18:06

    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

    0 讨论(0)
提交回复
热议问题