Camera in Unity

When you wear the HoloLens on your head, it becomes the center of your holographic world. The Unity Camera component will automatically handle stereoscopic rendering and will follow your head movement and rotation when your project has "Virtual Reality Supported" selected with "Windows Holographic" as the device (in the Other Settings section of the Windows Store Player Settings).

However, the following settings should be manually applied to the cameras in your app to optimize it for your holographic experience:

  • Mixed Reality Rendering
  • Positioning the Camera
  • Clip Planes

Note: These settings need to be applied to the Camera in each scene of your app.

By default, when you create a new scene in Unity, it will contain a Main Camera GameObject in the Hierarchy which includes the Camera component but does not have the above settings properly applied.

Mixed reality rendering

The default settings on the Unity Camera component are for traditional 3D applications which need a Skybox like background as they don't have a real world. HoloLens gives you the ability to mix your real world with your application.

In holographic applications, the real world should appear behind everything the camera renders so we set the camera background to be transparent (in HoloLens, black renders as transparent) instead of a Skybox texture.

  1. Select the Main Camera in the Hierarchy panel
  2. In the Inspector panel, find the Camera component and change the Clear Flags dropdown from Skybox to Solid Color
  3. Select the Background color picker and change the RGBA values to (0, 0, 0, 0)

Positioning the Camera

It will be easier to lay out your app if you imagine the starting position of the user as (X: 0, Y: 0, Z: 0). Since the Main Camera is tracking movement of the user's head, the starting position of the user can be set by setting the starting position of the Main Camera.

  1. Select Main Camera in the Hierarchy panel
  2. In the Inspector panel, find the Transform component and change the Position from (X: 0, Y: 1, Z: -10) to (X: 0, Y: 0, Z: 0)

Camera in the Inspector pane in Unity

Clip planes

The near and far clip planes can be set on the Camera component.

  1. Select the Main Camera in the Hierarchy panel
  2. In the Inspector panel, find the Camera component Clipping Planes and change the Near textbox from 0.3 to .85

Multiple Cameras

When there are multiple Camera components in the scene, Unity knows which camera to use for stereoscopic rendering and head tracking by checking which GameObject has the MainCamera tag.

See also