Hello, I'm trying to get a video with an alpha channel running on IOS. I have a plane with the texture playing and I use the following shader that works fine in the editor if set to stand alone. Should i switch the platform to IOS the shader stops working. Since alpha channels arent supported on ios with video. I have a movie with the alpha channel next to it that i sample from. Adding 'alpha' to the pragma tags will invert my mask Code (CSharp): Shader "Custom/VideoAlpha" { Properties { _MainTex ("Base (RGB)", 2D) = "white" {} _AlphaOffsetX ("alpha offset x", float) = 0.5 _AlphaOffsetY ("alpha offset y", float) = 0 _Cutoff ("Cutoff", Range (0,1)) = .5 } SubShader { Tags { "Queue" = "Transparent" } AlphaTest Less [_Cutoff] CGPROGRAM #pragma surface surf Lambert sampler2D _MainTex; float _AlphaOffsetX; float _AlphaOffsetY; struct Input { float2 uv_MainTex; }; void surf (Input IN, inout SurfaceOutput o) { half4 c = tex2D (_MainTex, IN.uv_MainTex); IN.uv_MainTex.x += _AlphaOffsetX; IN.uv_MainTex.y += _AlphaOffsetY; half4 d = tex2D (_MainTex, IN.uv_MainTex); o.Emission = c.rgb; o.Alpha = (d.r*-1)+1; } ENDCG } FallBack "Diffuse" }
It seems to me the inversion is done right there. Without inversion it's just: Code (csharp): o.Alpha = d.r; I'm also wondering a bit why you are using a surface shader for this. Do you need any lighting on the video?
It seems to me that d.r should lead to an inverted mask compared to 1-d.r. Anyway, I noticed the line AlphaTest Less [_Cutoff]. Less mode might not be (properly) supported on iOs. So just use: Code (csharp): AlphaTest Greater [_Cutoff] Combined with o.Alpha = d.r; If that doesn't work, just remove the alphatest and change o.Alpha = d.r to: Code (csharp): clip(d.r - _Cutoff); (Don't forget to add float _Cutoff as input.)
Somehow the shader fixed itself or perhaps i misspelt Less as Lesser and it simply broke. But the shader works like a charm now. Thanks Jvo3dc