【问题标题】:Unity Daydream distortion shaderUnity Daydream 失真着色器
【发布时间】:2017-01-16 17:27:52
【问题描述】:

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

我在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 所暗示的那样,它仅在编辑器中运行时才有效。当应用程序在实际设备上运行但找不到它时,我正在寻找一种方法来做同样的事情。有人知道去哪里看吗?

【问题讨论】:

  • 这段代码是模拟实际构建在编辑器中的显示。所以 GVR SDK 已经在为设备构建做这件事了。您无需手动执行此操作
  • 我知道,我只是想根据需要修改StereoRenderEffect 着色器。添加第二个全屏着色器太贵了,所以我想调整那个。

标签: unity3d google-vr daydream


【解决方案1】:

Daydream 和 Unity 目前无法实现这一点。

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多