Search Unity

Question Realtime part of mixed light is passing through objects.

Discussion in 'Global Illumination' started by PenProd, Mar 21, 2023.

  1. PenProd

    PenProd

    Joined:
    Dec 17, 2022
    Posts:
    171
    Unity 2021.3.19f
    URP 12.1.10


    In my scene, I have these balcony doors:

    upload_2023-3-21_8-48-31.png

    If you look closely, you can see something very strange is going on. Not only are the doors lit from the (mixed) light above, they seem to be lit from an invisible light from below. The underside of the doors are lit and you can see shadows of the handles above the handles.

    Only the doors are lit by this invisible light. Not the walls. The difference being that the doors use a URP/Lit shader, the walls use a URP/Baked Lit shader.

    Now actually, I do know where that light is coming from. There is a mixed light one floor down, below the balcony:

    upload_2023-3-21_8-52-31.png

    For some reason, the realtime part of this light is not blocked by the ceiling (as can be seen on the balcony doors). But the baked part is (as can be seen on the walls on the balcony). The ceiling is the floor of the balcony as well. It's just a simple cube which acts as the ceiling for the first floor, and as the floor of the balcony above. There is no problem with the normals of the faces. Also, there's no problem with the materials used. If I create a new cube without any materials applied, the problem also arises.
     
  2. PenProd

    PenProd

    Joined:
    Dec 17, 2022
    Posts:
    171
    I hate investigating a problem for days at end, only to find the answer myself minutes after I post a question here.

    But apparently (and I did not know that), static meshes don't cast real time shadows. The long answer is here.
     
  3. PenProd

    PenProd

    Joined:
    Dec 17, 2022
    Posts:
    171
    And I hate it even more when I think "problem solved" only to find out the problem has become more complex.

    So when I play the game in the editor, the problem seems to be solved. Here is the same balcony with the doors open, and as you can see, the doors are properly lit. Well, mostly. There's still something funky going on at the left door, but that's hardly visible:

    upload_2023-3-21_13-34-13.png

    But when I build and run (on a Quest 1 and Quest 2), it looks completely different and some weird lighting is going on:

    prob1.jpg
    It gets even weirder if I move slightly closer (and I mean, moving my head less than an inch towards the doors):

    prob2.jpg
    And yet another inch closer:

    prob3.jpg
    This kinda looks related to a problem I posted earlier.
     
  4. PenProd

    PenProd

    Joined:
    Dec 17, 2022
    Posts:
    171
    This is driving me absolutely insane. The solution according to this page, is to create a GameObject set to cast shadows only. So I did. I created a simple cube that seperates the first floor from the second floor. It seemed to work. All light bleeding from the first to the second floor seemed to have disappeared. Until... I added another simple object to the scene.

    I made some changes to the scene (added a few simple objects) and now light is bleeding to the second floor again. The GameObject I created earlier to block all light seems to do nothing anymore.
     
  5. PenProd

    PenProd

    Joined:
    Dec 17, 2022
    Posts:
    171
    I can't get rid of this problem. Even if I create extra objects to block the light, light still shines through...
     
  6. PenProd

    PenProd

    Joined:
    Dec 17, 2022
    Posts:
    171
    Does anyone have any idea what might be causing this? Or how I can troubleshoot this?
     
  7. PenProd

    PenProd

    Joined:
    Dec 17, 2022
    Posts:
    171
    Okay, the lack of responses tells me either no-one knows what could be causing this, or I'm not being clear enough. ;)

    So I did a bit more testing and found a few more "interesting" things. I have a room with a closet and a small table. One floor lower is a mixed point light which I disabled just to show you how things are supposed to look:

    upload_2023-3-31_11-49-50.png

    But this is what happens if I activate the light:

    upload_2023-3-31_11-51-35.png

    As you can see, both the closet and the table now gets lit from below. Mind you, the light is actually a floor down on the other side of the wall. So not only does the light pass through the floor (a cube), it also passes through a wall (also a cube). To top things off, I've actually placed another cube in between the two floors to try to block the light. It doesn't.

    But watch what happens if I set the light's Render Mode to "Not Important":

    upload_2023-3-31_11-54-8.png

    The closet is no longer lit from below, but the table still is... Both objects are static, BTW.

    What I've done now is put the objects that are receiving lighting from the lights on the lower floor, on their own layer. Then excluded that layer in the lights' culling mask. This works, but is not ideal.