Skip to content

Instantly share code, notes, and snippets.

@yoshitaka-xvi
Created September 5, 2017 04:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yoshitaka-xvi/47306adb930c806fd065c7aa8150ea03 to your computer and use it in GitHub Desktop.
Save yoshitaka-xvi/47306adb930c806fd065c7aa8150ea03 to your computer and use it in GitHub Desktop.
Unity 2017.2.0b10で、Immersiveヘッドセット向け描画でNearClipとFarClipを変更するためのUnityコンポーネント
using UnityEngine;
public class ProjectionMatrixSetter : MonoBehaviour {
Camera main;
[SerializeField]
float nearClip = 0.01f;
[SerializeField]
float farClip = 500.0f;
[SerializeField]
float fieldOfView = 102.0456f;
private void Start() {
main = Camera.main;
var projection = Matrix4x4.Perspective(fieldOfView, 1440.0f / 1440.0f, nearClip, farClip);
main.SetStereoProjectionMatrix(Camera.StereoscopicEye.Left, projection);
main.SetStereoProjectionMatrix(Camera.StereoscopicEye.Right, projection);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment