Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

[SOLVED] Screen position out of view frustum

Discussion in 'Scripting' started by grimmy, Sep 20, 2010.

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

    ioanna316

    Joined:
    Apr 14, 2014
    Posts:
    11
    we experience the very similar problem with screen pos equal to MAX_FLOAT numbers (that's what those long numbers are) - and for us, this started happening once we moved from 2017.1 to 2017.4.15f1 and 16f1 - LTS.
    Will try the workaround that you suggest, looks like a reasonable explanation for the bug.
     
  2. JeltzProstetnic

    JeltzProstetnic

    Joined:
    Dec 3, 2018
    Posts:
    4
    Using 2018.3.0f2 - Happens to me as soon as I split up layers between my near and far cameras (using oculus integration). Interestlinly enough it worked for a while even with three cameras, but atm. I have to set all three cameras to render everything to be able to continue coding. error message should maybe be converted to warning? because besides the constant console spamming it didn't seem to have side effects as far as i could tell.

    What I attemt to do:
    Floating point precision problems are the reason I use floating origin and different cameras. Working on an open world space sim. Near cam from 0.1 to 2000 (so I can see my hands), medium cam from 2000 to 1 million (for medium sized objects like large asteroids, stations, battleships) and 1 million to 1e9 for planets, suns, moons. My plan would be that the near cam doesn't need to render planets ever, because at 2km you are already deep in the atmosphere / close to landing. I would have a short cutscene for the landing while I switch between space and ground sim. And at the same time the far cam doesn't ever have to render small objects as non of them will be visible in a distance of > 1 million m by design. With two cameras I cannot do this properly. If anyone has a better idea I't be interested to know. In the meantime I will wait for an update and hope it gets fixed.
     
  3. IOT_Boy

    IOT_Boy

    Joined:
    Jan 9, 2015
    Posts:
    4

    Saved me
     
    xucian likes this.
  4. JeltzProstetnic

    JeltzProstetnic

    Joined:
    Dec 3, 2018
    Posts:
    4
    I'm not even using a mouse, and I'm working on a PC, so the above answer does nothing for me...
    I believe there is something instable in the unity framework or oculus integration package. Especially since this sometimes works for a very short time before subtly crashing something.
     
  5. vlab22

    vlab22

    Joined:
    Nov 22, 2012
    Posts:
    17
    Happens to me because I've done erratic camera movement.
    In my situation, my camera was a child of a gameobject with a rigidbody with 0 mass, not only zero but that "infinity ZERO".

    After add a impulse to this rigidbody, it goes "to infinity and beyond" and this bugs camera's ScreenPointToRay methods.

    So a attempt solution is to analyse the camera movement.

    Unity 2018.2.12f1 (64-bit)
    Windows 10
     
    cabanel likes this.
  6. Vivien_Lynn

    Vivien_Lynn

    Joined:
    May 17, 2019
    Posts:
    19
    This worked for me, thank you.

    Edit:
    The Error comes back after a while. So what I do at the moment:
    Build my Window-Layout -> Save my Layout
    When the Error pops up, I Revert Factory Settings and then load my saved Layout.
    (Sorry for everybody that looks for a real solution, but I learned to live with it, since it seems like this is not harmful)
     
    Last edited: Feb 6, 2020
  7. Meceka

    Meceka

    Joined:
    Dec 23, 2013
    Posts:
    420
    We also have encountered the same issue with planar reflections. This comment by Maki in a blog site has fixed the issue for us and the reflection effect looks completely the same.

    Edit: This fix may cause visual problems to the reflection if there are objects underground.
     
    Last edited: Dec 17, 2019
    Reahreic likes this.
  8. Roman_Keivan

    Roman_Keivan

    Joined:
    May 31, 2019
    Posts:
    21
    thanks dude
     
  9. dato818

    dato818

    Joined:
    Dec 8, 2019
    Posts:
    3
    I solved this issue by changing the resolution of BG picture(sprite) that was lower than a general resolution of UI.
     
  10. russisunni

    russisunni

    Joined:
    Oct 26, 2019
    Posts:
    8
    Pavito's suggestion worked. thanks!
     
  11. rinekso

    rinekso

    Joined:
    Feb 14, 2018
    Posts:
    1
    i solve it, when i change my code, in my code i change size of camera when i click something, and thats why showing this error, my input mouse is out side from camera.

    my suggest is make a delay before you change your size camera or dont change size your camera out of your mouse input.

    my case is only for changing camera attribute.
     
  12. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,084
    Not true in Unity 2019.3.11 and also this code breaks water completely if camera in menu is set to (0,0,0)
     
  13. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,084
    With Water from Standard assets this error is logged all the time with certain camera rotation - very hard to reproduce but I did a loop checking all rotations and found the values. This is how broken reflection camera looks like:

    Unity package: https://www.dropbox.com/s/gtkno2dypmoqqlo/waterBug.unitypackage?dl=0

    What's annoying is that the bug sometimes makes massive fps drop. Imagine playing the game, rotating camera all the time and hitting that unfortunate rotation all the time.
     
  14. diliupg

    diliupg

    Joined:
    Jan 23, 2018
    Posts:
    45
    This happens most time when you are using the mouse in you game/software and the camera is looking at the mouse and then you pause or move out of the Game screen and move to the editor to tweak something. Add a lin of code to sto tracking the mouse when it is off the game screen and you'll be fine.
     
  15. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,084
    No, in my case mouse does nothing.
     
  16. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,133
    Hmm this is appearing for me again on Camera Render.
    Unity can you just throw an error with exactly the cause if it is coder's fault AND if there is any chance, solve the error instead by adjusting some coordinate into the frustum when out by some tiny amount.

    I have had this error over the years for various reasons, sometimes unknown.
    Many other people too.

    If source is closed then reasons for errors must be explicit.
     
  17. Reahreic

    Reahreic

    Joined:
    Mar 23, 2011
    Posts:
    254
    When specifically using the Water4 asset from unity in really large scenes (+100KM) The reflection camera's position and projection matrix is being pushed outside of floating point precision bounds.

    While not perfect what worked for me was making the below edits to Water4's PlanarReflection.cs file

    In:
    Code (CSharp):
    1. //... about half way down #175
    2.  
    3. //reflectCamera.transform.position = cam.transform.position; <- Replace
    4.  
    5. //Limit camera positions to a little less than float.maxValue
    6. float xPos = Mathf.Clamp(cam.transform.position.x, -float.MaxValue + 100, float.MaxValue - 100);
    7. float yPos = Mathf.Clamp(cam.transform.position.y, -float.MaxValue + 100, float.MaxValue - 100);
    8. float zPos = Mathf.Clamp(cam.transform.position.z, -float.MaxValue + 100, float.MaxValue - 100);
    9. reflectCamera.transform.position = new Vector3(xPos, yPos, zPos);
    10.  
    11. //... a few lines later
    12.  
    13. //reflectCamera.transform.position = newpos; <- Replace
    14. xPos = Mathf.Clamp(newpos.x, -float.MaxValue + 100, float.MaxValue - 100);
    15. yPos = Mathf.Clamp(newpos.y, -float.MaxValue + 100, float.MaxValue - 100);
    16. zPos = Mathf.Clamp(newpos.z, -float.MaxValue + 100, float.MaxValue - 100);
    17. reflectCamera.transform.position = new Vector3(xPos, yPos, zPos);
    Another area that may need work is the Matrix4X4 for the reflectCamera.projectionMatrix but it seems to work well once i limited the cameras position.
     
  18. Wawwaa

    Wawwaa

    Joined:
    Sep 30, 2017
    Posts:
    164
    So, in editor, after clicking on the play button, if the mouse is inside the view area I get a bunch of this exception:

    Screen position out of view frustum (screen pos 728.000000, 393.000000) (Camera rect 0 0 1389 667)
    UnityEngine.SendMouseEvents:DoSendMouseEvents(Int32)

    Just appears 12 - 16 times in console and no more.

    Interesting thing is if I leave the mouse outside the view area, I don't get this message. Absolutely, no exception.

    I am pretty much sure that I don't do screen to world raycasts or any other related stuff to get this exception.

    It is harmless in the editor. But, in build, I think, script execution may be halted and some of my game objects stop generating.

    Any ideas?
     
  19. Kassem_m31

    Kassem_m31

    Joined:
    Apr 17, 2020
    Posts:
    25
    Im here five years later but do u mean the scale of the camera
     
  20. shieldgenerator7

    shieldgenerator7

    Joined:
    Dec 20, 2015
    Posts:
    39
    My Camera's Field of View was
    NaN
    because the formula I used to set it sometimes divided by 0.
    I prevented it from ever dividing by 0 and it solved the problem.
     
  21. shieldgenerator7

    shieldgenerator7

    Joined:
    Dec 20, 2015
    Posts:
    39
    No, the camera has a Size attribute when its Projection attribute is set to Orthographic.
    It determines how tall the camera is from top to bottom in World space.
    upload_2020-11-18_6-40-37.png
     
  22. Lynxbird

    Lynxbird

    Joined:
    Aug 19, 2018
    Posts:
    15
    I had a same problem where errors would happen when I would switch to 2D view in 3D game (when editing UI).

    This solved it for me.

    Disabling standard asset "WaterProDaytime" fixed the issue. I will just use different water asset.

    If you want to fix water asset, go to Water.cs and on line 75 under
    // find out the reflection plane: position and normal in world space
    Vector3 pos = transform.position;
    Vector3 normal = transform.up;

    add:

    //avoid frustum error
    int zeroVectors = 0;
    if (cam.transform.rotation.x == 0)
    zeroVectors++;
    if (cam.transform.rotation.y == 0)
    zeroVectors++;
    if (cam.transform.rotation.z == 0)
    zeroVectors++;
    if (zeroVectors > 1)
    {
    return;
    }


    Script will work normally in game but it will not spam you when you are in 2D view.


    If water asset is not your problem and you are desperate, I would suggest you to test disabling assets one by one until you find one that is causing errors for you.
     
    Last edited: Dec 4, 2020
  23. chaitanyabhardwaj

    chaitanyabhardwaj

    Joined:
    Jun 18, 2019
    Posts:
    3
    Same problem, I zoomed out too much I guess and got this error.
    Solution : Just close the scene window and reopen it. Worked for me!
     
  24. bdspvl

    bdspvl

    Joined:
    Jul 15, 2017
    Posts:
    5
     
  25. bdspvl

    bdspvl

    Joined:
    Jul 15, 2017
    Posts:
    5
    OK people.. it says when doing Prototype 1 training to use 2018.4 whatever. I did as they said and I got the same thing all you are saying. Now I had the effect when trying the turn speed. I did try the delete camera and and replaced the camera and it fixed that. Now since I didn't save anything I did another test. I updated to the current version 2019.4 and using the same original program did the test again. It has no problems so far and truck reacts to Speed and Turn Speed changes with no problems! AND no flying into space! Suggest everyone give this a try and let me and everyone know what happens! Barry S.
     
  26. artemkay851

    artemkay851

    Joined:
    Jul 19, 2020
    Posts:
    1
    Just set field of view to 60
     
  27. Deleted User

    Deleted User

    Guest

    Also I got that error, but somehow I got the idea to removed the camera and replaced with another one and it worked. I hope I helped someone.
     
  28. bradakan

    bradakan

    Joined:
    Feb 17, 2014
    Posts:
    4
    Had this issue today and this fixed it.
     
  29. Sercova

    Sercova

    Joined:
    Mar 9, 2017
    Posts:
    3
    I added this validation and the problem was solved.
    Code (CSharp):
    1.         Vector3 mousePos;
    2.    
    3.         if (Mathf.Abs(Mouse.current.position.ReadValue().x) == Mathf.Infinity || Mathf.Abs(Mouse.current.position.ReadValue().y) == Mathf.Infinity)
    4.             mousePos = Vector3.zero;
    5.         else
    6.             mousePos = Camera.main.ScreenToWorldPoint(new Vector3(Mouse.current.position.ReadValue().x, Mouse.current.position.ReadValue().y, -10.0f));
    7.  
    In my case the error occurs when using Camera.main.ScreenToWorldPoint and when running in the Game tab in Simulator mode, when the mouse pointer is outside the boundaries of the game screen using the new InputSystem. The main camera is controlled by Cinemachine.

    This is the conclusion I drew after reading the whole thread and that none of the proposed alternatives worked in my case.

    Maybe it is not the same validation that you need, but the idea is to validate the infinite values of the mouse pointer position. I hope this is useful to someone else.
     
    Last edited: May 3, 2021
  30. Antony-Blackett

    Antony-Blackett

    Joined:
    Feb 15, 2011
    Posts:
    1,772
    I'm getting this error on my live iOS builds: Here's the error. you can see the point is well inside the frustum. I don't understand why it happens or how to fix it.

    Log:
    Screen position out of view frustum (screen pos 612.090942, 1002.181824) (Camera rect 0 0 1536 2048) UnityEngine.SendMouseEvents: DoSendMouseEvents(Int32)
     
  31. pitchblende

    pitchblende

    Joined:
    Jan 9, 2020
    Posts:
    71
    This absolutely did help someone - me. Thank you! I rotated my Standard Assets Water plane by 0.00001 degrees about X and the error disappeared.
     
    MikeBastien likes this.
  32. Kamyker

    Kamyker

    Joined:
    May 14, 2013
    Posts:
    1,084
    This bug also happens with URP Boat Attack water.. Old bugs never go away, eh?
     
  33. BurAndBY

    BurAndBY

    Joined:
    Jun 8, 2020
    Posts:
    5
    Seems like you had the script that uses MainCamera tag and it don't understand which Main Camera to use.
     
  34. superjava250609

    superjava250609

    Joined:
    Apr 27, 2021
    Posts:
    2
    Hey Try Giving Some Error From Your Script(Syntax Error)Than Correct it That Worked For Me But When I Walk On Slopes The Error Shows Up.
    And This Can Also Be If Something Is Playing In Void Update But It Should Be Played In Void Awake Like In My Script I Made First Person Character With Controller Movement As Well As Keyboard Input But The Controller Input is Made Like This That You Can Only Run It With Void Awake or They Will Change The Character's Position Every Frame And At Last It Ends Like This Error.
     
    Last edited: Aug 25, 2021
  35. moonlightgames2021

    moonlightgames2021

    Joined:
    May 30, 2021
    Posts:
    3
    have not found any solution for this yet, i have tried all the purposed solutions here.
    i am using Unity version 2021.1.20f1.
    As few said it either switch of the 2d view in scene or disable the water object to stop getting this annoying issue in edior. if anyone found a solution please post here.
     
  36. amarquessbr

    amarquessbr

    Joined:
    Nov 3, 2021
    Posts:
    1
    this workin for me, but I just duplicate tha main camera and deleted the auto-created camera as well
    tks!!!
     
  37. xelanoimis

    xelanoimis

    Joined:
    Oct 29, 2013
    Posts:
    38
    I think the standard asset water code can't handle the reflection when looking from the side of the water plane, when you won't see it anyway. The error was produced even in 3d views when perfectly aligning the camera to look from the side. If your water plane is flat on XZ plane, use the view window axes widget to test.

    Previously suggested code (checking the rotation) worked for me, but I think the correct fix is to check for this unsupported alignment. So, to fix it edit Water.cs and add this:

    if (cam.transform.up == transform.up)
    return;
     
  38. nathan2019spence

    nathan2019spence

    Joined:
    Jan 21, 2022
    Posts:
    16
    Thank you I was getting worried when my canvas went out of wack....I just did windows/ layout/ default...
     
  39. XianGrim

    XianGrim

    Joined:
    Jan 14, 2014
    Posts:
    7
    I had this error pop up in my VR project after exiting PlayMode one time. Ever since it's a constant thing.
    What "fixed" it for me was dropping my VR rendering from Multi-Pass to Single-pass and it seemed to have fixed that issue.
     
  40. Booyaka_619

    Booyaka_619

    Joined:
    Sep 16, 2019
    Posts:
    2
    Hey guys!
    I'm working on a game and everything runs okay on the editor, but when I build the game on Android and ios platforms, sometimes the screen goes into blue and I receive this error:
    BSB1.png BSB2.jpg

    Screen position out of view frustum (screen pos 690.000000, 808.000000) (Camera rect 0 0 828 1792)
    UnityEngine.Camera:ScreenPointToRay(Vector2, MonoOrStereoscopicEye)
    UnityEngine.Camera:ScreenPointToRay(Vector3, MonoOrStereoscopicEye)
    UnityEngine.Camera:ScreenPointToRay(Vector3)
    UnityEngine.SendMouseEvents:DoSendMouseEvents(Int32)

    And Sometimes this one:

    Screen position out of view frustum (screen pos 675.000000, 167.000137) (Camera rect 0 0 1170 2532)
    UnityEngine.RectTransformUtility:pointInRectangle(Vector2, RectTransform, Camera, Vector4)
    UnityEngine.UI.GraphicRaycaster:Raycast(Canvas, Camera, Vector2, IList`1, List`1)
    UnityEngine.UI.GraphicRaycaster:Raycast(PointerEventData, List`1)
    UnityEngine.EventSystems.EventSystem:RaycastAll(PointerEventData, List`1)
    UnityEngine.EventSystems.PointerInputModule:GetTouchPointerEventData(Touch, Boolean&, Boolean&)
    UnityEngine.EventSystems.StandaloneInputModule:processTouchEvents()
    UnityEngine.EventSystems.StandaloneInputModule:process()

    The error keeps appearing in every frame with different screen positions.

    I've also included an explanation of my project if you want to understand it better:
    My project's scale is too big, and everything is 50 times bigger than a normal object so I've been forced to set the far clip to 6000. I'm using Cinemachine virtual cameras that instantiate during playtime. The main camera is in the perspective mode, Doozy UI and Lean touch + are used in the project, as well as Lean joystick from the Lean GUI package. The lights are baked and we have a light probe on the scene. My unity version is 2020.3.21f1. And the project is not Hololens or VR.

    I've read everything on the internet about this issue and done whatever I could but my problem still remains.
    Here is what I've done so far:
    1. Remove the camera's tag and make it "Untaged"
    2. Increase camera's a near clip
    3. Debug camera rect, camera scale, camera size, FOV, near clip, far clip but none of
    them change when the bug occurs
    4. Removed cinemachine from my project
    5. Make sure that my camera does not instantiate during run time
    6. Make sure that the main scene added to the build setting
    7. Remove the main camera and create another one
    8. Remove light baking and light probe
    9. Remove every light from the scene
    10. Downgrade the unity to 2019.4.28f1

    I think the problem may be from lean touch, especially the joystick script.
    There are some functions like
    `RectTransformUtility.WorldToScreenPoint`
    and `RectTransformUtility.ScreenPointToLocalPointInRectangle`
    that I'm suspicious to them and tried to check the pointer and screen values before calling them but it didn't help also.

    Could anyone help me with this?
    https://forum.unity.com/threads/blue-screen-bug-screen-position-out-of-view-frustum.1249480/
     
  41. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    8,991
    had this issue if MainCamera rotation was 0,0,0 (no error if added small rotation, 0.001f)
    and camera script was doing something with ViewportToScreenPoint values

    upload_2022-5-20_13-21-30.png
     
  42. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,133
    There are so many versions of when this error occurs here!
    But please report a bug if reproduceable. I do not think this is an acceptable error at any time and Unity should not report it.
    A warning might be suitable if it is a function call, but could return zero etc not just an error
     
  43. FelipeWagner_WildLife

    FelipeWagner_WildLife

    Joined:
    Sep 14, 2018
    Posts:
    2
    If your game camera is fine might be good to check the scene camera. My problem was with this one. upload_2022-7-29_0-29-56.png
     
  44. unity_jLjQJfizuJNJ4A

    unity_jLjQJfizuJNJ4A

    Joined:
    Mar 1, 2020
    Posts:
    1
    Hi Guys! In my case it was a Shader material, I just ajusted the size and now is working =]
     
Thread Status:
Not open for further replies.