Why does a baked spotlight looks less rough around the edges than a directional light?

At the default resolution of 40 a spotlight looks alot better around the edges than a directional light.

Spot

Directional light

Why is that?

Thanks

At a glance it seems to me that the Directional light in the picture is using realtime shadows while the spot is baked? Are you using the same lighting mode for both light ? Unity - Manual: Light Modes

Yep both are baked lightmaps with mixed mode (Shadowmask in quality setting, not Shadowmask distance which uses real-time up close). I can take some upclose pictures when I get to the office to show you the difference, directional looks less than half of the resulution of a spot light projected on the same mesh with same settings

have you tried to adjust baked shadow angle VS baked shadow radius?

Also lightmap debug views can be helpfull to narrow down the problem

Yepp, doesnt help. But I will get some detailed screenshot when I get to the office later today

@fguinier All right, so here is spot zoomed in. Still very low res (40 isnt very high). But its acceptable in my case

Here is dir.light. Now we got alot of edgy squares building up the edge of the shadow

The effect is very visible in game.

Interesting find, a directional light on its own, the usual rough edges

If overlapped with a spotlight it gets smoothed out

Does the same problem happens with baked light (rather than mixed) ? Also does unselecting ‘compress lightmap’ in the lighting window help?

Mixed or baked doesnt matter. Havent tried compressed but cant imagine it will make a difference since it works for spotlights and pointlights. But can try when I get to the office, thanks.

Btw, its really easy to reproduce the problem. Just import a cube and a plane into a empty scene mark them as static, set the directional light to mixed or baked and bake it. If you want to try for yourself. Present both in 2017.4.27 and 2019.1.2

Compression does not cause it. But it does add to the problem a bit, but its not the root of the problem. Here with compression off

I did a quick test with the repro as suggested and spot and directional seems to react the same for me? I can see artefact from linear filtering of the lightmap with high intensity light and sharp shadows however that is true for both directional and spot. I think the problem boil down to adjusting the baked shadow angle then see Unity - Manual: Lights

Hi, I use the default settings more or less in a empty scene. Precomputed real time disabled. Sadly the angle setting does not create satisfactory results. I use intensity of 1 and indirect intensity of 1.

I can get a screenshot on my settings when I get home but they are more or less default.

edit: I see you have the settings in screenshot above

Here is a repro.

https://drive.google.com/open?id=1mXj9zc0dK1D0Or_Y1u8pXwX-sygLFRl7

Our game have about 6 gigabyte of lightmaps at compressed. Unticking compressed really isnt an option for us. As you can see spotlight looks great even with compressed

Thanks for the repro, so the problem here (repro is using mixed mode) is the format of the shadowmask. by default when compress lightmap is true shadowmask are using RGBA16bits aka uncompressed 4 bits per channel. This indeed does not cope with high intensity light and smooth soft shadows (thus it would fail for the spot as well provided the spot would have an equally high intensity). The reason we use that format is because shadowmask channels represent visibility from different light source, so compression algorithms could introduce light leaks.

However this is a very generic approach! Knowing the data and target platform you can do a few things to improve the situation here:

  • Knowing the maximum amount of mixed overlapping lights you could select texture format with fewer channels. For example if only the directional light is using mixed lighting you know that you only need one channel and can use R16 to match memory footprint of the generic compressed version but for even higher quality.
  • Knowing the platform and data you can try compressed formats, for example on PC/Mac/Linux BC7 is a really good compression algorithm that leak very little among channels. I would recommend to try it on your game if targeting those platforms.

You can change the texture format directly on the shadowmask asset in the project folder:
4547146--421975--upload_2019-5-16_10-53-56.png

4547146--421972--upload_2019-5-16_10-53-24.png

In the case of baked lightmap i would also investigate texture format in regard to the target platform, finally in regard to 6GB of lightmaps have you considered crunched compression? Unity - Manual: Texture Import Settings

1 Like

Allright, thanks will have a look.

We only have overlap between directional and 1 more mixed mode light at various, places. We only target windows at the moment, but are looking into supporting PSVR and possible the Oculus Quest later. Will look at changing compression for the shadowmask thanks. We do not turn on/off the mixed mode lights, only use it to get shadows from dynamic objects and for specularity on static/dynamic objects. We cant ommit the shadowmask entirly? Or maybe its used to correctly cast shadows? I remembered before Shadowmask mode mixed mode lights didnt work properly.

We cant ommit the shadowmask entirly?
It is needed to get baked shadows in shadowmask mode. Details here :slight_smile: Unity - Manual: Light Mode: Mixed

Yeah I know you redid the mixed mode in 5.6 it was completly broken before that. I will experiment with it when I get to the office, thanks

Not much changed sadly, here is default

BC7