Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question UPDATE: How do I bake proper lightmaps for curved geometry?

Discussion in 'Global Illumination' started by ebaender, Dec 14, 2020.

  1. ebaender

    ebaender

    Joined:
    Oct 29, 2020
    Posts:
    97
    I'm having trouble baking proper looking lightmaps for some wavefront objects with problematic geometry. The flat parts look good for the most part, but anything curved has a lot of banding even at high lightmap sizes and resolutions. The fragmented faces in and around the arches also look horrible. Is there something that can be done with the lightmapper or lightmap UV generation settings to mitigate the problem, or is the mesh just not usable? There is no UV overlap on the lightmaps that could be causing this.

    By the look of it the arch was created using boolean operations, which definitely created more faces than necessary and subsequently more opportunities for things to go wrong. But I feel like there's something wrong with the settings too since even the clean faces at the back of the inner arch look really bad with tons of banding.
     

    Attached Files:

  2. kristijonas_unity

    kristijonas_unity

    Unity Technologies

    Joined:
    Feb 8, 2018
    Posts:
    1,080
    Author lightmap UVs by hand in a DCC tool. Make sure that you stitch UV shells together for the inner side of the arch, otherwise, you will see seams in the lightmap.
     
  3. Bordeaux_Fox

    Bordeaux_Fox

    Joined:
    Nov 14, 2018
    Posts:
    589
    Looks like your arch is flat shaded and not smooth shaded.
     
  4. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,631
    Nah that's not the issue.

    EDIT: Maybe I'm wrong, maybe that's true as well? It could be worth also trying to generate the normals.

    The generated lightmaps produce a whole bunch of seams there and there aren't enough texels to stitch seams or have enough detail to make it look somewhat continuous.

    The solution is to hand author the lightmap UVs as @kristijonas_unity says.

    People shouldn't rely on the generated UVs as much as they do. Even if Unity's generation was perfect, I believe this would be a case it would still be impossible to get perfect UVs without hand authoring.
     
  5. ebaender

    ebaender

    Joined:
    Oct 29, 2020
    Posts:
    97
    Coming back to this with a very late reply, thank you for the suggestions.

    I've been trying to hand author the UVs in Blender, but the problem is that the model is not a single mesh, but rather a humongous collection of unconnected objects containing a single mesh each. That's probably why it looks flat shaded no matter what.

    object-hell.png
    I can spend forever creating a seam to unwrap along, but it just gets ignored as if it isn't even there. I can't manage to turn all the separate meshes into a single mesh either, even when joining all the separate objects together and merging vertices by distance or using BoolTool, the end result is still unusable.

    nobool-obj-lightmap.png nobool-obj-shaded.png
    In my desperation I've gone as far as re-modelling the entire thing by hand without using boolean operations in TrenchBroom, since that's the only thing resembling modelling software I can actually use. That helped a bit with the fragmentation around the inner arches, but overall the result is still unusably bad due to the unavoidable bleeding along some of the edges.

    culling-view.png
    I've also spent way, way too long screwing around with every single lightmapping related setting in Unity, all to no avail. All I've managed to figure out is that it's not related to UV overlap, but the affected areas always show up in the culling view. Changing lightmap size, resolution, padding, sample sizes, filtering, compression, angle / area error and backface tolerance only varies the problem slightly, nothing puts a stop to it. I wish there was an option to just render all the lightmap segments slightly larger than their corresponding face margin, that would immediately solve this.

    I'm out of time and things left to try at this point, but if anyone with better 3D skills than me wants to give cleaning up the the .obj into a single mesh with proper lightmap UVs und normals a shot (primary UVs need to stay intact), I can offer 50$ over paypal as an incentive if it's done by sunday evening.

    The .obj is attached right here, the .txt extension had to be added to upload it.
     

    Attached Files: