Unity3d a way to play transparent MOV format video

Source: Internet
Author: User

First of all, this is the use of shader to achieve transparency, not using a transparent channel containing MOV video


The web looked at unity seems to have no way to support transparent channel MOV format video

But can be implemented with shader, MOV if the transparent channel with the same as no transparency is black background

Here need two video, AE inside as the following format output, note channels One is RGB another is Alpha does not need other adjustments

(also do not compress, because unity will automatically compress the MOV format, if the Mov import error first look at your video name is not Chinese speaking again )


I found one on the net. Write the shader file below and put the material on the object, and then press as adjust

Albedo (diffuse reflection) put RGB that Alpha put alpha that video



Shader "Custom/example" {Properties {_color ("color", color) = (1,1,1,1) _maintex ("Albedo (RGB)", 2D        = "White" {} _alphavideo ("Alpha Video (R)", 2D) = "White" {} _glossiness ("Smoothness", Range (0,1)) = 0.5 _metallic ("Metallic", Range (0,1)) = 0.0} subshader {Tags {"Queue" = "Transparent" "rendertype" = "Trans  Parent "} LOD Cgprogram//Physically based standard lighting model, and enable shadows on All light types #pragma surface surf standard alpha//Use Shader Model 3.0 target, to get nicer looking l        Ighting #pragma target 3.0 sampler2d _maintex;         Sampler2d _alphavideo;            struct Input {float2 Uv_maintex;        FLOAT2 Uv_alphavideo;         };        Half _glossiness;        Half _metallic;         Fixed4 _color;            void Surf (Input in, InOut surfaceoutputstandard o) {//Albedo comes from a texture tinted by colorFixed4 C = tex2d (_maintex, In.uv_maintex) * _COLOR;            Fixed4 _alpha = tex2d (_alphavideo, In.uv_alphavideo);            O.albedo = C.rgb;            Metallic and smoothness come from slider variables o.metallic = _metallic;            o.smoothness = _glossiness;                   O.alpha = _ALPHA.R; } ENDCG} FallBack "Diffuse"}
(reference URL http://forum.unity3d.com/threads/video-with-alpha.338072/)
Note that if you still see the black not seeing the animation that is because the video is not playing

Remember to play play () on all two videos; will be correct.

This method is suitable for GUI, but there will be a faint transparent background color.

Shader can be changed into

#pragma surface Surf Lambert alpha

Surfaceoutputstandard
Also change to Surfaceoutput can get the effect, notice this kind of put GUI will be all black or all white

Other quick methods are still in the exploration, hoping to have a good effect to share Kazakhstan, progress together

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Unity3d a way to play transparent MOV format video

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.