Search Unity

Enlighten and Preserving UV's

Discussion in 'Global Illumination' started by pluhn, Nov 19, 2014.

  1. pluhn

    pluhn

    Joined:
    Jul 27, 2010
    Posts:
    42
    Can anyone else confirm that Enlighten does not preserve UV's when baking despite "Preserve UV's" being checked? I have a mesh with a UV2 channel that I want used for the lightmap, but Enlighten still separates UV elements and stretches/rescales them. "Generate Lightmap UV's" is also unchecked in the mesh settings. Is there another method to using the UV2 channel as is?
     
  2. Jesper-Mortensen

    Jesper-Mortensen

    Unity Technologies

    Joined:
    Mar 15, 2013
    Posts:
    232
    So to separate the issues there are two sets of UVs here. One set is for realtime GI lightmaps and the other is for baked GI lightmaps.

    If you uncheck "Generate Lightmap UVs" the UVs that passed in should be used for the baked lightmaps directly, it will of course pack the instances together into atlases with some padding between them, but should leave the UV layout as is.

    For realtime GI lightmaps the situation is slightly different. In order to optimise both the precompute and runtime we attempt to merge together small charts, which will not contribute much to the bounced lighting using the "AutoUVs" feature. This means that surface detail and layered objects (such as carpets and debris) can be projected into larger single charts. If "Preserve UVs" is checked then we disable this and use the UV islands as is. We still pack and scale the charts for the realtime lightmap layout because it is tightly packed and we want to avoid overlaps when rendering from them. So the realtime charts are packed with a half pixel border around them. This ensures that we get no leaking when rendering from them.

    The "Preserve UVs" feature is meant as a way to preserve the shape of the UV islands in the output. This is because the realtime GI can stitch together matching edges in UV space such that seams in the indirect lighting can be avoided. We do this for the builtin sphere and capsule.
     
  3. pluhn

    pluhn

    Joined:
    Jul 27, 2010
    Posts:
    42
    Thanks for the detailed response. I think the problem I'm having is with Unity repacking the UV's. Each texture is a separate mesh with a custom vertex blend shader, but I need to light them as if it's all one surface; eventually there will be trees that will cast shadows into the meshes. I'm targeting mobile, so real-time shadows and GI aren't really an option.

    Here's the mesh before lightmapping:
    before.jpg

    And after:
    after.jpg

    So there's visible seams where the meshes meet, and it looks like the bunker UV islands got scaled down too far or something. Here's my UV2:
    UV2.jpg

    And what the lightmaps Unity creates look like:
    Lightmap-0_comp_light.jpg
    Lightmap-1_comp_light.jpg

    What I'm looking for is the lightmap to just be what my UV2 looks like. I believe this was possible with Beast, but now not so much.

    On a similar note, when will SpeedTree trees cast shadows in lightmaps? I understand this isn't supported yet?
     
  4. Jesper-Mortensen

    Jesper-Mortensen

    Unity Technologies

    Joined:
    Mar 15, 2013
    Posts:
    232
    Hmm, can I get a repro for this? Not exactly what I was expecting.

    >> when will SpeedTree trees cast shadows in lightmaps? I understand this isn't supported yet?
    This is on the roadmap. The preferred way to light trees would be to use probes to light the tree and for baking we need to support probelit props casting shadows onto the lightmaps.
     
  5. pluhn

    pluhn

    Joined:
    Jul 27, 2010
    Posts:
    42
    I've submitted a bug report along with the entire Unity project.
     
  6. Jesper-Mortensen

    Jesper-Mortensen

    Unity Technologies

    Joined:
    Mar 15, 2013
    Posts:
    232
    Kragh and melkior like this.
  7. st-VALVe

    st-VALVe

    Joined:
    Jan 8, 2014
    Posts:
    13
    Custom created lightmap uv still not working in Unity 5. You know?
     
  8. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,716
    They sort of do. There's an option in 5.3 I believe, that makes it not split the UVs at hard edges.
     
  9. clevermango

    clevermango

    Joined:
    Jan 7, 2015
    Posts:
    32
    I have just posted on the forum now, regarding Enlighten UV layout & Bake issues. Having just seen this post, I believe I am having the same problem. I am using 5.3 & the 5.4 beta, both producing the same issues. In essence, I am trying to retain the secondary (lightmap) UV map from 3DS Max, however Enlighten is packing it in a very small space within the objects UV space, despite setting Enlighten up with all of the correct settings. The result of this, is a very low resolution bake result. I have been seeing very wasteful and ineffective UV spacing with Enlighten for quite some time now, hence my use of Real Time. However, I now have a case where I must Bake a large environment. I cannot see a way that I can use Enlighten effectively for this purpose without compromising on quality, and accepting the engines downfalls.

    (http://forum.unity3d.com/threads/enlighten-bake-and-uv-layout-problems.413584/)