- Home /
!IsNormalized error when skewing a Camera
Hello,
I need to skew the camera view, which can be done quite simply by modifying a Camera's worldToCameraMatrix. Here is the working code, for reference: using UnityEngine;
public class CameraSkew : MonoBehaviour { public float skewX = 0.2f; public float skewY = 0.2f;
void Start()
{
Matrix4x4 camMatrix = camera.worldToCameraMatrix;
camMatrix[0, 2] = skewX;
camMatrix[1, 2] = skewY;
camera.worldToCameraMatrix = camMatrix;
}
}
Problem is, when playing in the Editor, the skewed camera generates a constant flow of !IsNormalized errors (!IsNormalized(normal, 0.001f)), coming from EditorGUIUtility.cs line 380. Obviously I can't put my hands in the EditorGUIUtility script since it's locked in the UnityEditor assembly, so I don't know how to solve it. Any help would be really appreciated.
NOTES
Since this error appears to be related to Unity's Editor GUI, it happens only if you play in the Editor (thus rendering the Editor player useless, because even if you close the log panel the player stutters terribly). Regular builds are ok and log no errors.
Skewing the camera projectionMatrix instead than the worldToCameraMatrix property works ok, but I can't do that (if you skew the projection too much, Unity will not recognize correctly the visible objects, and thus will not render their shadows, which instead I need).