Search Unity

Screen position out of view frustum bug?

Discussion in 'Scripting' started by smitchell, Sep 5, 2014.

Thread Status:
Not open for further replies.
  1. smitchell

    smitchell

    Joined:
    Mar 12, 2012
    Posts:
    702
    I keep getting this error:
    Screen position out of view frustum (screen pos 481.894531, 488.203125, 10.000000) (Camera rect 0 0 546 431)
    UnityEngine.Camera:ScreenToWorldPoint(Vector3)


    Which is really weird, because it's random; it only just started popping up.. And it only pops up in orthographic projection.

    Here's the code it cries about, but it's pretty standard code. It shouldn't be throwing this error surely?
    Code (CSharp):
    1. Vector3 mp = Input.mousePosition;
    2. mp.z = -Camera.main.transform.position.z;
    3.  
    4. mousePos = Camera.main.ScreenToWorldPoint (mp);
     
  2. RHD

    RHD

    Joined:
    Mar 30, 2009
    Posts:
    719
    This has started happening to me too and I can't figure out why.
     
  3. Mistale

    Mistale

    Joined:
    Apr 18, 2012
    Posts:
    173
    Just a tip; I had the same problem, and in my case it was because one my scripts accidentally set both the near and the far plane of the camera to the same value, and therefore the frustrum had no volume, it was infinitely thin.
     
  4. RHD

    RHD

    Joined:
    Mar 30, 2009
    Posts:
    719
    Someone else mentioned this but in this case I can't see anything that looks wrong.
    I did have two cameras in the scene originally and thought that might be it but deleting the extra one only made a temporary fix.
    In this case its a bug connected with the Unity Pro water.cs script but I can't figure out how as the same prefab works fine in other scenes.

    Actually it works fine in this one, its just the error messages that are the worry.

    Its an odd thing.
    Here are my camera settings to be sure.
    Thank you for the tip, I shall watch that one.
     

    Attached Files:

  5. smitchell

    smitchell

    Joined:
    Mar 12, 2012
    Posts:
    702
    When I was getting the error my near and far clips were not the same, I never figured out what was going on. It just fixed itself one day, or I did without knowing.
     
  6. RHD

    RHD

    Joined:
    Mar 30, 2009
    Posts:
    719
    I'm right there with you!
    My project was working perfectly, and I changed nothing, and then I got these Red Errors.
    The other thing is, that normally Red Errors stop you doing anything, but in this instance they don't.
    I do think its a Unity thing.
    I will submit a bug and hope they get back to me.
    Thank you smitchell
     
  7. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    In the console in the editor, enable the on error pause button.
     
    Cogent likes this.
  8. RHD

    RHD

    Joined:
    Mar 30, 2009
    Posts:
    719
    You mean that one?
    OK, what happens next?
    Thank you console-pause.jpg
     
  9. RHD

    RHD

    Joined:
    Mar 30, 2009
    Posts:
    719
    I play the thing with "error pause" enabled but it doesn't stop at any point.
    Also the error doesn't stop me doing anything as far as I have been able to tell yet.
    Its very strange
     
  10. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Please report it as a bug :)
     
  11. RHD

    RHD

    Joined:
    Mar 30, 2009
    Posts:
    719
    Done.
     
  12. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    More bug reports the better. Even if it happens to you more than once, it will get seen. If other people are also encountering the issue, they should report it too even if you have, because the report contains different os, hardware etc and so on... it's all helpful. Thanks!
     
  13. majklCZ

    majklCZ

    Joined:
    Jun 29, 2013
    Posts:
    3
    Has anyone solve this problem? the problem is that in Unity3D?

    Screen position out of view frustum (screen pos 0.000000, 0.000000, 1.947270) (Camera rect 0 0 0 0)
    UnityEngine.Camera:ViewportToWorldPoint(Vector3)
    NGUITools:GetWorldCorners(Camera, Single, Transform) (at Assets/NGUI/Scripts/Internal/NGUITools.cs:1575)
    NGUITools:GetWorldCorners(Camera, Single) (at Assets/NGUI/Scripts/Internal/NGUITools.cs:1527)
    UIPanel:get_worldCorners() (at Assets/NGUI/Scripts/UI/UIPanel.cs:574)
    UIPanel:OnDrawGizmos() (at Assets/NGUI/Scripts/UI/UIPanel.cs:1771)
    UnityEditor.DockArea:OnGUI(
     
  14. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,363
    I bump this as i had reports fro Sky Master 3.0 beta about the same issue and i managed to recreate it a few times in the latest version too, but is extremely rare, though it does happen and is very strange.

    It happens so rarely on my side that is very hard to debug as well.

    It seems to be related to the water shader i use, when the LOD changes especially to a new one (but i am not sure it was not coincidence that happened mostly at that point)

    Is there any development on this ?
     
  15. Amon

    Amon

    Joined:
    Oct 18, 2009
    Posts:
    1,384
    I get this also. I hadn't seen the error in a while but 15 minutes ago when I fired up unity I got this frustum error. Previous to that nothing.

    The project was brand new, nothing imported or changed.

    There is one thing though that I did prior to starting this project in unity. I shut down the android adb service on my laptop. It was locked by another service so when plugging in my Samsung Galaxy Tab A I couldn't get the debugging permissions popup to show on the Tablet to allow it trusted debug permissions.

    I restarted adb and plugged my Galaxy Tablet in to the usb port of my laptop and the popup appeared on the tablet, i ticket the agree/allow button and that was that sorted.

    I then fired up unity3d 5 (VERSION 5.2.3p1 ) and started a new project. Once the unity editor appeared I saw the Frustum error.

    I'm putting the adb restart here because it truly is the only change i made.
     
  16. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,363

    I managed to recreate the issue when i chose a 2D view in the editor with Unity water on. The issue was caused by the reflections script, in a custom render function and was solved by checking if the input to the rendering was not zero vector. So it has something to do with the camera orientation to the horizon, some infinite must be going in at certain angles and conditions.
     
  17. Nazowa

    Nazowa

    Joined:
    Oct 30, 2017
    Posts:
    15
    This has a solution ?

    Assertion failed: Screen position out of view frustum (screen pos 795.000000, 0.000000, 1000.000000) (Camera rect 0 0 795 415)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)
     
  18. blenderbug

    blenderbug

    Joined:
    Nov 16, 2014
    Posts:
    3
    "Screen position out of view frustum" error only shows up when at least 2 of the 3 rotation vectors are 0 on the mainCamera. Here's the fix inside of Water.OnWillRenderObject()
    Code (CSharp):
    1.             Camera reflectionCamera, refractionCamera;
    2.             CreateWaterObjects(cam, out reflectionCamera, out refractionCamera);
    3.  
    4.             // find out the reflection plane: position and normal in world space
    5.             Vector3 pos = transform.position;
    6.             Vector3 normal = transform.up;
    7.      
    8.             //avoid frustum error ugh
    9.             bool FrustumError = false;
    10.             int zeroVectors = 0;
    11.             if (cam.transform.rotation.x == 0)
    12.                 zeroVectors++;
    13.             if (cam.transform.rotation.y == 0)
    14.                 zeroVectors++;
    15.             if (cam.transform.rotation.z == 0)
    16.                 zeroVectors++;
    17.             if(zeroVectors >1){
    18.                 FrustumError = true;
    19.             }
    20.  
    21.             // Optionally disable pixel lights for reflection/refraction
    22.             int oldPixelLightCount = QualitySettings.pixelLightCount;
    23.             if (disablePixelLights)
    24.             {
    25.                 QualitySettings.pixelLightCount = 0;
    26.             }
    27.  
    28.             UpdateCameraModes(cam, reflectionCamera);
    29.             UpdateCameraModes(cam, refractionCamera);
    30.  
    31.             // Render reflection if needed
    32.             if (mode >= WaterMode.Reflective && !FrustumError)
    33.             {
    34.                 //end of avoid frustum error ugh
    35.  
    36.                 // Reflect camera around reflection plane
    37.                 float d = -Vector3.Dot(normal, pos) - clipPlaneOffset;
    38.                 Vector4 reflectionPlane = new Vector4(normal.x, normal.y, normal.z, d);
    39.  
     
  19. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,091
  20. PrintasticGraphics

    PrintasticGraphics

    Joined:
    Jun 28, 2023
    Posts:
    1
    I had this problem when creating my Canvas for Start Screen. I solved this by changing Render Mode from Screen Space - Overlay to Screen Space - Camera, and attaching the Main Camera object in Render Camera. Capture.PNG
     
Thread Status:
Not open for further replies.