Sometimes it can be useful to flip an image. One way this can be achieved is by inverting the camera’s projection matrix. By inverting the projection matrix, all draw calls will apply an inverted projection matrix to the mesh being rendered which will cause the mesh to be rendered upside down.
The script below demonstrates how to do that.
Place the following script on your scene’s camera.
public class ProjectionMatrixInverter : MonoBehaviour
// Use this for initialization
void Start ()
Camera c = this.transform.GetComponent();
Matrix4x4 proj = c.projectionMatrix;
proj.m11 = -proj.m11; // Invert the vertical field of view.
proj.m13 = -proj.m13;
c.projectionMatrix = proj;
GL.invertCulling = true;
You must remember to invert the culling when inverting the projection matrix. If you don’t, you will get a result like the one below.
The reason for this is because the order in which your vertices are defined will not change when you invert the projection matrix.
The GPU will incorrectly cull your mesh if the winding/culling mode isn’t inverted after inverting the projection matrix. The above example shows how the winding order should be inverted when inverting the projection matrix.