Created
March 21, 2018 08:54
-
-
Save korinVR/b7d6fc67a54fcf2d2f4e5940d298aa7a to your computer and use it in GitHub Desktop.
Use Vive Stereo Rendering Toolkit on Unity standard VR support
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEngine.XR; | |
namespace HTC.UnityPlugin.StereoRendering | |
{ | |
public class UnityXRParamFactory : IDeviceParamFactory | |
{ | |
public int GetRenderWidth() | |
{ | |
return XRSettings.eyeTextureWidth; | |
} | |
public int GetRenderHeight() | |
{ | |
return XRSettings.eyeTextureHeight; | |
} | |
public Vector3 GetEyeSeperation(int eye) | |
{ | |
const float Ipd = 0.06567926f; | |
if (eye == 0) | |
{ | |
return new Vector3(-Ipd / 2f, 0, 0); | |
} | |
else | |
{ | |
return new Vector3(Ipd / 2f, 0, 0); | |
} | |
} | |
public Quaternion GetEyeLocalRotation(int eye) | |
{ | |
return Quaternion.identity; | |
} | |
public Matrix4x4 GetProjectionMatrix(int eye, float nearPlane, float farPlane) | |
{ | |
switch (eye) | |
{ | |
case 0: | |
return Camera.main.GetStereoProjectionMatrix(Camera.StereoscopicEye.Left); | |
case 1: | |
return Camera.main.GetStereoProjectionMatrix(Camera.StereoscopicEye.Right); | |
} | |
return Matrix4x4.identity; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment