Search Unity

Question How to keep hard edges when using lightmapping?

Discussion in 'Global Illumination' started by Peter77, Jun 12, 2020.

  1. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,619
    I'm wondering how I can keep hard edges when using lightmaps. Think of some kind of low-poly art style with visible hard edges on your 3D models.

    When using lightmaps, these hard edges become very soft, depending on lightmap resolution. Please see the images below for examples.

    upload_2020-6-12_16-59-11.png

    upload_2020-6-12_16-59-19.png

    It seems I can workaround this issue by increasing the lightmap resolution to a ridiculous high number and use "Directional" lightmapping mode. Unfortunately, this causes a huge memory overhead, so it's not an option.

    I don't mind if the baked GI and shadows are blurry.
    I really just want to keep these hard edges somehow.

    How would I do this?
     

    Attached Files:

  2. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,796
    Hand author your lightmap UVs and create seams where you want hard edges.

    WIth Unity auto LM generation, just set Angle to 0.
     
    Marc-Saubion and Peter77 like this.
  3. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,619
    Thanks for your answer!

    Setting "Hard Angle" in the Model Importer to 0 seems to work. I had to increase the "Pack Margin" quite a bit (from 4 to 45) too, otherwise it causes severe lightmapping artifacts. I've to test this on Monday in the actual project, but in the test-case I posted above it looks fine.

    Could you explain that for me who isn't an artist? How would I layout the UVs to achieve these hard edges?
     
  4. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,796
    Careful with pack maring, since if you use higher "lightmap resolution" you will need a lower value and will be wasting space. 2020 actually has a feature to help with that, that I complained about, but anyway.
    I have no baseline on how much you know about UVs, so I don't quite know where to start, so I made a messy incoherent thing... and since I spent quite a bit of time on it now, so I'll post it anyway and hope that it makes some sense.

    Please ask me if you have questions, I'll try to be more coherent...

    So, this is what I meant with having seams between the edges (the bottom example):

    UVs.jpg

    And here are the scribbles of a madman my attempts to further explain things.
    UVs.jpg
     
    kristijonas_unity and Peter77 like this.
  5. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,619
    Thank you so much for the reply! It helped me a lot to understand the issue.

    I'll discuss this next week with our artist, whether that's the UV layout we tried already and greatly take your offer to ask another question, if we run into further issues. :)