# Easiest way to rotate a cubemap?

Unity's automatic texture importer cubemap generation is quite handy, but it produces cubemaps that are 90 degrees off of the direction I need them to face.

I used an editorscript to apply to cubemaps to a skybox, create a rotated camera, and render the skybox to a new cubemap, but the new cubemap's rotation is the same as the old one.

I would love to use the rendering approach, as it will allow me to bake in a tint as well. Any ideas why it isn't working?

I just figured out how to rotate a skybox for my own purposes, check this out:

Create a copy of the built in `skybox cubed.shader` and rename it (available from here).

Change line one to have the name "Rotated Skybox Cubed" (or whatever)

Modify the vert function (around line 35) to the following:

``````v2f vert (appdata_t v)
{
v2f o;
o.vertex = mul(_Rotation, v.vertex);
o.vertex = mul(UNITY_MATRIX_MVP, o.vertex);
o.texcoord = v.texcoord;
return o;
}

``````

Create a C# script called RotateSkybox like so:

``````using UnityEngine;

[RequireComponent(typeof(Skybox))]
public class RotateSkybox : MonoBehaviour {

void Start () {
// Construct a rotation matrix and set it for the shader
Quaternion rot = Quaternion.Euler (60f, 0f, 0f);
Matrix4x4 m = Matrix4x4.TRS (Vector3.zero, rot, new Vector3(1,1,1) );
GetComponent<Skybox>().material.SetMatrix ("_Rotation", m);
}

}

``````

Slap that baby on your camera and you're laughin! (hopefully)

Note: I've simply hardcoded the rotation I needed into the RotateSkybox script as `rot`, from you're description you'd either want +/- 90 in the y component instead.

Please follow the links for a tutorial on rotating the cubemap in any axis as per users convenience.