Unity Skybox Weirdness

If you haven't checked out our recent World Trade Center model, you should click on that link now! Given the crazy amount of security we had to go through to gain access to the top floor of the building, including signing our lives away to a >100-page security compliance document, we will probably have the best panorama from the top floor of the building for as long as the building is closed to the general public.

One of these days--maybe if our cool boss Dave makes a final selection for Floored's Catered Lunch Programâ„¢ (might he be reading this?)--we will write about how these panoramas are generated. Meanwhile, we thought we'd point out one weird thing about Unity's skybox renders.

Assume that our secret+magical sauce has given us a beautiful panorama for a model...

Since we rely on the Unity engine to render our models across devices, our panoramas have to be displayed in models via Unity Skyboxes. Here, the term "skybox" refers to the special construct that allows 3D worlds to render pretty scenes at a distant using images.

Imagine a 3D world similar to one shown below.

3D world with viewpoint marked by black dot at center 3D world with viewpoint marked by black dot at center
(Image source: Wikipedia article on 'Cube Mapping').

If the objects are sufficiently far away, we could replace the objects with flat images. This helps reduce the rendering complexity of the 3D world while creating an illusion that the surroundings remain in 3D. To the observer at the viewpoint at center, the surroundings near the horizon are identical whether they are in 2D or in 3D, as shown in the image below.

3D world with viewpoint enclosed in a box 3D world with viewpoint enclosed in a box
(Image source: Wikipedia article on 'Cube Mapping')

For this reason, once we have an equirectangular panorama for a model, we project the panorama into a cube by generating six images that correspond to the six sides of the skybox cube--up, down, front, back, left, and right. These images are viewed by an observer at the position indicated by the black dot in the 3D environment, so intuitively, the assignment of images to each of the six sides should the order shown below.

Intuitive assignment of image positions on an unfolded cube Intuitive assignment of image positions on an unfolded cube
(Image source: Wikipedia article on 'Cube Mapping')

Counterintuitively, Unity's skybox convention has the left and right assignment swapped as indicated below.

Unity's assignment of image positions on an unfolded cube Unity's counterintuitive assignment of image positions on an unfolded cube
(Image source: Wikipedia article on 'Cube Mapping')

This results in an odd situation where the correct assignment of our skybox images for the World Trade Center panorama has the left and right labels swapped.

Skybox image assignment for World Trade Center panorama Skybox image assignment for World Trade Center panorama

Isn't this weird?

After some head-scratching, it turns out that the reason this happens is because the Unity game engine that we rely upon operates on a left-handed coordinate system. By Unity's arbitrary convention, 'left' is assigned to the +X direction and 'right' is assigned to the -X direction, as displayed in the image below.

Unity left-handed coordinate system Unity's left-handed coordinate system

We think that this is a pretty convincing explanation for the left-right weirdness. However, if you have an even better idea, do let us know!