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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Screen space - camera canvas has 'choppy' UI when camera moves.

Discussion in 'UGUI & TextMesh Pro' started by notgrantcawood, Aug 22, 2014.

  1. comocc

    comocc

    Joined:
    May 10, 2014
    Posts:
    2
    I also encountered the problem.
    I found a cause and the solution.
    In my case, I have been set the value of the position X of the camera and the canvas are 10000(<-too large).
    So I tried to reduce the value to 5000.
    After this change, the problem became never occur.
     
  2. Cinfa

    Cinfa

    Joined:
    Apr 22, 2018
    Posts:
    1
    Same problem with 2018.3.11f1
    TextMeshPro is shaky when camera moves.
    Also, RectTransformUtility.ScreenPointToLocalPointInRectangle gives all kind of wrong results while camera is moving.
     
    boogi505 likes this.
  3. xsocomx

    xsocomx

    Joined:
    Apr 18, 2018
    Posts:
    34
    I had this exact same problem. There seems to be an issue with world/screen space canvases when they are moving.
    I fixed this by rendering the UI on a separate camera that wasn't moving.
     

    Attached Files:

  4. kirbyderby2000

    kirbyderby2000

    Joined:
    Apr 28, 2017
    Posts:
    35
    Was having the same problem and stumbled into this thread, just want to share how I fixed it on my end.

    My screen space canvas was way too close to the near clipping plane of its rendering camera. I pushed my screen space canvas about 0.5f from the camera's near clipping plane distance and the flickering stopped.

    Untitled-3.png
     
  5. fmoo

    fmoo

    Joined:
    May 31, 2015
    Posts:
    15
    Having this problem too. Not sure if it regressed or what since reports seemed pretty quiet for a couple of years. Tried all the workarounds (adjusting plane distance, parenting the canvas on the camera, various script hacks, etc) and nothing worked short of just not using Screen Space - Camera and using Screen Space - Overlay instead.

    Edit: Unity team was able to reproduce my issue and is now tracking it as a bug. You can upvote it here: https://issuetracker.unity3d.com/is...screen-space-camera-jitters-when-camera-moves
     
    Last edited: Jul 19, 2020
  6. mactinite77

    mactinite77

    Joined:
    Feb 14, 2012
    Posts:
    25
    Hopefully this helps people googling this in the future.
    This problem was keeping me up for weeks.. finally found a solution for my issue.

    background: I’m trying to get my canvas rendered in screen space, but was getting weird jitters when the camera would pan (using cinemachine & pixel perfect camera & URP)
    solution(s): Firstly, cinemachine pixel perfect does not round the camera position. Hugely important. So I wrote a simple script all it does is call the function RoundToPixel on the pixel perfect camera in LateUpdate and rounds the game objects position to the result (docs here: https://docs.unity3d.com/Packages/c...l.Rendering.Universal.PixelPerfectCamera.html)
    also important: this script needs to be after cinemachine in the script execution order settings.

    once that was done, the camera would snap to nice pixel increments (eg. 4.32 instead of 4.322222~), and my screen space UI no longer jitters.

    Here is that simple script:
    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.Experimental.Rendering.Universal;
    3.  
    4. /// <summary>
    5. /// Snap the object to the pixel grid determined by the pixel perfect camera.
    6. /// </summary>
    7. public class SnapToPixelGrid : MonoBehaviour
    8. {
    9.  
    10.     public PixelPerfectCamera ppc;
    11.  
    12.     private void LateUpdate()
    13.     {
    14.         transform.position = ppc.RoundToPixel(transform.position);
    15.     }
    16. }
     
    Last edited: Jun 16, 2021
    ROBYER1 likes this.
  7. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,446
    Shook this is still an issue with Unity in 2021
     
  8. EnricoBC

    EnricoBC

    Joined:
    May 4, 2014
    Posts:
    20
    Tried most of the proposed solutions here but only creating a different camera to render the UI worked, I'm using Unity 2020.3.12f1.
     
  9. JustinAHS

    JustinAHS

    Joined:
    Feb 18, 2013
    Posts:
    33
    2022-03-07, problem still exists.

    I'm not using any text, just rendering a dot as a reticle.
    I'd rather not create an entirely new camera just for that (and additional cameras are expensive on the Quest 2)

    It makes no sense that the reticle's position on the screen changes for a fraction of a second.
    It should always be on the same position on the screen.
     
  10. CGDever

    CGDever

    Joined:
    Dec 17, 2014
    Posts:
    154
    Unity 2021.3.1f1, still exist. Ohhh.... :/
     
  11. Pinwizkid

    Pinwizkid

    Joined:
    Feb 3, 2021
    Posts:
    6
    Just wanted to give you a shout out - EVERY solution that was posted in this thread and all other threads related to this issue did not work for me until this code. So thanks for sharing!

    Just for some added guidance to anyone that stumble upon this, you have to attach this script to your main camera (not cinema machine brain, the vcam, or your UI). I had to make one change:

    -Change "using UnityEngine.Experimental.Rendering.Universal;" to "using UnityEngine.U2D;" (I'm on Unity 2020)

    Also can confirm that Cinemachine needs to run before SnapToPixelGrid in script execution order.