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

Bug Visual glitch with 2D lighting

Discussion in '2D' started by myazuid, Oct 28, 2022.

  1. myazuid

    myazuid

    Joined:
    Jan 29, 2019
    Posts:
    26
    Hello,

    I've had this problem in my game for about a year now but it is quite intermittent so it hasn't been top of my list, but it does crop up every now and then and beta testers are now reporting it.

    Basically there is a black shape that appears on screen and sort of glides across it and behind the shape is an extremely bright light. Some testers called it "the UFO issue" haha.

    Here's a screenshot of it in action:



    I've added a little arrow to make it clear what it is I'm referring to. But all of that light you can see is driven by this artifact and it moves across screen and then disappears.

    Can anyone help with addressing this? It happens at runtime as well as in editor (when you're actively using the UI, in the same way that a shader might for instance).

    Thanks in advance.
     
  2. myazuid

    myazuid

    Joined:
    Jan 29, 2019
    Posts:
    26
    anybody able to help on this?
     
  3. Xiangting_Su

    Xiangting_Su

    Unity Technologies

    Joined:
    Sep 22, 2020
    Posts:
    246
    What an apt name. I like how you guys are calling it "the UFO issue". :D

    Well, this is rather strange. It's not immediately obvious to me what caused this visual glitch but let me bring this back to the team. Perhaps the devs or the QAs might have some clue.

    In the meantime, may I know:
    • What's the minimum setup to repro this visual glitch? More information on this would help greatly.
    • Any Shadow Caster 2D used in this Scene?
    • Any Sprite/Mesh/Tile or any objects that resemble this rhombus shape?
      • Is it always this rhombus shape when it appears?
    On a related note, if you would like someone to have a closer look at your project to ascertain if this is a bug which we can help to fix, perhaps it might be worth submitting a bug report. Also, if you share your bug ID with us here in this thread, we might be able to help expedite your case a little by assigning it directly to the relevant dev.
     
    Last edited: Nov 3, 2022
  4. karliss_coldwild

    karliss_coldwild

    Joined:
    Oct 1, 2020
    Posts:
    530
    Do I understand that the bright light is also unexpected not just the black shape? Without knowing how your game is supposed to look like it's hard to tell just from the screenshot whether that bright light is part of the intended content or not.

    General process for debugging graphical glitches like this isn't that different from debugging bugs in C# code. You need to systematically analyze step by step what's happening and intermediate values match with your expectation of what is supposed to happen. If some step produces wrong result check the inputs, if the inputs are good then the problem must be in the step itself. Split the step further into substeps. If the inputs go back to the thing which produces those inputs and analyze that. Repeat until the problematic step is sufficiently small that the problem and solution becomes obvious.


    1) Reproduce the issue. You can't fix problems that you can't repeat. Sounds like you where able to repeat it on your computer in Editor at least few times that's great . Ideally you should be able to trigger the problem in less than 10minutes, otherwise further investigation will be very slow and tedious.
    2) once the UFO appears start inspecting the situation and narrowing down whether the "UFO" is related to specific object
    * Is the movement of black shape is strictly locked relative to bright light?
    * You said you can repeat it in Editor. Can you see it also in scene view not just the game view? If you see it in scene view what happens if you slightly move the camera. If you don't see the bright light/black rectangle in scene view can you identify the object which is in the position that would match with UFO location.

    3) If basic investigation didn't give too much information you can start using more powerfull debuging tools like the builtin Unity frame debuger https://docs.unity3d.com/Manual/FrameDebugger.html or third party tool like RenderDoc https://renderdoc.org/ . They will help you analyze step by step how the frame is drawn what textures/materials/shaders/geometry each step uses. This information should help you narrow down whether the UFO is related to specific game object and material or some post processing step. Once you narrowed down what object/material/post processing step is producing UFO you can start checking it's configuration and why it looks like that. Did you forgot to set some setting, set some option to value that's too big or too small, or maybe it's a bug in shader you wrote, or maybe it's a third party asset which is incompatible with your current rendering pipeline. Knowing what exact object it's related to might also help with reducing the amount of time it takes you trigger the problem on demand. If the problem is caused by some multistage postprocessing shader you can use the frame debuging tools to inspect textures which are used as inputs for shader, whether some of the pixels in them contain values you didn't expect, if yes how are they produced what shaders where used to create those input texture and so on.
    4) If you fail to solve the problem directly once you know the object it's related to do. You can start creating a minimal testcase for repeating it in a new empty project. That way you will either end up with a testcase that you can use for creating a bugreport, or you will endup with setup where everything works. In the second case after creating a working thing port the working setup to your main project, do this only after you have learned how to reliably trigger the problem in step 3 otherwise you can't know whether the new setup fixes it or not.
     
    Xiangting_Su likes this.