Search Unity

Question Faces of objects light up as if they emit light themselves...

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

  1. PenProd

    PenProd

    Joined:
    Dec 17, 2022
    Posts:
    171
    I have a very weird problem. I made a few very simple objects using ProBuilder (plinths). They have a simple wood material and using the URP/Baked Lit shader. It's also marked as a static object.

    After I have generated the lighting, some of the faces light up as if they are emitting light themselves. Weird thing is, the entire scene is lit by a single point light, with its mode set to Baked. Even stranger, the plinth is outside of the reach of the light. Not only is the plinth further away than the light's range, The front of the plinth (facing the light) is completely dark, there are items between the plinth and the light, and the faces that are lit up are on the backside of the plinth. And yet they light up. I've tried everything I could think of but nothing seems to help. I even tried other objects and they experience the same problem, but only in that position. If I look at the lightmap, I don't see why the backside should light up, so it's not information in the lightmap.

    If I disable the (one and only) light, it doesn't light up, so it is cause by the light.

    One thing I noticed: When baking light, the (back faces of the) plinth stays dark till the very last second of baking. They only light up when the lightmap is created.

    Before baking light (you can see the light in the background):

    upload_2023-3-1_18-0-50.png

    After baking light:

    upload_2023-3-1_18-3-19.png

    This is the backside of the plinth, which is actually inside a wall.

    Also, the entire backside of the plinth is lit evenly:

    upload_2023-3-1_18-9-1.png

    What could be causing this? The problem disappears if I set the Directional Mode (Lighting) to Non-Directional.
     
  2. Pema-Malling

    Pema-Malling

    Unity Technologies

    Joined:
    Jul 3, 2020
    Posts:
    328
    PenProd likes this.
  3. PenProd

    PenProd

    Joined:
    Dec 17, 2022
    Posts:
    171
    2021.3.19f1

    Here's another example of a piece of geometry that lights up as if it's emitting light itself. It's not a single face that's lighting up, it's actually part of a face.

    No baking done yet, lighting comes from Scene View Camera Light:

    upload_2023-3-3_9-57-3.png

    After baking (yes, it's a very dark scene):

    upload_2023-3-3_9-58-11.png

    The light map (which doesn't show any problems):

    upload_2023-3-3_9-59-33.png

    Texel Validity (which shows problems, but no ideay what's causing them. These are very simple geometric shapes):

    upload_2023-3-3_10-1-39.png

    UV Overlap (again, shows problems but no idea how to solve them):

    upload_2023-3-3_10-2-28.png

    Now even though there are invalid Texels and overlapping UVs, I'm not sure those are causing the problem since these problems are everywhere and the problem doesn't show up immediately after I create/place the object. It will be fine and then much later in the project, it will suddenly show up. Also, there are numerous duplicates of the object, and none show this problem except this one.

    (continued in next post)
     
  4. PenProd

    PenProd

    Joined:
    Dec 17, 2022
    Posts:
    171
    But if you look at the Directional map, the problem becomes quite obvious:

    upload_2023-3-3_10-6-18.png

    Again, no clue what caused this error or how to prevent it.
     
  5. PenProd

    PenProd

    Joined:
    Dec 17, 2022
    Posts:
    171
    I would like to add that it only seems to happen with geometry which I have stretched out by moving the vertices instead of resizing. Let me try to explain with the above object as example.

    First thing I did was create a simple cube (ProBuilder):

    upload_2023-3-3_10-20-21.png

    I then bevel the edges:

    upload_2023-3-3_10-22-0.png

    Now I want to stretch this, but if I use the resize tool, it will deform the bevels:

    upload_2023-3-3_10-23-16.png

    So what I do is simply move the vertices on one side:

    upload_2023-3-3_10-25-21.png

    And this is apparently what is causing the problem. Because I've noticed that when I stretch an obect by resizing over a single axis, there are no problems. But if I stretch it by moving vertices, all kinds of problems occur.
     
  6. Pema-Malling

    Pema-Malling

    Unity Technologies

    Joined:
    Jul 3, 2020
    Posts:
    328
    Hmm. It almost looks like your normals are flipped in some places, but the process doesn't indicate that that should happen. Here are a few things you can try:

    - Adjust the backface tolerance in your Lightmap Parameters asset. It is accessed via Window > Rendering > Lighting > Scene > Lightmap Parameters. Maybe it's a tad too low
    - Try adjusting your lightmap padding and perhaps resolution+max size. These settings are also found in the lighting window
    - Try enabling Double Sided GI on the relevant materials. This isn't really a fix, but might tell us something
     
    PenProd likes this.
  7. Pema-Malling

    Pema-Malling

    Unity Technologies

    Joined:
    Jul 3, 2020
    Posts:
    328
    You can use the the lightmap preview window to debug issues like this. Found in the Baked Lightmaps tab of the lighting window, click "Open Preview" on one of the lightmaps. Should make it easier to see why you get validity issues, select the relevant mode from the top dropdown.

    upload_2023-3-3_11-32-36.png
     
    PenProd likes this.
  8. PenProd

    PenProd

    Joined:
    Dec 17, 2022
    Posts:
    171
    One more example. Here is a white plinth. It's not scaled (yet). No baking, Scene View Camera Light:

    upload_2023-3-3_11-35-17.png

    After baking:

    upload_2023-3-3_11-36-11.png

    Now the reason I want to stretch it, is because if I simply place multiple instances end to end, each instance gets lit differently:

    upload_2023-3-3_11-37-4.png

    This is how it looks if I stretch it by moving the vertices on one end. As you can see, it's lit completely wrong:

    upload_2023-3-3_11-37-53.png

    The only way to get it to be correctly lit, is by sizing it over a single axis:

    upload_2023-3-3_11-39-8.png

    (There's actually another light at the far end causing the end to become a bit lighter again)

    So there you have it. I'm not sure this is a bug, or a wrong setting, or me just being an ID-ten-T. :)
     
  9. PenProd

    PenProd

    Joined:
    Dec 17, 2022
    Posts:
    171
    The problem seems completely random. After baking the lights for above example, I had a look at the problem area of the first example and it was gone (don't have a screenshot of that, but imagine the object of my first message lit correctly). I then removed the sample object (the white plinth in above post), rebaked the lights and the problem returned. So apparently, adding a random object somewhere in the scene causes the problem to appear somewhere else.
     
  10. PenProd

    PenProd

    Joined:
    Dec 17, 2022
    Posts:
    171
    Increasing the Lightmap Padding from 2 to 3, seemed to have had a positive effect. I don't know yet if it completely solved the problems, have to do some more testing for that. But a definite improvement!
     
  11. SF_FrankvHoof

    SF_FrankvHoof

    Joined:
    Apr 1, 2022
    Posts:
    780
    Flipped/Incorrect Normals.
     
  12. Pema-Malling

    Pema-Malling

    Unity Technologies

    Joined:
    Jul 3, 2020
    Posts:
    328
    Changing the scene can affect the resulting layout used for the lightmap. When you have invalid texels, as shown on your scene view debug mode screenshots, data will be dilated from neighboring texels. If there is something very bright close by in lightmap space, you'd get bright splotches like that. One way this can happen is indeed if you have flipped normals, which will cause erroneously invalid texels. Did you check if double-sided GI or editing backface tolerance made a difference? You might even try even higher padding
     
  13. PenProd

    PenProd

    Joined:
    Dec 17, 2022
    Posts:
    171
    I'll check the double-sided GI in a minute but just wanted to say there's no "Backface Tolerance" option.

    upload_2023-3-3_13-41-39.png
     
  14. Pema-Malling

    Pema-Malling

    Unity Technologies

    Joined:
    Jul 3, 2020
    Posts:
    328
    It's a bit hidden. You see that "Lightmap Parameters" field at the bottom of the window? That's a reference to a separate asset. This asset - the Lightmap Parameter Asset, contains the backface tolerance setting.
     
  15. PenProd

    PenProd

    Joined:
    Dec 17, 2022
    Posts:
    171
    Enabling Double-Sided GI did not make (much of) a difference. The problems are still there, they just moved to other objects (so objects that were lit incorrectly are now lit correctly, but now other objects are lit incorrectly).
     
  16. PenProd

    PenProd

    Joined:
    Dec 17, 2022
    Posts:
    171
    Ah ok. But if I click "View", everything is grayed out - cannot change anything.
     
  17. SF_FrankvHoof

    SF_FrankvHoof

    Joined:
    Apr 1, 2022
    Posts:
    780
    The default Lightmap Param Assets are part of the URP-package, and thus not editable. Create a new one, and use that.
     
  18. PenProd

    PenProd

    Joined:
    Dec 17, 2022
    Posts:
    171
    Just for the heck of it, I increased Lightmap Padding to 10. That seemed to get rid of all overly lit objects. But still objects are incorrectly lit. For instance, here is a piece of a wall that is lit correctly:

    upload_2023-3-3_13-58-32.png

    The frames, lamp and light have been duplicated and moved a few meters to the right on the same wall. But now, it's lit completely wrong:

    upload_2023-3-3_13-59-58.png

    Exact same objects, exact same orientation...
     
  19. PenProd

    PenProd

    Joined:
    Dec 17, 2022
    Posts:
    171
    Sorry, my last message was incomplete. In the first image, the frames are dynamic objects (to see how it should be lit). In the second image, the frames are marked as static (and thus get their lighting from the lightmap)
     
  20. PenProd

    PenProd

    Joined:
    Dec 17, 2022
    Posts:
    171
    The problem is not in the light map. I've set lightmap padding to 6 and still I get this:

    upload_2023-3-3_15-58-3.png

    Looking at the object in the lightmap, I see no bleeding or anything:

    upload_2023-3-3_15-59-31.png

    The Directional map however, does show a problem (again):

    upload_2023-3-3_16-0-30.png
     
  21. PenProd

    PenProd

    Joined:
    Dec 17, 2022
    Posts:
    171
    I've increased the Backface Tolerance from 0.9 to 1 (the max). Made no difference.
     
  22. PenProd

    PenProd

    Joined:
    Dec 17, 2022
    Posts:
    171
    Interesting observation: Switching from the Progressive GPU lightmapper to the Progressive CPU lightmapper and the problem disappears...
     
  23. Pema-Malling

    Pema-Malling

    Unity Technologies

    Joined:
    Jul 3, 2020
    Posts:
    328
    Hmm... this might be a legitimate bug, especially given the discrepancy between CPU and GPU LM. I suggest you file a bug report if this is blocking you.
     
  24. PenProd

    PenProd

    Joined:
    Dec 17, 2022
    Posts:
    171
    Oh man, this is frustrating... It seems that with every bake, quality of the lighting gets worse and worse.

    Now I noticed my skybox has disappeared (it should be a nice night sky instead of the blueish whatever it is now, and these dark lines have appeared.

    upload_2023-3-3_17-58-2.png

    No matter what I change the skybox to, it stays blue and I can't get rid of the dark lines either...
     
  25. PenProd

    PenProd

    Joined:
    Dec 17, 2022
    Posts:
    171
    Skybox is back - something caused this to be "off", even though it was showing "on".

    upload_2023-3-4_9-22-14.png

    And the dark lines were caused by the shader rendering both sides. Which still shouldn't happen but I could get rid of it by only rendering the front. Still other lighting problems which aren't caused (or solved) by anything in the above posts. Now, instead of spots emitting light, I have dark spots which are not shadows and any of the above solutions does not get rid of it.

    upload_2023-3-4_9-32-40.png

    I think this is caused by bleeding in the light map. The reason why increasing the lightmap padding does not work is because that increases the distance between objects in the lightmap, not between the individual parts of an object.

    upload_2023-3-4_9-43-35.png
     
  26. kristijonas_unity

    kristijonas_unity

    Unity Technologies

    Joined:
    Feb 8, 2018
    Posts:
    1,080
    There seem to be multiple issues at play:
    • NaNs in directionality mode. That could be caused by incorrectly authored normals/smoothing groups as @SF_FrankvHoof has pointed out. Inspect the meshes in a DCC package, or let Unity generate normals for them automatically in the mesh importer.
    • Make sure that lightmap UVs are properly laid out. You'd need to do it yourself in a DCC tool, or have Unity generate them for you.
    • As for validity artifacts; I'd highly recommend you'd check out the following chapter in the troubleshooting guide: Chapter 15: Invalid texel artifacts
    • Lightmap UV seams are very common when using modular meshes and are very difficult to get rid of. Again, I'd recommend that you'd check out this chapter in the troubleshooting guide: Chapter 10: Lightmap UV seams