0

我正在使用“Pixel”手机为 Google 的白日梦开发一款游戏。我正在寻找一种使用失真着色器的方法,该着色器将每只眼睛渲染为 aRenderTexture以匹配镜头失真。

我在StereoRenderEffect.cs

using UnityEngine;

/// @cond
[RequireComponent(typeof(Camera))]
[AddComponentMenu("GoogleVR/StereoRenderEffect")]
public class StereoRenderEffect : MonoBehaviour {
#if !UNITY_HAS_GOOGLEVR || UNITY_EDITOR
  private Material material;

  private Camera cam;

  private static readonly Rect fullRect = new Rect(0, 0, 1, 1);

  void Awake() {
    cam = GetComponent<Camera>();
  }

  void Start() {
    material = new Material(Shader.Find("GoogleVR/UnlitTexture"));
  }

  void OnRenderImage(RenderTexture source, RenderTexture dest) {
    GL.PushMatrix();
    int width = dest ? dest.width : Screen.width;
    int height = dest ? dest.height : Screen.height;
    GL.LoadPixelMatrix(0, width, height, 0);
    // Camera rects are in screen coordinates (bottom left is origin), but DrawTexture takes a
    // rect in GUI coordinates (top left is origin).
    Rect blitRect = cam.pixelRect;
    blitRect.y = height - blitRect.height - blitRect.y;
    RenderTexture oldActive = RenderTexture.active;
    RenderTexture.active = dest;
    Graphics.DrawTexture(blitRect, source, fullRect, 0, 0, 0, 0, Color.white, material);
    RenderTexture.active = oldActive;
    GL.PopMatrix();
  }
#endif  // !UNITY_HAS_GOOGLEVR || UNITY_EDITOR
}

它让我找到了UnlitTexture.shader造成失真的 . 但是,正如#if !UNITY_HAS_GOOGLEVR || UNITY_EDITOR 暗示的那样,它仅在编辑器中运行时才有效。当应用程序在实际设备上运行但找不到它时,我正在寻找一种方法来做同样的事情。有人知道在哪里看吗?

4

1 回答 1

0

目前,Daydream 和 Unity 无法做到这一点。

不过,我相信您仍然可以使用 Cardboard 和 Unity 做到这一点。

于 2017-01-17T19:21:02.963 回答