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 All kinds of strange things happening (movie)

Discussion in 'Global Illumination' started by PenProd, Apr 4, 2023.

  1. PenProd

    PenProd

    Joined:
    Dec 17, 2022
    Posts:
    150
    So I've been struggling with lighting for months now and actually haven't been able to find solutions to any of the problems I've experienced so far - only workarounds. For instance, the problems I had with light shining through objects, I was only able to "solve" by putting objects on separate layers and using a light's culling mask. Or the problem with faces of objects lighting up like a Christmas tree by turning of Directional Mode when baking lights.

    But like I said, those are workarounds - not solutions.

    But there are a few problems/glitches for which I can't even find a workaround. And they are hard to reproduce. Because if I just change one small thing in my scene, the problems simply moves to another object.

    I've made a small movie of a few of the problems I'm experiencing now. All only appear when looking at objects from certain positions and from certain angles. Sometimes just weird stuff happens (objects "glitch"), other times objects loose their lighting.



    So yeah, anyone know what's going on?
     
  2. kristijonas_unity

    kristijonas_unity

    Unity Technologies

    Joined:
    Feb 8, 2018
    Posts:
    1,080
    This looks like z-fighting to me. Make sure that your models don't have any overlapping faces.
     
  3. PenProd

    PenProd

    Joined:
    Dec 17, 2022
    Posts:
    150
    That was the first thing I checked. No overlapping objects, no overlapping faces.
     
  4. Pema-Malling

    Pema-Malling

    Unity Technologies

    Joined:
    Jul 3, 2020
    Posts:
    248
    Does it only happen in the built player, or also in editor? If you have the know-how, it might be worth taking a few RenderDoc (https://renderdoc.org/) captures to figure out what is happening here.

    Either way, you'll probably want to file a bug report for this - and make sure to include enough of your project to reproduce the issue if you do.
     
  5. PenProd

    PenProd

    Joined:
    Dec 17, 2022
    Posts:
    150
    It happens only in the built player. In the editor, it runs without any problems.

    I'm not sure I can reproduce it without actually including the entire project. This game consists of three scenes. The first two scenes run without any problems but they are much smaller. The third scene is quite big and that is where the problems are.
     
  6. Pema-Malling

    Pema-Malling

    Unity Technologies

    Joined:
    Jul 3, 2020
    Posts:
    248
    Big projects shouldn't be an issue with regards to filing bug reports
     
  7. PenProd

    PenProd

    Joined:
    Dec 17, 2022
    Posts:
    150
    I think in the video posted above, there are two different problems at work. Before the 0:30 time mark, I think the problem is caused by the shape of the object, but I'm currently investigating that, so I'll come back to that later.

    But from 0:31 onwards, it's all one and the same problem for which I can't find the cause. As you can see, objects simply loose their real-time lighting. Mind you, this happens throughout the scene. In fact, all static objects with a URP/Lit shader (as opposed to a Baked Lit shader) exhibit this behavior. But only when viewed from specific spots and certain angles. When the problem occurs, an object looses its real-time lighting and all that it's left with is the baked part (from the lightmap). For some static objects I have set the size in the lightmap to 0, meaning they still contribute to GI, but do not get baked lighting. So when the problem occurs on these objects, they turn black (since they are only lit by the real-time part of a light and they don't have lightmap data).

    As I said, the problem only occurs from certain positions and certain angles. Sometimes that means that if you look straight an object, it looses it's realtime lighting, and the lighting return if you look away, sometimes it's the other way around.

    All lights in the scene are mixed lights.
     
  8. PenProd

    PenProd

    Joined:
    Dec 17, 2022
    Posts:
    150
    Just for giggles, I changed the Graphics API from OpenGLES3 to Vulkan and that got rid of all problems in the above video. So no more glitching and no more lighting problems. So problem solved you would think.

    Well... Not so much. Now there's a new problem with occlusion culling. Objects are glitching out of existence left and right now. Also, I have a feeling I get slightly lower FPS now than before.
     
  9. PenProd

    PenProd

    Joined:
    Dec 17, 2022
    Posts:
    150
    This is what happens now. Look at the bottom of the stairs through the pillars. BTW, the pillars aren't set as occluders (they are set as occludees), and it only happens when you look through "holes".

     
  10. PenProd

    PenProd

    Joined:
    Dec 17, 2022
    Posts:
    150
    These problems are the only things keeping me from finishing the game. In fact, the game is finished, I just need to get rid of bugs like these first before I can release it.
     
  11. PenProd

    PenProd

    Joined:
    Dec 17, 2022
    Posts:
    150
    Does anyone have an explanation for the things happening in the above video?
     
  12. PenProd

    PenProd

    Joined:
    Dec 17, 2022
    Posts:
    150
    I did some more testing and the problem is definitely caused by the baked occlusion data. If I clear the data and rebuild the game for the Quest, the problem is gone. But since the problem only occurs in the player and not in the editor, I must assume this is a bug in the player.