Search Unity

[2D] Why do my sprites darken when I move my camera?

Discussion in '2D' started by CarterG81, Feb 16, 2014.

  1. CarterG81

    CarterG81

    Joined:
    Jul 25, 2013
    Posts:
    1,773
    I have a very simple tile map that is only 10x10.

    At any moment, only a few tiles are displayed, as each tile is 290x290.

    Whenever I move my camera using WASD, it seems to darken my entire tile map. The screen does not darken, as the GUI renders perfectly (The GUI is not moving, so obviously it renders flawlessly). When I stop moving, it returns to normal, which is quite a bit brighter.

    I have also noticed that whenever I move for longer than a second, my pixels actually blur from a single dot . to a line of stars, almost like traveling through space and seeing stars turn into lines.

    $208922.jpg


    I cannot actually show this effect in a screenshot, because the pixels never ACTUALLY change.
    I am not moving the camera very fast. The speed of the camera doesn't seem to effect it.

    Interesting enough, the blur is quite significant.
    A single pixel will seem to appear as a line of 4-5 pixels.



    Once more, I cannot show a screenshot as the entire tilemap (but NOT the GUI) darken. Yet the darkening tint is very significant.

    I do not understand why rendering is having problems like this. Most 2D engines will work without any problem, and even working with low level frameworks or directly with OpenGL does not result in these weird issues. I've experienced some flickering problems working the XNA in the past, but nothing as bad as this. It isn't game-breaking, but it is quite annoying to me.
     
  2. CarterG81

    CarterG81

    Joined:
    Jul 25, 2013
    Posts:
    1,773
    I realize I need to provide more information about the camera.
    I figured this was a common problem, with an easy solution.

    Here is my camera move code.

    Code (csharp):
    1.  
    2. using SpriteTile;
    3.  
    4. public class MoveCamera : MonoBehaviour
    5. {
    6.  
    7.     public float moveSpeed = 10.0f;
    8.     // Use this for initialization
    9.     void Start () {
    10.    
    11.     }
    12.    
    13.     // Update is called once per frame
    14.     void Update ()
    15.     {
    16.         Tile.MoveCamera (new Vector2(Input.GetAxis ("Horizontal") * moveSpeed * Time.deltaTime,
    17.                                  Input.GetAxis ("Vertical") * moveSpeed * Time.deltaTime));
    18.  
    19.     }
    20. }
    21.  
     
  3. MasterSubby

    MasterSubby

    Joined:
    Sep 5, 2012
    Posts:
    252
    Your best bet is to post this in Answers. That's where questions like this belong anyways (you'll get a much faster response) . I'd help you if I could though, but never had any issues like this. Are you using Unity2D? Perhaps a plugin asset? Maybe someone has used whatever you have before, and has encountered the issue. If so, post in the topic for that plugin in the Assets Forum, or post a bug report to Unity if you suspect it is one.
     
  4. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    Welcome to the modern era of graphics displays, where the response time is quite laggy. The pixels that make up your screen can only change between intensities at a given rate, which is much slower than 60hz. It especially is evident when you have high contrast such as going from white to black. It can take several frames for the screen to actually transition from a white pixel to a black or vice versa, or even for colored pixels. As a result, as soon as you scroll or move objects, it appears like a blur because you're still seeing traces of the intensities that used to exist from previous frames. The reason it seems to darken in your situation is because not only does the trailing edge leave a fading-out blur of intensities, but also the leading edge of your moving object takes several frames to come to full brightness, and thus starts off appearing much dimmer than it should. Especially with small objects, if your object isn't big enough or spans enough pixels then it will seem to be constantly in a state of partly faded in or out, and never has enough sustained pixels to maintain a high intensity at any time.

    Unfortunately most displays are like this these days. Very few have a fast enough response time to change pixel values at 60hz or better. Most monitors and HDTV's have this problem. Unfortunately for those of us who want to make scrolling games or games with objects that move fairly fast, this puts a total damper on things. I had to give up on my side-scrolling shootemup, which was fairly fast moving, because the amount of blur was horrible and made it hard to focus my eyes and creates headaches/nausea. It's not like it used to be back in the day with simple monitors that could actually refresh at the proper rate. It's always been an issue with most LCD/TFT display panels. I have a 27" high end iMac which you would think would be high quality enough to not have this issue but it does. It's very disappointing for 2D game development in particular. In 3D where you're moving into the screen mostly it doesn't seem to be quite as much of an issue because objects don't move sideways quite as fast, except towards the edges of the screen which isnt where most of your attention is. In 2D when you scroll the entire screen blurs.

    There is literally nothing you can really do to fix this. What I came up with was to try to a) make your objects very sharp or over-sharp, b) try to avoid high contrast pixel colors, c) try to use more animation to differentiate the frames and avoid streaks, d) dont move the objects as fast. In my case this still didn't fix it and having to halve the scroll speed just sucked the life out of the game so I had to axe it.
     
    Last edited: Feb 16, 2014
  5. CarterG81

    CarterG81

    Joined:
    Jul 25, 2013
    Posts:
    1,773
    What a major bummer. I thought it was just Unity, but this makes a lot of sense and I have never tried such high contrast with other engines or frameworks.


    I might have a solution. In the end, there is a good chance I will make each star have a flicker effect anyways. So while the display causes them to dim/brighten as the camera moves/stops, it may not matter as it may look natural with the effect.

    Zooming in doesn't seem to change things. Whether they are 1x1 blue pixels amidst a mostly black background, or zoomed in 10x over, the dimming is the same. The scrolling speed doesn't fix things either, but instead ranges from the entire screen flickering (very slow scroll) to just the 1x1 pixels dimming (faster scroll).


    The line blurring is perfectly fine for the game, since it is a space game. I will try a different color for the millions of stars in the background if the flickering effect doesn't resolve it.
    In the end, it is only a map which rarely needs to be moved (and is also uncommon to access), so at least I won't have to scrap my game even if I can't change a darn thing about it.

    Thank you again!


    (Image must be native resolution (CLICK IT) to be viewed properly.
    $HelloWorld.png