Search Unity

!IsNormalized errors when applying skew to camera worldToCameraMatrix

Discussion in 'Editor & General Support' started by ENDEther, Oct 5, 2012.

  1. ENDEther

    ENDEther

    Joined:
    Oct 5, 2012
    Posts:
    1
    Hi all,

    I was wondering if anyone could help me with an error that I’m seeing repeat endlessly in the Console Window when applying a skew factor to a camera's worldtoCameraMatrix.

    I am currently doing this with the following code, which I've attached to my camera GameObject.

    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. [RequireComponent(typeof(Camera))]
    5.  
    6. public class SkewCamera : MonoBehaviour
    7. {
    8.     public float m_Skew = 0.5f;
    9.  
    10.     public void Start()
    11.     {
    12.         // Just an arbitrary rotation
    13.         transform.eulerAngles = new Vector3(45.0f, 45.0f, 0.0f);       
    14.     }
    15.  
    16.     public void LateUpdate()
    17.     {
    18.         Matrix4x4 NewWorldToCameraMatrix = transform.worldToLocalMatrix;
    19.  
    20.         Matrix4x4 SkewMatrix = Matrix4x4.identity;
    21.         SkewMatrix[2, 0] = m_Skew;
    22.  
    23.         NewWorldToCameraMatrix *= SkewMatrix;
    24.  
    25.         camera.worldToCameraMatrix = NewWorldToCameraMatrix;   
    26.     }
    27. }
    This causes a flood of the following error message in the Console Window:

    !IsNormalized (normal, 0.001f)

    With the stack:
    Code (csharp):
    1. !IsNormalized (normal, 0.001f)
    2. UnityEditor.EditorGUIUtility:INTERNAL_CALL_RenderGameViewCameras(Rect, Rect, Boolean, Boolean)
    3. UnityEditor.EditorGUIUtility:RenderGameViewCameras(Rect, Rect, Boolean, Boolean) (at C:\BuildAgent\work\14194e8ce88cdf47\Editor\MonoGenerated\Editor\EditorGUIUtility.cs:330)
    4. UnityEditor.GameView:OnGUI() (at C:\BuildAgent\work\14194e8ce88cdf47\Editor\Mono\GameView\GameView.cs:521)
    5. System.Reflection.MonoMethod:InternalInvoke(Object, Object[], Exception)
    6. System.Reflection.MonoMethod:Invoke(Object, BindingFlags, Binder, Object[], CultureInfo)
    7. System.Reflection.MethodBase:Invoke(Object, Object[])
    8. UnityEditor.HostView:Invoke(String, Object) (at C:\BuildAgent\work\14194e8ce88cdf47\Editor\Mono\GUI\DockArea.cs:228)
    9. UnityEditor.HostView:Invoke(String) (at C:\BuildAgent\work\14194e8ce88cdf47\Editor\Mono\GUI\DockArea.cs:221)
    10. UnityEditor.DockArea:OnGUI() (at C:\BuildAgent\work\14194e8ce88cdf47\Editor\Mono\GUI\DockArea.cs:649)
    11.  
    This seems to be very similar to the issue reported here:

    http://forum.unity3d.com/threads/131936-ERR-!IsNormalized.-Camera-matrix-change

    But there does not seem to be a resolution at present.

    Can anyone help me apply a camera skew factor without provoking this error? I am running Unity 3.5.6f4, by the way.

    Thanks in advance!
     
  2. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    Having the same problem here. You found any solution? Initially, I solved it by skewing the camera projection, but in that case I have to move the camera to actually show the skewed projection, and shadows are thus not rendered (because Unity thinks they're outside the camera view).

    EDIT: also, this issue seems to appear only while playing in the Unity Editor. No errors are logged while playing a regular build
     
    Last edited: Dec 2, 2012