0
나는 '픽셀'폰으로 구글의 백일몽 게임을하고있다. 나는 디스토션 쉐이더를 가지고 놀 수있는 방법을 찾고 있는데, 왜곡 쉐이더는 각 렌즈를 RenderTexture
으로 렌더링하여 렌즈 왜곡을 매칭시킵니다. 유니티 백일몽 왜곡 쉐이더
UnlitTexture.shader
을 찾을 수
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
}
StereoRenderEffect.cs
에 다음 코드를 발견했다. 그러나은 #if !UNITY_HAS_GOOGLEVR || UNITY_EDITOR
을 의미하므로 편집기에서 실행할 때만 작동합니다. 앱이 실제 기기에서 실행될 때 동일한 작업을 수행 할 수있는 방법을 찾고 있지만 찾지 못했습니다. 누군가가 어디를보아야하는지 알고 있습니까?
이 코드는 편집기에서 실제 빌드의 표시를 시뮬레이트합니다. 그래서 GVR SDK는 이미 장치 제작을 위해 그것을하고 있습니다. 이 작업을 수동으로 수행 할 필요가 없습니다. –
내 필요에 맞게 'StereoRenderEffect' 셰이더를 수정하고 싶습니다. 두 번째 전체 화면 쉐이더를 추가하는 것은 너무 비싸므로 그 쉐이더를 조정해야합니다. –