기본 배경위에 투명한 동영상을 올려야 하는 상황이 생겨 찾아보게 되었습니다.
인터넷에 우선 검색을 해보니 몇가지 자료가 나옵니다.
원문주소
자신있게 긴 댓글을 단 사람이 있는데….
마지막에 유니티 개발자라고 적은것으로 보아 덧글에 신뢰도가 높아 어떻게든 분석을 해야겠다는 생각으로 짧은 영어실력으로라도 분석을 좀 해봅니다.

Hi iflo!

There are surprisingly few movie file formats that can contain alpha and are supported by the native video decoding libraries on the various Unity editor/runtime platforms.

몇가지 알파채널을 지원하는 비디오가 있다는 말 같습니다.

Furthermore, to get a full understanding on what to do in order to get clips with transparency in various contexts, you must realize the implication of choosing whether you ask Unity to transcode your clips or not:

transcode라는 기능을 택할지 말지를 결정해야 한다는 듯…
  • If you choose to transcode the clip, Unity uses an internal layout that makes transparency work across the board, for both VP8 and H.264, which are the two video codecs the VideoClip importer knows how to transcode into.
transcode를 선택하면 아…잘 모르겠네요..
  • If you choose not to transcode, it means you know the target platform(s) will natively support the clip’s original format. You save time but it is up to you to verify the clip works as expected.
transcode를 선택하지 않은 이유는  니 타겟 플랫폼이 원래 알파채널을 지원하는지를 니가 원래부터 알고 있기 때문이다..물론 시간은 절약하겠지만 예상한대로 동작하게 니가 검증해야 한다?…뭐 이정도 해석인데…이것도 대충 이런 느낌만 알고 완벽하게 이해되지는 않습니다. 슬프네요..
Supported codecs with native capatility for transparency
투명을 지원하는 코덱
퀵타임 코덱을 말하는 것 같습니다.mov파일이죠.
Apple ProRes 4444
  • https://en.wikipedia.org/wiki/Apple_ProRes#ProRes_4444_and_ProRes_4444_XQ
  • https://support.apple.com/en-ca/HT202410
This is a proprietary codec made by Apple. It is natively supported on OSX and as such the Unity editor is able to decode these .mov clips on this editor platform as well as in the OSX standalone player. This is more of a work format however, and may be on the heavy side for distribution with your game. It has the advantage of being less compressed, meaning it preserves a good amount of quality when used as a transport format to transcode into another format later on. On Windows, since Apple discontinued the support of Quicktime for Windows, there is no builtin option to Apple ProRes 4444 on this platform.

퀵타임으로 만든건 무겁지만 퀄리티가 좋다…이런 얘긴것 같습니다.

You can author movie files that use the Apple ProRes 4444 codec using applications found here: https://support.apple.com/en-us/HT200321

Webm VP8 with alpha

  • https://en.wikipedia.org/wiki/WebM
  • https://en.wikipedia.org/wiki/VP8
  • http://wiki.webmproject.org/alpha-channel
Webm is a royalty-free movie container format sponsored by Google. It supports the VP8 and VP9 video codecs, also royalty-free and owned by Google. Unity currently only supports VP8. For this codec, the webm container definition has an extension to allow embedding an alpha channel with the color stream. We have implemented this extension in Unity so your webm+vp8+alpha will be understood on all the editor platforms as well as most runtime platforms. A notable exception to this is Android, which has a native – possibly hardware-assisted – implementation for VP8 decoding but does not support the alpha extension, so here will most likely have to enable Unity’s transcoding for its transparency to be available.
v8코덱은 구글이 만들었는데. 공짜고 웬만한 플랫폼에서는 동작이 된다고 하는것 같습니다. 안드로이드에 대한 언급 부분은 alpha extension을 지원하지 않는 다는 부분이
눈에 거슬리네요.
There are not many applications that produce webm with vp8 and alpha, but thanks to tools such as ffmpeg, you can easily convert your source material when needed. See the section about ffmpeg later on.
v8알파채널을 많은 어플리케이션이 지원하지 않는데 ffmpeg가 가능하게 해준다고 합니다.
Unity’s layout-based workaround to support transparency in VP8 and H.264In order to work around the difficulties of using standard clips with alpha in your Unity built game, Unity offers the “Keep Alpha” option in its VideoClip importer. When Unity detects the video has native alpha in it, the Keep Alpha option shows up in the VideoClip importer and if you enable it along with the transcode option, the resulting VideoClip asset will use an internal layout where the alpha is encoded in hidden color channels. During decoding at runtime, we recombine these hidden color channels with the actual color content on the GPU to yield a RGBA movie without needing any special decoding capabilities from the platform.
유니티는 비디오클립 임포터 keep alpha옵션으로 알파채널을 유지하는 기능을 제공합니다.

An exampleSo you can go ahead right now and download this clip in Unity on any editor platform: https://simpl.info/videoalpha/video/dancer1.webm

유니티에서 사용할 비디오 영상 주소
Just drag-and-drop the movie in your Assets folder and you can use it without transcoding in your scene. Drag-and-droping the VideoClip asset onto the Main camera will cause the video to play on the Camera’s far plane, leaving the skybox visible in the transparent portions of the movie.

드래그해서 다운 받은 영상을 assets폴더에 넣고 scene화면에 트랜스코딩 없이 사용할 수 있습니다.

You can even just put the URL in the VideoPlayer Component’s URL field (after you have set its Source popup to URL) and you’ll be playing it from the web without needing to create an asset.

Now, if you decide you target a platform that cannot read webm with transparency (e.g.: Android’s hardware decoder does not support vp8 with alpha), what you can do instead is transcode. Go to the VideoClip importer for this movie file, enable “Keep Alpha”, enable “Transcode”, hit “Apply” and the resulting clip can then be used, with transparency fully working, in the VideoPlayer on any target platform. The downside to this method is that transcoding in Unity takes time and is currently not interruptible. Both of these aspects will be addressed later on.
안드로이드는 vp8알파채널을 지원하지 않기때문에 transcode를 사용해야 합니다.

무비클립 임포터에서 Keep Alpha를 설정하고 transcode를 적용 시켜야 합니다.

Converting with ffmpegIf for some reason you have movie files that have transparency but are in a format that is not supported by Unity, you can use an external tool such as ffmpeg (https://ffmpeg.org) to convert into any of the Unity-supported movie file formats that can include transparency. ffmpeg supports reading and writing a broad range of file types so it is a good fit for this task. It is not an easy tool to figure out, however, but there is plenty of examples available on the web when you search for “how do you do xyz with ffmpeg”. Be ready for some command-line action, though.

To convert a movie that you know has transparency into a webm with vp8 and alpha:

ffmpeg -i my_clip_with_alpha.xyz -vcodec vp8 -pix_fmt yuva420p -metadata:s:v:0 alpha_mode=”1″ my_vp8_clip_with_alpha.webm​
To convert a movie that you know has transparency into a ProRes 4444:
ffmpeg -i my_clip_with_alpha.xyz -vcodec prores_ks -pix_fmt yuva444p10le -alpha_bits 16 -profile:v 4444 -f mov my_prores_4444_clip_with_alpha.mov​

This is just a startSo, as you can see, the topic of movie files with alpha is not a simple one but hopefully with this background and instructions, you’ll be able to get going. Hopefully, as we gather feedback, we’ll be able to streamline this process so it’s more automatic and leaves less chance to mistakes and uncertainties.

Hope this helps!

Dominique
A/V developer at Unity

대충 이정도만 해석하고 만들어 봅니다. 유니티는 5.6.3 64비트 버전으로 테스트합니다.
일단 테스트 프로젝트를 하나 만들고,
 .
 .
다운받은 알파채널 동영상을 드래그 해서 임포트 합니다.
 .
.
동영상을 클릭하면 inspector창에 옵션을 확인할 수 있는데 keep alpha에 체크를 하고 apply를 시켜줍니다. 스마트폰의 경우 override for Android옵션을 체크하고 codec를 vp8로 선택하고 적용해야 합니다.
 .
  .
 사각형의 회색영역이 없어지고 투명하게 변해 있는 걸 확인 할 수 있습니다.
 .
 .
동영상을 그대로 화면에 던져서 실행해도 투명하게 적용이 되지만 좌표설정이 불가능해 3d 객체에 넣기 위해 plane를 생성해서 그 안에 동영상을 드래그 합니다.
동영상 방향을 제대로 나오게 하기 위해 plane의 xy로테이션을 바꿔주었습니다.
이 상태로 동작시킬 경우 plane의 기본 배경색인 흰색으로 화면배경이 나오게 됩니다.
.
.
투명하게 만들기 위해 이리저리 적용해 보던중 material에 기본 텍스쳐를 적용한 후
texture라는 흰색 jpg파일을 만들어서 scene plane에 드래그하여 texture를 적용하니
하단의 shader의 옵션을 바꿀 수 있게 됩니다. unlit/Transparent로 변경하여 적용합니다.
.
 .
cube를 하나 만들어 plane뒤편에 배치해서 실행하면 영상이 cube앞쪽에서 플레이 되는 걸 확인 할 수있습니다.
 .