Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Some objects have the wrong texture randomly for a single frame at a time

Discussion in 'General Graphics' started by MSplitz-PsychoK, Dec 30, 2015.

  1. MSplitz-PsychoK

    MSplitz-PsychoK

    Joined:
    May 16, 2015
    Posts:
    1,278
    This has been a problem for a long time and I've gathered a lot of information on it, but I'll try to keep this post brief.

    The problem was first observed in Unity 4, but we didn't test or gather information about it yet.

    (5.1.3f) We have a 3D scene with a 2D UI over it. Originally, the problem was that some 3D objects would flash white for a single frame. After a lot of testing, I believed those objects were receiving a solid white texture instead of the usual texture for their material.

    (5.3.0f4) Now sometimes certain UI elements will use a sprite used by another UI element for a single frame (example, a menu itself will use a button graphic stretched to the dimensions of the menu). When objects flicker like this, be it 3D or UI, all similar objects that come from the same prefab will flicker (4 menu's open, one for each player, all 4 menu's will show the same incorrect sprite for a single frame).

    I do not have the right to post screenshots of this game, nor am I able to predict when the frame will flicker to capture it. This problem does not relate to model scale. Any help is greatly appreciated!
     
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,396
    Do the UI elements have an empty texture slot? We fixed a bug where this would happen when no texture was assigned, I think the fix is in 5.3.1.
     
  3. MSplitz-PsychoK

    MSplitz-PsychoK

    Joined:
    May 16, 2015
    Posts:
    1,278
    None of our UI elements are missing sprites, though most of the bugged frames tend to be around when we instantiate a prefab with a UI.Image and immediately change it's sprite.

    Though aside from UI, we still see 3D objects flash white and I strongly believe the shaders are working correctly, but are using a solid white texture for the bugged frame. When one object flashes, every object using the same shader will also flash, even when those objects are using different materials with different textures.

    This is a very important problem that needs to be solved. There is very little information about it online, and we've tried everything suggested (such as changing model import scale). Our clients will absolutely not accept anything that appears buggy in any way and we're rapidly approaching our deadline.
     
  4. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,396
    Have you tried the latest patch 5.3.1p1?
    If that does not work create a bug report with an example that has the problem and post the case id here so I can take a look.
     
  5. MSplitz-PsychoK

    MSplitz-PsychoK

    Joined:
    May 16, 2015
    Posts:
    1,278
    I can't even reproduce this bug consistently on our current two projects, I'm not going to have the time to figure out how to reproduce it in a new project.

    I will try 5.3.1 on Monday, but this bug has been around since Unity 4 so I'm not very hopeful.
     
  6. MSplitz-PsychoK

    MSplitz-PsychoK

    Joined:
    May 16, 2015
    Posts:
    1,278
    It looks like the bug occurs more often when the framerate is bad. The UI only started flickering in 5.3, so I believe that might be fixed in 5.3.1, but the 3D objects will still be a problem.
     
  7. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,396
    The bug I mentioned was only for UI sprites, it did not involve 3d objects. Sounds like something else. If this problem has existed since 4 it seems odd that no one else has reported it. I would take a close look at your project and see what your doing. Maybe try and break it down to a smaller scene with just the problem. Have you seen the issue on multiple machines?
     
  8. MSplitz-PsychoK

    MSplitz-PsychoK

    Joined:
    May 16, 2015
    Posts:
    1,278
    We've seen the issue on multiple machines, but with the same hardware. The bug is so difficult to reproduce, we can only do it by accident by playing the game for a while, so it may be hard to narrow the problem down to a smaller scene. I did some more tests with shader code, and I think it's possible ShaderForge might be giving us some really intense specular values for those bugged frames.

    Thanks for the help, I'm going to try 5.3.1 and a few more shader tweaks before I seek more help.
     
    karl_jones likes this.
  9. daggada2

    daggada2

    Joined:
    Sep 8, 2015
    Posts:
    9
    Yes, I've seen this too, and it's driving me insane.

    I'm able to repro by calling Destroy() from script, on pretty much any 3D object in the scene (doesn't seem to matter which). Basically every time I call Destroy(gameObject); I see many of the sprites on my HUD flicker for 1 frame, they appear to be randomly "shuffling", such that sprites from one UI Image appear as a sprite in a totally different and unrelated Image, for one frame. And then they snap back to their normal proper sprites. It feels like some weird video memory offset thing or something....

    Edit: Posting example images.

    So here's the original HUD, 1 frame before I am about to Destroy a scene object:
    http://i.imgur.com/GTaYxLP.png

    Now, on the same frame Destroy is called on one of those enemy gameObjects:
    http://i.imgur.com/drt8LFD.png

    I see the 'flicker' of different sprites on my UI Image components. It looks kind of like the index offsets inside an atlas jump for a frame or something. The frame immediately after will return the first image, and will proceed as normal until the next call to Destroy.

    I haven't notice a pattern to the images that get shuffled. These all happen to be on the same Canvas though. Although those symbols hovering above the enemies are on a separate Canvas, and I've seen those flicker as well...

    I've tried making sure the imported sprites don't have mip maps generated. And I've tried setting pixel perfect on and off in the Canvas. Doesn't appear to be related to the problem so far...

    Now, I'm able to stop the flicker if I don't destroy the 3D object, but obviously that's not a great option...

    I want to say I've seen this issue for pretty much every version of Unity since 4.6.
     
    Last edited: Feb 1, 2016
  10. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    8,396
    This should be fixed in 5.3.2p1
     
  11. daggada2

    daggada2

    Joined:
    Sep 8, 2015
    Posts:
    9
    Just grabbed 5.3.2p1. Yep seems to have fixed it! Thanks Karl!
     
    karl_jones likes this.
  12. Hemanth_DJ

    Hemanth_DJ

    Joined:
    Aug 12, 2017
    Posts:
    13
    Screen/Canvas flickering/blinking is happening when gazed down on a UI Window,
    Issue happens only in the emulator and Hololens not in Editor ,please help couldn't find reason for the issue.I'm Using unity 2017.1.2 with Visual studio 2017
     
  13. carldevelopsforcoffee

    carldevelopsforcoffee

    Joined:
    Sep 20, 2017
    Posts:
    19
    Getting flickering on UI over sprite renderers. In my scene, both ui images and sprite renderers come from the same atlas. My UI also has a part where I mask a raw image with a unique texture (not part of atlas). So far I couldn't find a fix yet, I currently am on Unity 2018.1.3f1