Arrangement of cubemap faces from RenderToCubemap

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

I’ve got the same issue when I created a cubemap with RenderTextureDescriptor.
But it works fine when you create it like that:

cubeMapRT = new RenderTexture(width, height, depth,  RenderTextureFormat.ARGB32);
cubeMapRT.dimension = TextureDimension.Cube;

@andrei_kushner You star, thank you for reporting that here.

I’ve reproduced this issue and reported it to Unity. I’ve made the repro available here https://github.com/Bouncyrock/potential-cubemap-descriptor-bug showing the working and failing case. I’ll link the unity bug here once it’s confirmed by them.