Version: 2019.3
LanguageEnglish
  • C#

RenderTexture.ConvertToEquirect

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Switch to Manual
public void ConvertToEquirect(RenderTexture equirect, Camera.MonoOrStereoscopicEye eye);

Parameters

equirectRenderTexture to render the equirect format to.
eyeA Camera eye corresponding to the left or right eye for stereoscopic rendering, or neither for monoscopic rendering.

Description

Converts the render texture to equirectangular format (both stereoscopic or monoscopic equirect). The left eye will occupy the top half and the right eye will occupy the bottom. The monoscopic version will occupy the whole texture. Texture dimension must be of type 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); } } }