Home Unity

Directional Specular LightMap causing bad results with custom LightMap UV channel

polycounter lvl 10
Offline / Send Message
nevermind polycounter lvl 10
Hey guys.
This is an issue that's been causing me headache the past couple days. When baking lightmaps with the "non directional" option, my maps look fine. But I need to use the "specular directional" option in the end since I will be using spec maps, and the results are far less than satisfactory.

Here's an image that shows what I'm talking about using an example mesh. I created my own lightmap UVs in a second channel so that I could control my seams and softness / hardness of edges. When baking "directional specular," however, the edges that are fine in "non directional" get really jacked up. The only way I can avoid this right now is letting Unity generate UVs for my mesh, but this results in hard many hard edges and seams in incorrect places.

sg2N0dP.png

Just curious if the problem is user related and I'm missing something here.
Thanks a ton!

Replies

  • Avvi
    Options
    Offline / Send Message
    Avvi polycounter lvl 3
    Just a thought: try exporting to FBX in other software. Maybe it's a tangent related issue
  • echofourpapa
    Options
    Offline / Send Message
    echofourpapa polycounter lvl 4
    If those weren't lightmaps I would say that it's padding issue. That may still be the case, maybe they are packed too close together?
  • nevermind
    Options
    Offline / Send Message
    nevermind polycounter lvl 10
    Avvi - I originally exported out of Max, so I tried Maya. Same result. =(

    echo - I don't believe its a padding issue. Here's a pic of the lightmap baked that I opened in photoshop:
    LBCT4ze.png
    None of these artifacts seem to be visible in them.
    There is no black line, like the model shows...
    It looks like the errors are happening at smoothing group change areas - which is odd, because that should have nothing to do with UVs and doesn't happen in a Non Directional Bake.
  • echofourpapa
    Options
    Offline / Send Message
    echofourpapa polycounter lvl 4
    In Unity a smoothing group edge is a split seam, because it has to normalize the vertex count between verts, normals and UVs. So even in Max or Maya list the UV as an island Unity will still register a split seam there. Unity also seems to be doing some funky UV packing behind the scenes automatically too(depending on map type, as an optimization).
  • Avvi
    Options
    Offline / Send Message
    Avvi polycounter lvl 3
    Oh, that's a good point. enter Lighting > Object and press Preserve UVs. As a second test, leave Preserve off but minimize angle and try larger distance.
    As echofourpapa said, remember to treat every hard edge as a seam on lightmap uv.
  • nevermind
    Options
    Offline / Send Message
    nevermind polycounter lvl 10
    Thanks for the responses guys! So far, I've gotten more help here than the actual Unity forums, which seem to be riddled with lightmap issues.=P

    I attempted a few bakes with preserve UVs on and off and tried a few different amounts in UV max disntance / angle, resulting in no change in the bakes=(

    When I split the UVs in those problem areas, the hard black lines go away and the bake looks "correct", but then I lose the soft bleed that I had before in the non directional bake that made the hard edge seem much softer.

    Example: first one is with connected edges, where I intentionally want a bleed.. second is with detached
    7Nh7spv.png

    Any way to get this effect in the directional specular bake other than adding more geo?
  • echofourpapa
    Options
    Offline / Send Message
    echofourpapa polycounter lvl 4
    You are baking directional specular maps, right?

    In the lighting tab at the bottom when you have an object selected it will show you how your different maps sit on your UVs(Unity used several UV channels, not just one). You might be able to identify what map and UV layout is causing the problems.

    I've been experimenting today I think I encountered your problem. I'm using a single directional light, and I get this problem in both directional and directional specular. It might end up being UVs. but I know that adjusting bounces and resolution greatly affect it.

    Here's what I'm getting with Unity primitives, single directional light and baking:
    xpHKzaS.png
    s2LuLUh.png
    58xruqO.png
    GbTYozG.png
  • echofourpapa
    Options
    Offline / Send Message
    echofourpapa polycounter lvl 4
    Here's some more updates that makes me think it is a UV padding issue:

    Here's the subject prop, a barrel:
    zKfN359.png

    I packed the lightmap UVs manually in Blender, to get something packed really tight:
    uMNoGDi.png

    I set it to Preserve UVs and baked, bad lines on seams:
    WJNRScL.png
    l0glT0M.png

    Taking a look at the lightmap I see this:
    3gGJv3x.png
    Not only does Unity repack my UVs(why?) but the padding is pretty awful:
    z0P6cIr.png

    Now I let Unity Generate Lightmap UVs with angle set to 120, and the barrel looks great:
    nn28kx9.png

    On closer inspection, I found a few problem areas, here:
    3x8tT4S.png
    and here:
    ZKYRj8O.png

    The textures had been covering them up, so I didn't notice them until I removed them. On the light map those areas are here:
    ylblguE.png

    As you can see the resolution is pretty low and the padding about a pixel or two.

    I ran a test, I doubled the atlas size and baked GI texel resolution, and the problems go away, and there is at least some padding:
    UbIPvdS.png
  • echofourpapa
    Options
    Offline / Send Message
    echofourpapa polycounter lvl 4
    I tested this further, used the tightly packed UVs I made, had Preserve UVs checked and set Scale In Lightmap to 3 ( the atlas is still set to 2048 ):

    RYBK2tm.png

    I'm getting better padding and a better final result.

    Also, it turns out that the lightmaps are mipped(I'm not sure why this surprises me). So the problem should get worse the further you are and better the closer you are.
    Close:JU2g7un.png Far: GrbsWBf.png
  • Eric Chadwick
    Options
    Offline / Send Message
    Nothing helpful to add to this, except to say thanks for sharing your shots and findings.

    I'll be lightmapping again soon (I lightmapped a ton in 4.2, a couple years ago) so I'm sure I'll be running into the same issues.
Sign In or Register to comment.