I experienced a lot of problems in the past months using Unity’s Lightmapping for my big open world scene.
The models are low poly and UV unwrapped by hand(had to because there were problems with automatic UV no matter what the settings were).
The main problem is that the edges where the shadow changes are very, very jagged/blocky. The only way to sort of mask it is by increasing the Lightmap Resolution, but this increases the texture size a lot and that’s a problem since I am targeting mobile devices.
You can check out 1 more example here Imgur: The magic of the Internet.
I couldn’t post them here. There is a 5 images limit per post.
This is another problem. I was left with the white smudges today after changing a lot of values trying to solve the problem. Tried reverting to the old settings but now they are here to stay I guess. Welp!!
For the jagged edges the only thing that helped was scaling down the whole scene in half. Now I get a lot better shadows with the lightmap resolution even at 5. I wonder if there is some math I can do to figure out what is the perfect scale.
But the AO white seams still persists. No info on internet and I don’t know what to do.
@AlienBoyGames Thanks for you post. I think that the jaggies that you are seeing are due to sub-optimal UV unwraps. My guess is that your object is authored in such a way that the two faces on either side of the jagged edge points to the same charts/island in the UV unwrap. This is a problem because that means pixels being shaded near that edge will potentially sample from both sides of the light/shadow part of the island/chart in the baked lightmap. Therefore shadow/light bleeds across the edge even though that is not what you want
I’d say that the best way to solve this is to make sure that faces which ought to looked faceted have their own separate chart/island in the UV unwrap of the object. In the clip below I show how you can achieve this using Unity’s built-in auto unwrapper:
By setting “Hard Angle” to a small value, you ask the unwrapper to treat most faces as having a sharp edge. This is typically what you want in low-poly style games. Of course, you don’t have to use Unity’s unwrapper to achieve this.
Another solution to your problem is to not bake direct light into your lightmap. The reason the jaggies are so significant is because you have very bright direct light on one side of the edge and relatively weak indirect light on the other. If you only bake indirect light (and apply direct light with realtime techniques instead), then you would not have that problem. I show this solution in this clip:
As you can see in the video, the problem becomes much less significant by not having direct light in the lightmap.
Note that this is not a perfect solution since there is still some “texel bleeding” across the edge. It is just less visible because it is “only” indirect light. Therefore, I’d recommend the first solution that I mentioned above over this second solution.
Regarding the “white smudges” that you see I am less certain of what is going on. I suspect this is due to texel bleeding across separate lightmap charts. Are you getting “There are X objects in the Scene with overlapping UV’s.” warnings in the console? If so you can solve this by increasing the resolution or increasing the spacing between your charts as explained here. Generally, I recommend you use Unity’s unwrapper’s new feature Auto Pack Margin .
Ok this makes a lot of sense. So the jagged edges happens because texel for blending was put right on the seam which is ok for normal models with smooth geometry.
This is my current progression.
I ditched the unity generate lightmap uv’s because the uv faces were still connected. So I went to blender and marked all edges as seams and did a uv unwrap. That left me with some ugly bleeding between all the faces but no more jagged edges. Then tried Lightmap Pack, same thing happened. Increased the margin. Same thing.
Deactivated the denoiser and everything got fixed. No more jagged edges and even the AO worked perfectly but I was left with some horrible noise.
This is where I am stuck right now. I don’t have any uv overlap and a few texels between each uv chart.
AlienBoyGames: I am slightly confused. You say that when disabling the denoiser “everything got fixed”, except now you have horrible noise. However, in the images you posted I don’t see any noise. Instead, I see suspicious “bands” near geometry edges. Therefore it is not clear to me what your current problem actually is (is it noise or it edge artifacts?). Can you elaborate?
:)) Sorry, sometimes I get really tired. Last night I had an revelation and decided to switch the art style from low poly to stylized so these problems might not happen again.
But I will explain in case anyone has these problem or I will face it again.
I didn’t post any photos with the noise. The 3 pictures are from the same bake in which I used the denoiser. The second pic shows the highest bleeding and the first in the first one you can see a zoomed in picture of it’s uv’s.
In the third photo you can see what usually happens, on most 3D models, slight bleeding but noticeable.
I baked the whole scene with the denoiser off and you can see the pictures from the same angles as before so you can compare.
It’s hard for me to tell if there is still some bleeding happen because of the huge amount of noise. I doesn’t look like it on direct lighting.
Can you share a screenshot of your filtering/denoising settings? Perhaps you are using a very large blur radius for filtering?
Another thing you could try is to set filtering to “Advanced” and then disable everything (set all denoising/filtering settings to None). Then you can reenable the denoising/filtering settings one at a time and bake in between to inspect the results. That should give you a clue about what may be causing this.
You may also consider to only enable filtering and disable denoising. This works well for some projects.
PS: Perhaps you already know this, but currently there’s way too much space between the charts. You are wasting precious lightmap texel :).
I know this is an old topic, but I was struggling with this the last days. I messed around with a lot of settings, until I got to filtering. I was using Optix for Denoiser, and after changing to “None” the issue was solved, but AO got very noisy. So I found a middle ground using OpenImageDenoise and setting Gaussian to something around 2 texels for each one. I hope this helps someone out there.