- Home /
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);
}
}
Answer by andrei_kushner · Mar 22, 2020 at 06:28 PM
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;
Answer by Baggers_ · May 13, 2020 at 01:56 PM
@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.
Your answer
Follow this Question
Related Questions
Problems using OnRenderObject() and Graphics.DrawMeshNow() 2 Answers
Camera / Graphic bug with 2D Sprites [Please help me solve this] 4 Answers
How to maintain sharp lines (pixel-like effect) from small textures on 3D assets 2 Answers
Render to texture with disabled camera allways generates error 0 Answers