Search Unity

how to make a Movie with alpha channel work ?

Discussion in 'General Discussion' started by Rakeshkr590, Mar 7, 2013.

  1. Rakeshkr590

    Rakeshkr590

    Joined:
    Mar 7, 2013
    Posts:
    9
    Hi guys ,
    i have read through most of the post regarding this question but i haven't managed to find any sort of examples or process to make this work . Could any one of you please post or give me a link to any examples or a step through process for this please thank you.
     
  2. MarigoldFleur

    MarigoldFleur

    Joined:
    May 12, 2012
    Posts:
    1,353
    I don't believe the Ogg Theora implementation in Unity supports alpha channels. At least, that was the case some time ago.
     
  3. Rakeshkr590

    Rakeshkr590

    Joined:
    Mar 7, 2013
    Posts:
    9
    Hi marigoldfleur , i have seen people doing things like splitting a movie into 2 different one one with rgb data and the another one with alpha but here goes the problem , they both are out of sync . so if this kind of implementation exits is there any documentation regarding this if not and example ?
     
  4. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    2,901
    You can have the RGB Video and the alpha channel side by side like on the picture

    (Sorry did not find a better image fast)
    $depositphotos_3393846-Number-9-of-the-grass-with-alpha-channel.jpg

    I used a shader like this

    Code (csharp):
    1. Shader "Custom/VideoAlpha_invert" {
    2.        Properties {
    3.           _MainTex ("Base (RGB)", 2D) = "white" {}
    4.           _AlphaOffsetX ("alpha offset x", float) = 0.5
    5.           _AlphaOffsetY ("alpha offset y", float) = 0
    6.           _Cutoff ("Cutoff", Range (-1,0)) = -0.3
    7.        }
    8.        SubShader {
    9.             //Lighting Off
    10.             AlphaTest Less [_Cutoff]
    11.             Tags {"Queue"="Transparent-20" "IgnoreProjector"="True" "RenderType"="Transparent"}
    12.  
    13.             LOD 300
    14.             //ZWrite Off
    15.             //alphatest:_Cutoff
    16.             CGPROGRAM
    17.             #pragma surface surf Lambert alphatest:_Cutoff
    18.  
    19.                  sampler2D _MainTex;
    20.                  float _AlphaOffsetX;
    21.                  float _AlphaOffsetY;
    22.            
    23.                  struct Input {
    24.                     float2 uv_MainTex;
    25.                  };
    26.                  void surf (Input IN, inout SurfaceOutput o) {
    27.                     half4 c = tex2D (_MainTex, IN.uv_MainTex);
    28.                     IN.uv_MainTex.x += _AlphaOffsetX;
    29.                     IN.uv_MainTex.y += _AlphaOffsetY;
    30.                     half4 d = tex2D (_MainTex, IN.uv_MainTex);
    31.                     o.Albedo = c.rgb;
    32.                     //o.Alpha =  (d.r*-1)+1;
    33.                     o.Alpha =  ((d.r*-1)+1 )*-1;
    34.                  }
    35.                  
    36.                  ENDCG
    37.              
    38.              
    39.            }
    40.       // FallBack "Diffuse"
    41.       FallBack "Transparent/Diffuse"
    42.     }
    so you just show (via texture offset) the RGB part of the video and use the Alpha part of the video for your cutout.
    (Maybe the shader need some work ,to work in your case but it should work some how)
     
  5. Rakeshkr590

    Rakeshkr590

    Joined:
    Mar 7, 2013
    Posts:
    9
    @fffMalzbier Thank you so much for this i will try this out now for sure . if any one has any other approach please tell me thank you.
     
  6. Jingle-Fett

    Jingle-Fett

    Joined:
    Oct 18, 2009
    Posts:
    549
    This is a feature I really wish Unity had. You can get around it in some cases by using a sprite sheet, like if you were taking stock footage of effects and wanted to use them as animated particles. But it would be so much easier and production friendly if we could just import pre-keyed video footage :/
     
unityunity