Created
September 18, 2018 10:17
-
-
Save SoylentGraham/a1590c45b1fa64a1934975ca2b44a52d to your computer and use it in GitHub Desktop.
Hacky record-360/equirect in unity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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