SteamVR_SphericalProjection.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132
  1. using System;
  2. using UnityEngine;
  3. [ExecuteInEditMode]
  4. public class SteamVR_SphericalProjection : MonoBehaviour
  5. {
  6. public void Set(Vector3 N, float phi0, float phi1, float theta0, float theta1, Vector3 uAxis, Vector3 uOrigin, float uScale, Vector3 vAxis, Vector3 vOrigin, float vScale)
  7. {
  8. if (SteamVR_SphericalProjection.material == null)
  9. {
  10. SteamVR_SphericalProjection.material = new Material(Shader.Find("Custom/SteamVR_SphericalProjection"));
  11. }
  12. SteamVR_SphericalProjection.material.SetVector("_N", new Vector4(N.x, N.y, N.z));
  13. SteamVR_SphericalProjection.material.SetFloat("_Phi0", phi0 * 0.0174532924f);
  14. SteamVR_SphericalProjection.material.SetFloat("_Phi1", phi1 * 0.0174532924f);
  15. SteamVR_SphericalProjection.material.SetFloat("_Theta0", theta0 * 0.0174532924f + 1.57079637f);
  16. SteamVR_SphericalProjection.material.SetFloat("_Theta1", theta1 * 0.0174532924f + 1.57079637f);
  17. SteamVR_SphericalProjection.material.SetVector("_UAxis", uAxis);
  18. SteamVR_SphericalProjection.material.SetVector("_VAxis", vAxis);
  19. SteamVR_SphericalProjection.material.SetVector("_UOrigin", uOrigin);
  20. SteamVR_SphericalProjection.material.SetVector("_VOrigin", vOrigin);
  21. SteamVR_SphericalProjection.material.SetFloat("_UScale", uScale);
  22. SteamVR_SphericalProjection.material.SetFloat("_VScale", vScale);
  23. }
  24. private void OnRenderImage(RenderTexture src, RenderTexture dest)
  25. {
  26. Graphics.Blit(src, dest, SteamVR_SphericalProjection.material);
  27. }
  28. private static Material material;
  29. }