Version: 2023.1

RenderTexture.ConvertToEquirect

切换到手册
public void ConvertToEquirect (RenderTexture equirect, Camera.MonoOrStereoscopicEye eye);

参数

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); } } }