If you are not a VR game or app developer, you can choose to ignore the following content, this is not for ordinary users to see ~
If you have previously developed for Oculus Rift DK2 or Gear VR, there must have been thousands of grass and mud horses running back and forth in the heart. While Unity has supported VR applications and game development since the 5.1 release, the Oculus and unity developer forums have been a source of dissatisfaction with both sides ' shifting responsibilities.
Today, with the first generation of consumer mobile VR products Samsung Gear VR formally to the market, and the three major core equipment will be all in 2016 Q1 and Q2, Unity has always been with the times can not sit.
Today, Unity officially launched its 5.3 release with the first official VR development tutorial. Although not very detailed, but for the hard-pressed developers for a long time, is simply immortal music Buddha.
Talk less, let's have a look.
Part I UNITY VR Introduction
Unity has built-in support for several VR devices, and as for which devices, it's worth looking at Vrdevicetype, the enumeration variable.
This tutorial focuses on the Oculus series of VR devices, especially the Oculus Rift development Kit 2 (DK2) and the consumer version of Samsung Gear VR (which needs to be used in conjunction with the Samsung flag carrier mobile phone series, such as Galaxy S6, S6 edge,s6 Edge+,note 5). We are not concerned with the Note4 of the first generation of the pioneer version of Gear VR. So while some VR samples can still run on this device, the effect is certainly not that good. Brother, you should be careful not to use the Note4 and pioneer version of Gear VR.
Of course, unity will also support other VR headsets in the future, such as HTC VIVE. So when that day comes, this official tutorial will be updated as well. To be honest, unity and Oculus are really good friends.
If you want to learn more about VR headset, it is recommended to read the official manual.
Part II set up VR in Unity project
First, download the latest Oculus Runtime 0.8 or later (https://developer.oculus.com/downloads/ ), and the latest Unity5.3 or later (http/ Unity3d.com/get-unity/download ).
Enabling VR support in your project is easy, just choose Edit > Project settings> Player > Other Settings > Rendering in the Unity menu
Then tick "Virtual Reality supported" in the inspector.
At runtime, you can set it by using the UnityEngine.VR.VRSettings.enabled property in your code.
Part III previewing VR scenes in unity
When we have enabled VR support in Unity Editor and connected to the DK2 device, you can show the game's scene on DK2 by entering play mode. This can greatly improve the efficiency of development testing and iteration. Unlike before, developers do not need to compile and build an executable project to see the VR app or game adjustments. Of course, the old drivers will find that the previous binocular view has been replaced by a single view.
It is important to note that we do not need to create a camera for each eye, all cameras will be rendered in VR, except those that are assigned the render Texture (render texture). For the render textures, please refer here (http://docs.unity3d.com/Manual/class-RenderTexture.html ). Unity automatically optimizes the rendering of the camera, such as culling (culling) and shadow rendering, thus reducing performance consumption.
Topics related to VR can also be found in the Unity Manual (http://docs.unity3d.com/Manual/VROverview.html ) and Unity Scripting APIs (http:/ /DOCS.UNITY3D.COM/SCRIPTREFERENCE/30_SEARCH.HTML?Q=VR ) and find more information in.
Part IV software and hardware recommendations for VR development using unity
Because VR is a completely new medium, there are limitations of hardware and software in writing this tutorial, please refer to the following content.
1. Hardware
In order to get a good VR gaming experience, you need to achieve the desired frame rate on your headset. The minimum frame rate on the DK2 is 75fps, while the minimum frame rate on Gear VR is 60fps. If the frame rate is less than the above values, then the user will obviously feel the experience drop or even cause dizziness.
In addition to keeping the game frame rate above a certain value, the GPU on the player's computer must also be capable enough to output at the desired resolution with the refresh rate of the HMD head-mounted device panel. Taking DK2 as an example, it is necessary to do 75hz and 1920*1080. But if you want to develop applications for Oculus Rift CV1, then you have to achieve 90hz and 2160*1200 resolution, which is a huge challenge.
If you are using DK2, you need to make sure that the hardware device can output the image at the desired refresh rate at the desired resolution. Many laptops use discrete graphics and integrated graphics to switch, but these graphics cards are basically not enough to meet the above requirements, even 1920*1080 and 75hz can not be achieved, which will seriously affect the user experience. For this section, refer to the documentation for Oculus (https://support.oculus.com/hc/en-us/articles/201835987- Oculus-rift-development-kit-2-faq ), and Oculus PC Configuration Guide (https://www.oculus.com/en-us/oculus-ready-pcs/ )。
2. Software
Apple OS X OS: At this time we can still use OSX 10.9 OS with Oculus 0.0.5 runtime for development. But because Oculus officially suspended support for OS X, it is recommended that the powders do not make bricks, or use the Windows system honestly, using Unity's native VR capabilities.
Windows: Supports Windows 7,8,8.1 and Windows 10.
Android: Recommended with Android OS Lollipop 5.1 or later
Graphics driver: Make sure your graphics driver is up to date. You can use the Oculus Configuration utility to check if the graphics driver is adequate.
Oculus Runtime: To do VR development in Unity 5.3, use Oculus runtime 0.8 or later.
Part V VR Sample project
As part of this tutorial, we offer a VR sample project free of charge on the asset store. The project can support both DK2 and gear VR, and we will constantly update the sample project based on the iterations of the Oculus hardware, and will consider supporting other headset devices in the future.
The download link for the sample project is as follows:https://www.assetstore.unity3d.com/#!/content/51519
1. Example Scenarios
The main example scenarios are:
(1) Intro: Introduce the scene and teach the user to learn basic interactions
(2) Menus: Menu scene, you can choose mini games to play
(3) Flyer: A flying mini-game
(4) Maze: A desktop maze game
(5) Target Gallery: A corridor shooting game
(6) Target Arena: A 360-degree shooting arena game
What, unity is still very kind?
In addition to these complete mini-games, there are some example scenarios that cover some of the important concepts of this tutorial:
(1) Interactiveitem: Demonstrates how VR interacts with objects
(2) Renderscale: Demonstrates how Renderscale will affect image quality
(3) Basic example of reticle in RETICLE:VR
(4) Rotation: Demonstrates how an object responds to the head motion
(5) Touchpad: Demonstrates how to interact with the touch pad of Gear VR.
The key concepts covered are:
(1) Top-down desktop game mechanism
(2) The shooting game mechanism of the star Firefox style in the screen
(3) Corridor shooting game mechanism
(4) 360 degree corridor shooting game mechanism
(5) How to design the interface in VR
(6) How to design a stereoscopic interface
(7) Basic framework for interacting with objects in VR, including how to handle the switching of gaze focus
(8) Reticle Movement, zoom, shadow, etc.
(9) Motion based on head rotation
(10) How to use the Gear VR touchscreen, including tapping, double-clicking and swiping, or how to interact with the keyboard and mouse when using DK2.
(11) How to determine the device when Gear VR or DK2
(12) How to avoid the stun effect when rotating the camera around the center point
(13) How to realize the blanking of the camera
(14) The transition of camera blanking
(15) The pooling of objects
In addition to providing these concepts, we have provided some other useful examples to facilitate the reuse of VR developers:
(1) The blanking of the camera
(2) The transition of camera blanking
(3) A framework for interacting with objects in VR
(4) Hold to confirm the interaction
(5) reticle movement and zooming
(6) Platform-Independent text
(7) UI arrows indicating a specific direction
(8) Moving UI elements so that they are always oriented to the camera
(9) Tilt the UI object when interacting.
In order to run this project, developers need to use Unity5.3.0 or above, have a recommended configuration of the above hardware and software, a DK2 or with the appropriate Samsung mobile gear VR, while downloading Oculus Runtime 0.8 or later.
Part VI Oculus Unity Utilities
As a supplement, you can also download Oculus's official Oculus Unity Utilities (https://developer.oculus.com/downloads/ ) to implement some special features. It contains useful scripts and presets, such as how to adjust the IPD (pupil spacing) and so on.
This tutorial focuses only on native Unity VR development, so for Oculus Unity Utilities, refer to the Oculus official website for more information. (https://developer.oculus.com/downloads/game-engines/0.1.3.0-beta/Oculus_Utilities_for_Unity_5/)
Well, now you know what you need. This concludes the first tutorial and we will learn more about how to start VR in the following time.
Unity5.3 Official VR Tutorial-Series 1