- Home /
Fixed with Unity 4.x (can't remember which version, but lower than 4.2)
!IsNormalized error when skewing a Camera
EDIT: This issue was fixed in Unity 4.X (can't remember the exact version, but lower than 4.2)
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).
hello,
After scanning your this question,I am amazing that I have faced the same problems with you.This problem has puzzled me for several days. If possible,Would like to help me or give me some advises.Any help would be really appreciated.
$$anonymous$$y E-mail is :zh_heng@foxmail.com. Looking forward to your reply
Follow this Question
Related Questions
How do I calculate a view matrix using Matrix4x4.LookAt? 2 Answers
Camera movement doesn't work in Unity (but does in builds) 0 Answers
Can't stop camera from rotating on Z Axis 1 Answer
Taking screenshot from Camera in Editor 2 Answers
Flipping projection matrix problem: It flips everything but the Skybox. How do I fix this? 1 Answer