Why does this happen?

preview during baking:

results after finished baking:

what’s ruining my results and causing them to look jagged after baking completes?



6178515--676629--ezgif-6-94e121891926.gif

Hey stroustrup,

I assume you’re talking about the shadows? Are those realtime shadows, or are they baked?

Cheers

baked

6178845--676596--Screenshot 2020-08-07 at 08.09.27.jpg
6178845--676599--Screenshot 2020-08-07 at 08.09.31.jpg

As long as your shadows aren’t baked out, you see realtime shadows instead. The different resolution in your shadowmap compared to your baking resolution in the lightmaps causes the artifacts - in this case the aliasing along the shadow border - to look different. Try experimenting with the shadowmap resolution or your lightmap resolution.

not at all sure what’s causing the worsening of results. why is blur radius greyed out? i tried changing it via text file but doesn’t seem to make any difference

results are fully baked, something is happening just before the baking finishes that’s destroying my results. 40 rez behaves like 28 res, 60 resolution behaves like 40 due to this effect

do you know how to turn off the blurring in post bake? tried setting the filtering to none but doesn’t work


6178902--676611--Screenshot 2020-08-07 at 10.42.59.jpg
6178902--676614--Screenshot 2020-08-07 at 10.43.09.jpg

something is adding squares and removing the smooth lines of the spotlight after baking. no option in the light baking menu seems to be able to remove it. it is extremely noticeable despite me increasing texture rez to 4k, and egregious for spot lights especially which i use exclusively.

Hi Stroustrup. Does your light object use Mode=Baked or Mode=Mixed?

One possible explanation for what you are seeing is that you have Mode=Baked for your lights. During baking when there’s still no bake lightmap ready, Unity’s renders your scene with realtime shadows (shadow mapping) and this usually leads to a high shadow resolution compared to what lightmaps can give you. This would explain why you are seeing smooth shadows during baking. Then at some point, Unity applies the baked lightmaps to your meshes. When this happens you may see a reduction in the on-screen shadow resolution simply because lightmaps are not super high resolution (compared to what you get from realtime shadow mapping).

Assuming my explanation is correct, then I want to make it clear that this aliasing is not because something is wrong with Unity. It is simply a consequence of lightmaps not having high enough resolution to fully capture the high-frequency information in sharp shadow borders. One way to solve this problem is precisely to use Mode=Mixed because then you get the high precision from shadowmapping rather than lightmapping (while still getting GI from lightmapping).

I did a little experiment to check whether my hypothesis indeed made sense. As you can see in the attached images I get a more accurate/smooth shadow terminator when using Mode=Mixed.


With default settings there are blurring/filtering going on two places:

  • As a post step in baking (as you mentioned).
  • During runtime shading. By default we use bilinear filtering to sample from the baked lightmaps.

In order to completely disable blurring you have to disable both. You can disable the bake blurring in the Lighting window by setting the Filtering dropdown to None (it’s in the Lightmapping Settings).

To disable runtime filtering you must find the generated lightmaps in the Project tab. It is usually stored in SceneName/Lightmap-0_comp_light or something like that. Select the lightmap(s) and then in the Inspector you can choose Filter Mode = Point.

See attached image for example of what this looks like.

I mean sure but Unity could also attempt to filter / process the direct light buffer to make direct light shadows to appear smooth more than it currently does, which is not at all.

Somehow I believe there are ways to make a hard edge look reasonably antialiased without it just Gaussian blurring way too much.

Good point, you are right. I should have been more clear. What I meant to say was that the lightmapping technique usually tends to give you fewer data points per pixel (when projected to screen space) compared to what you get from shadowmapping techniques. No filtering tricks can change that.

That being said, I agree with you that Unity could provide better ways to filter the lightmap. One particular technique that I have been wanting to try out for some time is bicubic filtering of the baked lightmap. At the cost of a little extra work in the shader, you can reduce quite a lot of the aliasing you get with bilinear filtering. See the section “Bicubic interpoation” in the blog post Baking artifact-free lightmaps on the GPU by Mr F.

1 Like