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.

Question Strange stains after baking light

Discussion in 'Universal Render Pipeline' started by Mikolaj_Mal, Oct 5, 2022.

  1. Mikolaj_Mal

    Mikolaj_Mal

    Joined:
    Oct 5, 2022
    Posts:
    3
    Hello, I have problem with baking light. After generating lightning, weird stains appear around some objects. I checked Generate Lightmap UVs for every object, changed the values mentioned in the Brackeys tutorial about lighting and nothing of that make much of a diffrence. Has someone idea what I am doing wrong? LightProblem.png LightProblem2.png LightProblem3.png
     
  2. burningmime

    burningmime

    Joined:
    Jan 25, 2014
    Posts:
    676
    This is somewhat endemic to how light baking works -- light leaks, dark leaks, UV issues, stretching, etc -- but there are lots of ways to improve it. I spent way too much time investigating and experimenting, so here's 3 methods to make it a lot better:

    1. Combine your static meshes. Manually tweaking lightmap UV scale is a PITA and is mostly just guesswork. I started off using Mesh Baker for this and eventually wrote my own to fix some issues I had with Mesh Baker. That way, the UV unwrapping can be done across the whole object instead of some meshes getting way too much lightmap space and others getting too little (and depending on the unwrapper, can also do things like maintain continuity across like a pencil sitting on a desk instead of having the pencil and desk be separate objects on the light map). As a bonus, you'll get a dramatic reduction in draw calls and you'll need fewer light maps, saving on memory.

    2. Speaking of, use a good unwrapper. Xatlas is open source. Bakery has an API wrapper for it, but you can just grab the DLL and do it yourself. Xatlas does quite a decent job, particularly at maintaining scale.

    3. Use a better baker. I use Bakery (you can read about it here and some of the problems it solves). This requires you to buy something so it's not an option for everyone but it produces vastly better light maps.
     
    Mikolaj_Mal likes this.
  3. Mikolaj_Mal

    Mikolaj_Mal

    Joined:
    Oct 5, 2022
    Posts:
    3
    Thank you very much for your answer!

    It looks like there is actually a problem with overlapping UVs. I've reduced number of meshes, but some problems still occur. Either way there is a big improvement. I will conisder also better baker.
    Thank you!
     
  4. RevC2

    RevC2

    Joined:
    May 2, 2021
    Posts:
    33
    There are tools like Bakery that are really good to work with, but overall if you study really well how the Progressive lightmapper works it can work like a charm. I'm thinking about doing a series of video to explain everything in detail.

    BTW, if you really don't understand what's the technology at the base of something, other tools could alleviate some struggles, but then again if a problem shows up you still have to understand why and how to fix it. I witnessed people getting mad at overlapping uvs, or having splats due to missing faces in models so it becomes more a thing on knowing how the system works (how to author meshes the correct way) more than a progressive lightmapper's problem per se. :)
     
    Mikolaj_Mal likes this.
  5. Mikolaj_Mal

    Mikolaj_Mal

    Joined:
    Oct 5, 2022
    Posts:
    3
    Yeah, it is problem for me to understand how can I change my UVs and meshes to cooperate better with lightmapper.

    I would love to see those videos. Let us know if you made any or if you have already some videos and where to find them. :D