Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

visible squares in baked lightmap

Discussion in 'Global Illumination' started by abductor, May 7, 2020.

  1. abductor

    abductor

    Joined:
    Apr 19, 2017
    Posts:
    18
    Hello,

    this one should be easy for you guys: What do I need to change to get a nice light cone from that truck?
    I use baked lightning and the truck has two spot lights attached.

    But there is a square visible. I already increased the Lightmap resolution in the lighting settings, but to no avail. Or is this maybe a terrain setting I have to adjust?

    Bildschirmfoto 2020-05-07 um 16.08.28.png
     
  2. uy3d

    uy3d

    Unity Technologies

    Joined:
    Aug 16, 2016
    Posts:
    187
    can you post a screenshot of your lighting settings, and also a screenshot of the baked lightmap with texture resolution overlay debug view that you can select in the scene view's top left corner (should say "Shaded" by default).
     
  3. abductor

    abductor

    Joined:
    Apr 19, 2017
    Posts:
    18
    Hi,
    okay. Though I`m not sure about the 'texture resolution overlay debug view'. As I understand this is related to the post processing stack. I disabled my post progressing volumes and the squared sections remain: sc1.png

    sc2.png sc3.png sc4.png
     
  4. abductor

    abductor

    Joined:
    Apr 19, 2017
    Posts:
    18
    Any ideas?
     
  5. ADufay

    ADufay

    Unity Technologies

    Joined:
    Jan 2, 2020
    Posts:
    30
    Hello,
    are the spot lights from the truck baked or realtime ? You can see that by going to the Light Explorer window (window->rendering->Light Explorer).
     
  6. sameng

    sameng

    Joined:
    Oct 1, 2014
    Posts:
    172
    This is a compression issue, I have the same problem.

    If you turn off "compress lightmaps" it should be much less blocky.
    There's something weird with the compressor on lightmaps that makes it really blocky.

    I would love a solution that compresses the lightmaps without making it so blocky...
     
  7. abductor

    abductor

    Joined:
    Apr 19, 2017
    Posts:
    18
    They are all baked lights
     
  8. abductor

    abductor

    Joined:
    Apr 19, 2017
    Posts:
    18
    Hey @sameng

    I just tried that. And besides the lightmap size (0.8MB compressed, 4.7MB without compression), there is no difference in the results for my case :( The square remains.
     
    Last edited: Jun 9, 2020
  9. abductor

    abductor

    Joined:
    Apr 19, 2017
    Posts:
    18
    I just had the idea of using a plane which i placed 0.1 units above my terrain and marked as static. And the result speaks for itself:

    Terrain with sand layer:
    Bildschirmfoto 2020-06-09 um 21.59.30.png


    Plane with default material:
    Bildschirmfoto 2020-06-09 um 22.01.27.png

    Plane with sand material:
    Bildschirmfoto 2020-06-09 um 22.04.20.png

    Seeing that it is working fine with a plane, I assume it must be somehow related to my terrain settings
     
  10. ADufay

    ADufay

    Unity Technologies

    Joined:
    Jan 2, 2020
    Posts:
    30
    I looked again at the screenshot of your terrain version of the scene that shows the texel resolution.
    The texel resolution for the terrain looks quite low, sorry for not noticing that before.
    Using a plane instead might have made you use a much better resolution since the default resolution is much higher on planes than terrains.

    You can still use the terrain and fix the issue by increasing the scale in lightmap of the terrain.
     
  11. abductor

    abductor

    Joined:
    Apr 19, 2017
    Posts:
    18
    @ADufay I experimented a little with the lightmap settings of the terrain and the baked lightmap looks much better now:
    Bildschirmfoto 2020-06-11 um 00.13.24.png

    However, switching the view back to "shaded" still shows some smaller square effect:
    Bildschirmfoto 2020-06-11 um 00.16.07.png

    my current terrain lightmapping settings:

    Scale in Lightmap: 0.25 (the max value before the atlas warning appears)
    Lightmap Parameters: scene default parameters
    Info text is saying 'Terrain is chunked up into 64 instances for baking'

    Is there a another terrain configuration parameter to further optimize this?
    Please be aware that the current results are already sufficient for my requirements ;)

    Btw. increasing the values from the lighting tab (lightmap resolution to 40 texels and lightmap size to 1024) did not have any noticeable impact.

    Thank you so far for your help!
     
  12. DavidLlewelyn

    DavidLlewelyn

    Unity Technologies

    Joined:
    Aug 14, 2012
    Posts:
    29
    Hi @abductor,

    Are you bound to using Forward rendering for this project, or can you use a Deferred path? Is there a hardware reason why you would be bound to forward? For example are you targeting older mobile hardware?

    Note, if you are using URP, you will currently be obligated to using Forward.

    If it is possible to use Deferred, I would switch to this and then make the lights for the vehicle above, realtime. This will remove the need to use such high resolution lightmaps to capture accurate penumbra for the spots you are using. High texel density and terrain is a recipe for memory problems down the line. A nice additional benefit here will be faster iteration times without needing to rebake to see changes.

    If it absolutely necessary to see the effect of the bounce light, maybe try marking these lights as "Mixed" and then using either Shadowmask or Baked Indirect modes from the Lighting window. This will enable you to use realtime direct lighting, with baked Indirect (bounce).

    I can also see that the post processing bloom is interacting with your higher luminance areas. This is also propagating the texel artefacts from your low resolution lightmaps and exaggerating the effect.

    As a final remark, I'd say that your intensities were not sufficient to get a good response from bloom. You want a clear separation in value between the bright parts of the Scene, and the ambient light. This allows you to set a higher threshold for the bloom. Otherwise, things will tend to look hazy and washed-out.

    Hope this helps.
     
  13. abductor

    abductor

    Joined:
    Apr 19, 2017
    Posts:
    18
    Hi @DavidLlewelyn

    I want to cover a wide range of mobile devices, also older models. That`s why I decided to go with forward rendering.

    Not sure about the performance impact when using realtime lights, but I read the docs and decided to go with baked lights straight away. Going mixed mode and also using realtime lights requires more testing on different mobile devices from my side tbh. But using it for few objects only (like the truck lights) should be a good compromise. So I will definitely try that.

    Regarding the bloom effect: Not sure if I understood your point correctly. Yes, I know that this also increases the square effect a little.
    But concerning the washed out look: That is exactly what I needed for empathizing my nighttime atmosphere. I think it fits into the general style I am trying to archive.
     
  14. DavidLlewelyn

    DavidLlewelyn

    Unity Technologies

    Joined:
    Aug 14, 2012
    Posts:
    29
    If you are bound to Forward rendering, then yes, using many lights which affect the same terrain will seriously hurt performance. I would consider breaking the terrain into smaller tiles if you do wish to continue with this approach.

    This will allow you to change the lightmap texel density per tile, to ensure you only use the higher resolution where needed. It also means each tile is likely to be affected by fewer realtime lights. Ideally, you should consider no more than 3 or 4 realtime lights per terrain tile, max. Even then it will be costly.

    Also consider making key, gameplay relevant lights Mixed mode, and profit from the benefits of realtime direct lighting (shadowmapped shadows, realtime direct specular) while retaining the bounce from the indirect. As inidirect is inherently more diffuse, you can get away with much lower texel density for the lightmaps. This will save you memory.

    Regarding reduced contrast enhancing your nighttime look, this is an aesthetic choice that isn't for me to comment on. However, I would seriously consider using a fog rather than bloom to achieve this. You will have much greater control and can then reserve the bloom to accentuate lights. Bloom is really intended to simulate imperfections in a lens, so using it everywhere implies that the lens is misted/greasy.
     
    abductor likes this.
  15. abductor

    abductor

    Joined:
    Apr 19, 2017
    Posts:
    18
    Thank you very much for the tips. Using multiple connected terrains seems the way to go. Also good explanation of the bloom effect. I played a lot with the post processing effects until I found a setting which fits into my idea of how the game should look, in addition to the shaders and geometry I used.
    So my approach on that was rather experimental driven instead of knowing which knobs to turn in advance.

    Talking about fog, do you mean the post processing fog effect? Because that only seems to be available for deferred rendering