equirect | 渲染等距矩形格式的目标 RenderTexture。 |
eye | 与立体渲染的左眼或右眼相对应的相机眼,或与单目渲染都不对应。 |
将渲染纹理转换为等距矩形格式(立体或单目等距)。左眼将占据上半部分,右眼将占据下半部分。单目版本将占据整个纹理。纹理尺寸必须为 TextureDimension.Cube 类型。
using UnityEngine; using UnityEngine.Rendering;
public class CreateEquirect : MonoBehaviour { public RenderTexture cubemap; public RenderTexture cubemap2; public RenderTexture equirect; public bool renderStereo = true; public float stereoSeparation = 0.064f;
void LateUpdate() { //assume cubemap and cubemap2 are rendered using Camera.RenderToCubemap() for left/right eyes
if (equirect == null) return;
if (renderStereo) { cubemap.ConvertToEquirect(equirect, Camera.MonoOrStereoscopicEye.Left); cubemap2.ConvertToEquirect(equirect, Camera.MonoOrStereoscopicEye.Right); } else { cubemap.ConvertToEquirect(equirect, Camera.MonoOrStereoscopicEye.Mono); } } }