Hi everyone,
I’m trying to render a cubemap with Camera.RenderToCubemap, but I’m running into an issue. The faces of the resulting cubemap don’t seem to be in the right place (see the screenshot below).
Everything seems to be upside down and the sky/ground are swapped.
I’m rendering the cubemap like this:
using UnityEngine;
public class RenderTest : MonoBehaviour {
public Camera CameraToUse;
public RenderTexture CubemapTarget;
public void Update()
{
if (Input.GetKeyDown(KeyCode.R)) Test();
}
public void Test()
{
if (!CubemapTarget)
{
RenderTextureDescriptor desc = new RenderTextureDescriptor();
desc.autoGenerateMips = false;
desc.bindMS = false;
desc.colorFormat = RenderTextureFormat.ARGB32;
desc.depthBufferBits = 24;
desc.dimension = UnityEngine.Rendering.TextureDimension.Cube;
desc.enableRandomWrite = false;
desc.volumeDepth = 1;
desc.msaaSamples = 8;
desc.sRGB = true;
desc.dimension = UnityEngine.Rendering.TextureDimension.Cube;
desc.width = 512;
desc.height = 512;
CubemapTarget = new RenderTexture(desc);
}
CameraToUse.RenderToCubemap(CubemapTarget);
}
}