There are great examples of mixing animation and graphics, by EYEJACK based on AR technology:

EYEJACK has also released an AR book includes these examples:

I feel it is not such perfect in this period, because of limits of devices and algorithm, but a pleasant way to use AR form in the future, with HMD as Google Glass and etc..

So the problem now is how to achieve this effect with present technology in an easy way that designers with basic coding background are able to do.

At first, I had two ideas:

  1. Using shader to make the background invisible.
  2. Using a video with alpha channel;

The first way works well, I learnt a lot from this tutorial, but the shortage of being tough to locate the video in the ideal place makes me think it might not be a good method. Here is the result:

Feb-04-2018 15-28-47.gif

1. Softwares

  1. macOS 10.13.2;
  2. Unity 2017.3;
  3. Vuforia SDK included in Unity’s installation package;
  4. After Effect CC2017.

2. Video

  1. In AE, use effect/keying/color range to make the background invisible, and export two videos: one with RGB channel and another with Alpha channel.Feb-04-2018 15-48-27.gif
  2. Create a new composition and put two videos together as this, then render it as mp4屏幕快照 2018-02-04 下午3.53.14.png

3. AR

  1. If you don’t know how to set up Vuforia’s ImageTarget environment, please follow this Vuforia official tutorial, it is quite basic and I don’t want to copy it here.
  2. Create a plane in Hierarchy, later it will be used as the platform of video playing, and drag it under the ImageTarget屏幕快照 2018-02-04 下午4.01.18.png
  3. Create a new Material in Project, and drag it on the plane, and also Add Component/Video Player on the plane, and import your video in Project and drag it into the Video Clip which is in the Video Player屏幕快照 2018-02-04 下午4.03.15.png
  4. Create a new Shader in Project, and replace all default codes with these, which I learnt from the mentioned tutorial:
         Shader "Custom/Transparent" {
     Properties {
         _Color ("Color"Color) = (1,1,1,1)
         _MainTex ("Albedo (RGB)"2D) = "white" {}
         _Glossiness ("Smoothness"Range(0,1)) = 0.5
         _Metallic ("Metallic"Range(0,1)) = 0.0
         _Num("Num",float) = 0.5 

    }

    SubShader {
         Tags { "Queue"="Transparent"  "RenderType"="Transparent"}
         LOD 200

        CGPROGRAM
     #pragma surface surf NoLighting alpha:auto
 
     fixed4 LightingNoLighting(SurfaceOutput s, fixed3 lightDir, fixed atten)
         {
             fixed4 c;
             c.rgb = s.Albedo;
             c.a = s.Alpha;
             return c;
         }
     float _Num;

        sampler2D _MainTex;

        struct Input {
             float2 uv_MainTex;
         };

        half _Glossiness;
         half _Metallic;
         fixed4 _Color;
         UNITY_INSTANCING_BUFFER_START(Props)
         UNITY_INSTANCING_BUFFER_END(Props)
     void surf (Input IN, inout SurfaceOutput o) 
         {
             o.Emission = tex2D(_MainTex, IN.uv_MainTex).rgb;            
             

             if (IN.uv_MainTex.x >= 0.5)
             {
                 o.Alpha = 0;
             }
             else
             {
                 o.Alpha = tex2D(_MainTex, float2(IN.uv_MainTex.x + 0.5, IN.uv_MainTex.y)).rgb;                        
             }

        }
         ENDCG
     }
     FallBack "Diffuse"
     }

5. Select the plane, and change the shader in the material part屏幕快照 2018-02-04 下午4.17.53.png

4.Test & Build

  1. If you have finished that Vuforia’s official tutorial, you should know how to play it with your webcam;
  2. If the webcam works well, so you can build it into your mobile device with File/Build and Run;
  3. It will automatically run the Xcode software, and this process you can learn from this Unity official tutorial.
  4. Done

The second way is much easier but it has a shortage that it can only work on apple’s devices because it use Apple ProRes 4444 which is only supported on OSX, check Unity’s official documentation about Video transparency support for more information.

1.Video

  1. It is the same workflow as the first method, in the After Effect you will have the result that video has an transparent background;屏幕快照 2018-02-04 下午6.35.50.png
  2. Then you have to export the video as QuickTime format with RGB+Alpha channels屏幕快照 2018-02-04 下午6.38.16.png
  3. On the same window, there is a button named Format Options, click it and in the new window you have to choose Apple ProRes 4444 as the Video Codec屏幕快照 2018-02-04 下午6.40.28.png
  4. Render it and you will have an Unity-Ready transparent video

2. AR

  1. Import it into Unity and in the Inspector click Keep Alpha and click Apply屏幕快照 2018-02-04 下午6.44.16.png
  2. Drag it into Video Clip of Video Player Component of Plane which has been mention in the first method, and create a new Material for the plane which shader should be selected as Transparent/VertexLit with Z屏幕快照 2018-02-04 下午6.47.56.png
  3. Done

发表评论

Fill in your details below or click an icon to log in:

WordPress.com 徽标

You are commenting using your WordPress.com account. Log Out /  更改 )

Google+ photo

You are commenting using your Google+ account. Log Out /  更改 )

Twitter picture

You are commenting using your Twitter account. Log Out /  更改 )

Facebook photo

You are commenting using your Facebook account. Log Out /  更改 )

Connecting to %s