This article is written by Cartzhang, reproduced please indicate the source. All rights reserved.
Article Link: http://blog.csdn.net/cartzhang/article/details/53674647
Cartzhang
"Introduction to VR"--360 Panorama video
This chapter uses an earlier Unity OC plugin to implement a 360 panorama video, and you can switch video content at will by using a different path configuration. This eliminates the process of packaging multiple times, easy to use.
Of course, you can spend 40 of knives to buy one.
https://www.assetstore.unity3d.com/cn/#!/content/35102
This one still listens to expensive.
Or make a free bar!!!
After packing, no password is available:
OC version 0.8.0 cloud disk address:
Http://pan.baidu.com/s/1nv4QLuD
OC version 0.4.4 cloud disk address:
Http://pan.baidu.com/s/1jI8uDRC
I. Resource requirements
Simply make a 360 panoramic video with the resources you need:
AVPro Windows Media2.9.0 Unity Plugin
:
Http://pan.baidu.com/s/1bz7pc6
0.4.4runtime required to install OC:
Http://pan.baidu.com/s/1jIJPXCa
Figure 1
Version used by untiy:
Figure 2
Second, make a 360 VR video 1. Import Plugins
Import Avpro Windows Media2.9.0 Plugin
Figure 6
Find the precast body he gives such as:
Figure 7
Then select the video file:
Figure 8
2. Decoder installation
If you run this time, you will get an error, as follows
According to the error:
For MP4 files-need an MP4 splitter such as Haali Media splitter or GDCL.
Figure 9
If you are interested in further understanding, you can look at the following address:
http://haali.su/mkv/
To download the required decoder directly here:
:
Then install:
Figure 10
Figure 11
Then load the load test again:
If you see the following, the decoder installation is successful
Figure 12
3. Set up video load configuration and run settings
First, you need to block the original main camera and then add the OC camera preform
Figure 13
Then, add the well-written configuration file code:
Figure 15
Finally, be careful not to tick the virtual Reality supported option because we are using the lower version of the Ocruntime plugin.
Figure 14
Of course, I also packaged the test of OC 0.8.0 Runtime, possibly relative to the 0.4.4 version, OC caused by the possibility of a crash is smaller. This is not a detailed test, just believe in unity Embedding and OC version upgrade optimization capabilities.
The packaged file will also be given the download link address later.
Third, use the configuration file to package and modify the video content at any time
Directly modify the Loadmovie function in AVProWindowsMediaMovie.cs.
BOOL Allownativeformat = (_colourformat! = Colourformat. RGBA32);String filePath = GetFilePath ();String FilePath = ConfigFile. Cconfig. Vediofullpathname;if (_movieplayer. Startvideo(FilePath, allownativeformat, _colourformat = = Colourformat. YCbCr_HD, _allowaudio, _useaudiodelay, _useaudiomixer, _usedisplaysync, _ignoreflips, _texturefiltermode, _textureWrapMode ) {if (_allowaudio) {_movieplayer. Volume= _volume;_movieplayer. Audiobalance= _audiobalance;} _movieplayer. Loop= _loop;if (autoPlay) {_movieplayer. Play();}} else
In fact, the only thing to modify is the video loading path, that's all.
Just change:
//string filePath = GetFilePath(); string filePath = ConfigFile.Cconfig.VediofullPathName;
That's all you can do.
Script for the configuration file:
usingUnityengine;usingSystem;usingSystem.IO;usingSystem.Xml.Serialization; Public classConfigfile:monobehaviour { Public StaticConfigFile Instance {Private Set;Get; } Public StaticClientconfigreference Cconfig;voidAwake () {Try{Readconfigfile (Application.streamingassetspath +"/configfile.xml"); }Catch(Exception ex) {Debug.logerror ("Read XML Failed! "+ ex. Message); } }voidReadconfigfile (stringFilePath) {Try{FileStream fs =NewFileStream (FilePath, FileMode.Open, FileAccess.Read); XmlSerializer xs =NewXmlSerializer (typeof(clientconfigreference)); Cconfig = xs. Deserialize (FS) asClientconfigreference; Fs. Dispose (); Debug.Log ("ConfigFile:"+ FilePath); }Catch(Exception ex) {Debug.logerror ("Read configfile Failed! "+ ex. Message); } }}//Configure class Public classclientconfigreference{ Public stringVediofullpathname;}
This only needs to be mounted in the scene and does not require any action.
Figure 15
Iv. shader used within the ball
The shader of the material used in sphere in 360SphereVideo.
Shader "Unlit/insidesphere"{Properties{//We have removed support forTexture Tiling/offset,//So make them notBe displayedinchMaterial Inspector _maintex ("Texture",2D) ="White"{} }Subshader{Cull Off Pass{Cgprogram #pragma vertex vert #pragma fragment Frag #include "Unitycg.cginc"struct AppData {float4 vertex: POSITION;//Vertex position Float2 UV: TEXCOORD0;//texture coordinate}; struct V2F {float2 UV: TEXCOORD0;//Texture coordinate float4 vertex: sv_position;//Clip Space position}; Uniform FLOAT4 _maintex_st; v2f Vert (AppData v) {v2f o; O.vertex = Mul (UNITY_MATRIX_MVP, V.vertex); O.uv.xy =Transform_tex(Float2 (1-v.uv.x, V.UV.Y), _maintex);returnO } sampler2d _maintex; Fixed4 Frag (v2f i): Sv_target{//Sample Texture and returnIt fixed4 col = tex2d (_maintex, I.UV);returnCol }ENDCG} }}
Interested in self-study.
Five, after packaging run test: 1. First use of the starry sky:
Resources can be downloaded at the following address of the article:
Look at the beautiful stars:
Figure 16
Figure 17
Figure 18
Figure 19
As you can see, this is a monocular effect, because the use of the Dapeng helmet, the effect of using the copy screen, the resolution is not correct, but in the direct run, does not affect the use and experience.
2. Look at the beauty.
By toggling the configuration file
<VediofullPathName>H:\Unity\UnitySay\360Video\360Demo\360VedioTest\Assets\StreamingAssets\猫耳娘SEASON 2.mp4</VediofullPathName>
To switch the video content.
Figure 20
Figure 21
Figure 22
Figure 23
Because the texture clarity is not very high, this needs to be improved.
There is also the use of the old version of OC, so it may crash. The crash log is as follows:
Check out the important stickers
==========OutputingSTACKTRACE==================Error:symgetsymfromaddr64, GetLastError:' attempted to access an invalid address. '(Address:6CF02036)6CF02036 (Oculusplugin)6CF03012 (Oculusplugin) ovr_setviewport6CF030D3 (Oculusplugin) Unitysetgraphicsdevice01040016(001) RECTT<Int>:: Contains01040058(001) RECTT<Int>:: Contains0104054B001) RECTT<Int>:: Contains100399D8 (mono) Mono_lookup_pinvoke_call100484DE (mono) mono_marshal_string_to_utf16 -CF9DD (mono) mono_inst_name -EF02C (mono) mono_set_defaults -EFE79 (mono) mono_set_defaults -F03d4 (mono) mono_set_defaults -f059d (mono) mono_set_defaults1005D872 (mono) Mono_runtime_invokexxFc47fe (001) Scripting_gchandle_get_target01077709(001) scriptingarguments:: AddString0107777E001) scriptingarguments:: AddString010777DC (001) scriptingarguments:: AddStringxxFB3462 (001) Reportscriptingobjectstransfer:: TransfertypelessxxFB3669 (001) Reportscriptingobjectstransfer:: TransfertypelessxxFB5988 (001) GetmonobehaviourinconstructorxxFB3B7C (001) Reportscriptingobjectstransfer:: Transfertypeless0109768B001) registerallownameconversioninderivedtypes0109785D001) registerallownameconversioninderivedtypes01050908(001) CallbackArray3<Std:: basic_string<Char,std:: Char_traits<Char>, Stl_allocator<Char -, -> >Const&, Awakefromloadqueue&, enum Loadsceneoperation:: Loadingmode>:: Invoke01050B0F (001) CallbackArray3<Std:: basic_string<Char,std:: Char_traits<Char>, Stl_allocator<Char -, -> >Const&, Awakefromloadqueue&, enum Loadsceneoperation:: Loadingmode>:: Invoke....==========END of STACKTRACE===========
That's it.
So, as you just said, you can use a later version of OC's 0.8.0 version of the packaged version.
Vi. Resources:
Cat Ear Video Address cloud disk Download: HTTPS://PAN.BAIDU.COM/S/1QYTVHFE
Star Video Cloud disk download: Https://pan.baidu.com/s/1c2rBNo8
More can address: http://vr.diyiapp.com/vrsp/
Project Download GitHub Address:
Https://github.com/cartzhang/ImgSayVRabc/tree/master/360Vedio/360Demo/360VedioTest
After the project is downloaded, you need to put the video file under Streamingassets, and then use the configuration file Configfile.xml to use it.
Project release address: After packaging, add a new video file directly under Streamingassets, and then use the configuration file Configfile.xml to use it. It's so simple and fast.
Decoder:
Http://pan.baidu.com/s/1o80fjXS
Http://pan.baidu.com/s/1mhVbk5U
OC 0.4.4 Plugin:
Http://pan.baidu.com/s/1gfA2TwR
AVPro Windows Media2.9.0:
Http://pan.baidu.com/s/1gfPvXyr
360 video game Package full address:
OC version 0.4.4 cloud disk address:
Http://pan.baidu.com/s/1jI8uDRC
OC version 0.8.0 cloud disk address:
Http://pan.baidu.com/s/1nv4QLuD
Vii. Reference
[1]. http://www.panduoduo.net/s/name/%E5%85%A8%E6%99%AF%E8%A7%86%E9%A2%91
[2]. http://bernieroehl.com/360stereoinunity/
[3]. http://download.videolan.org/pub/videolan/x264/binaries/win64/
[4]. Http://www.divx.com/zh-hans/software/download/start
[5].http://vr.diyiapp.com/vrsp/
"Introduction to VR"--360 Panorama video