Random white spots after baking (lightmap artifacts)

For the past week I have gotten a Phd in baking lighting in unity. I have done everything from generating UV’s automatically using unitys algorithm, to packing my own lightmap UV’s in Blender.

I have added padding in the lighting settings, also in the UV layout among the islands to prevent light leaks.

No matter what I tried I keep getting the same issue over and over and over again.

Absolutely random white spots all over the place…

I have 0 clue what is causing this.

The closest I have gotten to figuring it out is disabling the “Filtering” option under “Lightmapper” in the Lighting settings in unity.

It seems that, when this setting is off, I get a disco effect in the scene, not sure if this is normal, I think it is not.

Because I tried doing the same on a super simple scene with unity cubes and planes and did not have this happen.

My theory is that this is where the problem occurs, maybe there are not enough rays? I tried increasing direct and indirect samples to 4000 and nothing changed…

Or maybe the rays are hitting the same point for some reason, resulting in a bright spot that is then filtered with the filter to make it look smooth, leaving the white smudge that I am complaining about…

Here’s an example of the UV unwrap I did in Blender with massive margins and padding to prevent light leaks:

Here’s a close up of a random wall, you can see the white smudge there:

And this is that wall in-game view, the massive smudge is clearly visible:

This is the model I am using, maybe the issue lies in the fact that there are too many objects in the scene?
House by Elbolilloduro (itch.io)

Any sort of help would be massively appreciated, thanks!

Nothing at all? It should improve, it looks like not enough rays to me, it may simply be that you need a lot more than 4000.

Thanks for the speedy response! I really appreciate it! I will give it another shot and report back. Currently I am baking a test with 4096 direct samples, 4096 indirect samples and 2048 environment samples.

I don’t think you need that many environment samples, but you probably need more indirect samples than 4096.

Also the margins / padding look a bit overkill, but that’s not related to this issue.

I was going a bit extreme with the margins to see if the problem was light leaks. I will tone it down:smile:

I just finished the test and here are the results:


It definitely looks better, but there are still some light spots as you can see. I will try increasing the direct samples more to 8192 like you suggested and see what happens then.

At 8192 it still looks the same as at 4096 to me:

That bright spot under the shovel that is consistently there seems a bit weird. Does Texel validity (scene view debug) show any red areas where the bright spot is?

Also, I said indirect samples, not direct.

Try something like
Direct: 512
Indirect: 16384
Environment: 1024

Apologies for the late reply, I fell asleep Again, thank you so much for helping out!!

The bake has finished, and the results are better:

Here’s a screen of the texel validity:

So, I will now try out the settings you suggested, but I would like to try and understand them, if you could let me know if I got it right:

  • The shovel and the thing next to it are just a plane with a transparent texture. I guess the texels behind the objects are hitting the back face of the plane, rendering them invalid? To fix this I can try enabling two-sided thingy in the material?
  • However, I am not sure why most of the edges of all the models are also having this issue? Maybe because there’s not enough indirect samples for it to hit a front face, thus the suggestion to increase indirect light samples?

There’s also this weird area behind the bed that I am thinking is also because of the lack of indirect samples? Since there is no one sided planes in this area I think:
9780456--1402500--upload_2024-4-19_13-19-14.png

Thanks!

I think I understand the edge issues now!

As you can see this wall here has issues on the edges:

If I zoom inside the wall I see that the floor plane extends inside the wall and the wall is one sided, thus producing the texel invalidity, but the texels on the edge bleed out and it looks like an edge issue:


I am using third party models, so I had no clue it was modeled like this. However, I don’t think this is causing a lot of problems at the moment.

1 Like

To mitigate texel validity issues, you can increase backface tolerance in your Lightmap Parameters asset, or turn on Double Sided GI for the relevant materials. https://discussions.unity.com/t/895352/16

Texels are maked invalid specifically when the percentage of rays shot from the texel, which hit a backface, is greater than the backface tolerance. The idea is that texels which mostly saw backfaces probably have bogus data (unless the backface was intentional, determined by Double Sided GI flag), so we average nearby texels to get a better value for the invalid texel.

Exactly.

Those are fine, you don’t need to worry about them. The texel is partially inside geometry. If it was valid, Unity would deem it to be black (since it is inside geometry!), therefore you would have a row of really black pixels in your corner. This is why texel rejection exists, so it can say “This is mostly inside geo, but since it may be visible, it will probably be best if it borrows a value from a neighbour instead of being calculated black”. I hope my explanation makes sense, I haven’t had coffee yet.

The red always means that Unity thinks it is inside geometry and is rejecting the texels, you need to find the material that has open backfaces nearby and mark it as double sided GI. Newer Unity versions have a debug scene view mode that highlights the open backfaces, but that may be only for Unity 6 (2021 doesn’t have it, maybe 2022 does but I’m not sure).

1 Like

@AcidArrow FYI, the backface highlighting mode landed in 2023.2.0a5. It’s not a new scene view mode, rather a checkbox you can enable when using the existing ones

1 Like

Right, thanks! Immediately after posting I opened Unity 6 to see how it was called, and I was looking at the debug view list, not remembering it was a checkbox, and for a minute there I was starting to wonder if I had dreamed the feature.

@AcidArrow @Pema-Malling Thanks for the help! Your answers helped me solve my problem and deepen my understanding of lightmapping. Increasing the samples and marking certain materials as double sided fixed all my issues!

1 Like