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