Search Unity

Baked shadows are very soft

Discussion in 'General Graphics' started by Tidvis_Martin, Mar 27, 2019.

  1. Tidvis_Martin

    Tidvis_Martin

    Joined:
    Mar 12, 2019
    Posts:
    24
    Hello Unity forum!
    I've recently returned to light baking in Unity and I've encountered a slight problem with controlling the softness of the shadows I get when I bake. The baked shadows are nowhere near as sharp as I want them (Note the image below showing the mixed lighting is sharper than what I am aiming for but it demonstrates the point well). I've had a look around but there wasn't a lot to find and what did exist seems to be several years old, unless there is a search term I don't know that would yield more results.
    I've had a go at increasing the resolution from the default 512 to 1024 without much luck, I've also tried to lower the environment intensity too see if it was softening the shadows, it did not seem to do anything and I have also tried to increase the texel resolution but alas, to no avail.

    Does anyone have some tips I could try? I am currently trying to bake a 2048 map but the bake time went from 1-2 mins to 60-90 mins so I am a little nervous, especially since this is just a test scene with one object and a smaller ground plane. The real scene will be a much larger terrain with hundreds or thousands of objects casting shadows.

    Thanks for the read!
     

    Attached Files:

  2. Tidvis_Martin

    Tidvis_Martin

    Joined:
    Mar 12, 2019
    Posts:
    24
    Anyone have any idea? Or an obvious question/answer?
     
  3. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    Increasing the lightmap resolution is kind of the only way to fix this. Specifically the texels per unit setting. Just increasing the overall lightmap resolution may not have any affect as that controls the size of the lightmap textures used, but not necessarily the texel coverage of an object. It should be noted that you can adjust the relative lightmap resolution per object from the lighting window.
     
  4. Tidvis_Martin

    Tidvis_Martin

    Joined:
    Mar 12, 2019
    Posts:
    24
    Hey @bgolus , thanks for the reply!
    I just got back to this yesterday after having to work on other things. I had a look at your suggestions but could not seem to get too much further. I kept the settings the same but cranked the "Lightmap Resolution" to 300 texels pr. unit and hit bake but did not see any noticeable difference, kept the settings the same as seen in the original post with the exception that I also tried to increase the lightmap padding too 10.
    I've also had a look at the custom Lightmap Parameters, most of them were pertaining to Precomputed Realtime GI, the only settings for Baked GI/Mixed GI were AA samples, baked tag and push off unless I am to use Enlighten, however, this does only give access to some more settings, none of which seems to be that much more relevant (or are the looks deceiving?).
    Anyways I've had more of a poke around and noticed that after I cranked the size of my ground plane up for a test to see how bad the bake times with Enlighten were vs the cpu or gpu progressive I noticed that the scale of the ground (at least when dealing with large scale change) does have a very noticeable impact on the sharpness of my shadows. When my ground plane was at 100x100 the shadows looked like hot breath on a cold window, I figure calling it a smear would be to give the sharpness more credit than it deserves. When I scaled down my plane to 25x25 I got back where I was in the original posts pictures. Finally, I did a test where I scaled down the plane to 5x5 and make a 2x2 arrangement of them to cover the ground under my building, now we are talking sharpness!

    On a final and off-topic note, sorry to break the unspoken rules of a topical forum thread, however, just today I seemed to have a 1/5 chance of having my light mapper sorta quit on me and just start giving me completely dark and orange-tinted scene, would you happen to have any experience with that?

    Thanks for the read!

    Images:
     

    Attached Files:

  5. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    A single object's lightmap resolution is limited by the lightmap size. If you have the default Lightmap Resolution set to 300, but you have an Lightmap Size of 1024, then a plane larger than ~3.4 x 3.4 units will not be able to have that 300 texels per unit lightmap resolution. (3.4 * 300 = 1020). You can get a sense of the actual lightmap resolution per surface by setting the Scene view to Baked Lightmap or UV charts preview mode with Show Lightmap Resolution checked on.
    upload_2019-4-4_9-5-31.png

    The checkerboard texture that appears on objects will show the actual lightmap texel density on that object; 1 lightmap texel per box.

    You have to play with the texels per unit, the lightmap size, the lightmap settings on the renderer component, and potentially split up your meshes into multiple objects to get the resolution you might want. And yes, sharp shadows will lead to very long bake times (potentially hours). Some production games that use a lot of Lightmaps, baking can be several days.

    This adds empty pixels between the lightmap UVs to reduce lightmap bleeding. Increasing that value will potentially reduce the overall texel density as more of the lightmap will be left empty. I suggest going into the lighting window and looking at the baked UV charts to get an idea of what your settings are doing.