Skip to content

Instantly share code, notes, and snippets.

@SoylentGraham
Created September 18, 2018 10:17
Show Gist options
  • Save SoylentGraham/a1590c45b1fa64a1934975ca2b44a52d to your computer and use it in GitHub Desktop.
Save SoylentGraham/a1590c45b1fa64a1934975ca2b44a52d to your computer and use it in GitHub Desktop.
Hacky record-360/equirect in unity
// use this shader https://github.com/SoylentGraham/PopUnityCommon/blob/master/BlitCubemapToEquirect.shader
// and utils in here https://github.com/SoylentGraham/PopUnityCommon/blob/master/PopTexture.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraRecorder : MonoBehaviour {
public Cubemap RenderTargetCubemap;
public RenderTexture RenderTargetEquirect;
public Material CubemapToEquirect;
[FilePath(FilePathAttribute.PathType.Folder)]
public string SaveFolder = "d:/Capture/";
int FrameCounter = 0;
public string CubemapUniform = "Cubemap";
Camera GetCamera()
{
return HmdManager.Instance.GetCamera();
}
void Update ()
{
var Cam = GetCamera();
Cam.RenderToCubemap( RenderTargetCubemap);
CubemapToEquirect.EnableKeyword("USE_CUBEMAP");
CubemapToEquirect.SetTexture(CubemapUniform,RenderTargetCubemap);
Graphics.Blit( null, RenderTargetEquirect, CubemapToEquirect );
var Filename = SaveFolder + FrameCounter + ".png";
PopX.Textures.DoSaveTextureToPng( RenderTargetEquirect, Filename, false );
FrameCounter++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment