Search Unity

Jagged Shadows in Baked Lightmaps (Unity 5)

Discussion in 'Global Illumination' started by BaconSanwich, Apr 7, 2015.

  1. BaconSanwich

    BaconSanwich

    Joined:
    Mar 16, 2013
    Posts:
    19
    EDIT: Can everyone please upvote this bug so we can get a fix faster? Login and vote here:
    http://issuetracker.unity3d.com/iss...alias-when-blur-radius-value-is-larger-than-1

    ------------------------------

    Hey all,
    So I'm having an issue with very jagged shadows in baked lightmaps in Unity 5, and after searching a ton and trying every possible setting adjustment (that I know of!), I've decided to post the question here and see if anyone has a solution.

    What I'm seeing is very jagged edges in certain places in my shadows:
    (Scale: this is a large cliff wall, player being about a 10th of the height.)

    Upping the Baked Resolution only makes the jaggedness smaller, but it's still very harsh. In Unity 4, I remember an option for sampling (or something similar) which smoothed shadow edges without upping the resolution, and it looked great. I've tried messing with all different types of samples, direct light quality, etc, but the only thing that seems to really change anything at all is Blur Radius (which actually helps quite a bit, but I'd rather not blur all my shadows if I don't have to). Also tried the "Default-HighResolution" general GI parameter, but again it changed nothing about the jaggedness.

    The burn time for my scene is already between 5-7 hours per bake, which is crazy high if you ask me, and that's at a fairly low resolution (10 texels per unit). So increasing the resolution is probably not an option at this point (not to mention it doesn't soften the jaginess when doing test burns on this single object, just makes the jags smaller as I mentioned before).

    Is there something I'm missing? I've run out of things to try...
    Any help would be very much appreciated!

    Here are all my settings.

    Scene Lighting:


    Lightmap Parameters:


    Object Settings:


    Light Settings (using one single directional light):


    Project Quality Settings:


    Thanks very much in advance!
     
    Last edited: Nov 20, 2015
  2. BaconSanwich

    BaconSanwich

    Joined:
    Mar 16, 2013
    Posts:
    19
    Bumpity bump bump.
     
  3. Almakos

    Almakos

    Joined:
    Dec 13, 2013
    Posts:
    179
    I'd say it's the way your UVs are laid out
    maybe try to make an unwrap with fewer pieces...
     
  4. BaconSanwich

    BaconSanwich

    Joined:
    Mar 16, 2013
    Posts:
    19
    At first I thought that might be it as well, but as you can see above, the UVs are in one piece except for one small triangle.
    My guess is that this is more of an anti-aliasing/refinement/quality issue of some sort which I'm either missing or is broken... Any other ideas?
     
  5. Almakos

    Almakos

    Joined:
    Dec 13, 2013
    Posts:
    179
  6. Howard-Day

    Howard-Day

    Joined:
    Oct 25, 2013
    Posts:
    137
    Could you try shifting the auto UVs to a small number? Like 5? That may help, if I understand the visual style your're going for..
     
  7. KEngelstoft

    KEngelstoft

    Unity Technologies

    Joined:
    Aug 13, 2013
    Posts:
    1,366
  8. KEngelstoft

    KEngelstoft

    Unity Technologies

    Joined:
    Aug 13, 2013
    Posts:
    1,366
    Hi! To rule out the scaling as the cause, please try and assign a custom LightmapParameters with a higher pushoff value, that fixes artefacts on large objects.
    It could be a charting problem, would you mind filing a bug report so we can take a closer look if your problem persists.
    Thanks!
     
  9. BaconSanwich

    BaconSanwich

    Joined:
    Mar 16, 2013
    Posts:
    19
    So I don't think the scale is the issue since the object isn't very large. I've included a default Unity 3d Cube object in the shot for scale.

    I've assigned a higher pushoff value (from .0001 to .5) and it seems to soften the edge a tiny bit, but it's still definitely there:

    And here's a before shot (.0001) if you'd like to flip back and forth to see the diff:


    I'll file an issue and post the number in this thread for you.
     
  10. BaconSanwich

    BaconSanwich

    Joined:
    Mar 16, 2013
    Posts:
    19
  11. BaconSanwich

    BaconSanwich

    Joined:
    Mar 16, 2013
    Posts:
    19
    Just for fun I burned a comparison shot with Unity 4's lighting system, and it looks amazingly good!


    And this is Unity 5 at the same resolution:


    Again, I feel like there's some fundamental setting that isn't being considered as far as sampling is concerned, or something like that.
     
    vicator likes this.
  12. fredericomachuca

    fredericomachuca

    Joined:
    Nov 14, 2013
    Posts:
    26
    im having the same problem. its not an UV or scale issue.
    each day working with unity 5 I miss unity 4's lightmapping more and more lol.
     
  13. BaconSanwich

    BaconSanwich

    Joined:
    Mar 16, 2013
    Posts:
    19
    So after doing more tests, it looks like what I was afraid of. The GI anti-aliasing seems to have no effect on the aliasing of the lightmap whatsoever.


    If that's the case, then this is pretty bad... Is someone looking into this on the dev side?
     
  14. Almakos

    Almakos

    Joined:
    Dec 13, 2013
    Posts:
    179
    same story
    Screen-Shot-2015-04-21-at-11.20.48-am.jpg
    with directional/specular it looks super bad
     
  15. BaconSanwich

    BaconSanwich

    Joined:
    Mar 16, 2013
    Posts:
    19
    Can we get a fix for this asap? We can't get any sort of quality light burns until this is working.
     
  16. BaconSanwich

    BaconSanwich

    Joined:
    Mar 16, 2013
    Posts:
    19
    Anyone...?
     
  17. Bravo_cr

    Bravo_cr

    Joined:
    Jul 19, 2012
    Posts:
    148
    Same issue here:
    Captura de pantalla 2015-04-30 a las 16.35.13.png

    Unity 5 light mapping is slower and gives worst results than Unity's 4 Beast. I really miss the old system :(
     
  18. Sir-Spunky

    Sir-Spunky

    Joined:
    Apr 7, 2013
    Posts:
    132
    Edit: Just as I wrote this, I noticed that hiding my large ocean plane seems to reduce the distance between the jaggies, making them much less apparent. I'll try increasing the polygon count on my ocean and see if that helps.

    I'm having the same problem, but with realtime shadows. It seems to be related to self-shadowing. As you can see in the first screenshot, it's not related to shadow resolution in my case, as the other shadows look great.

    Bias is set to 0.1 and normal bias 0.4 on the sun directional light using soft shadows, and changing these values only moves the problem rather than hide it. Lowering shadow distance or camera clipping does not seem to make a difference.

    This is my biggest issue with realtime shadows at the moment.

    Skärmklipp 2015-05-02 17.20.59.jpg Skärmklipp 2015-05-02 17.11.49.jpg Skärmklipp 2015-05-02 17.12.13.jpg Skärmklipp 2015-05-02 17.13.18.jpg
     

    Attached Files:

    Last edited: May 2, 2015
  19. Ignifex

    Ignifex

    Joined:
    May 6, 2015
    Posts:
    11
    I am experiencing a similar problem with shadows when using a large plane for an ocean. This has little to do with lightmapping or geometry.
    It seems the effective precision in bit depth of the shadowmap decreases when a large plane is either casting or receiving shadow. Perhaps there is a mistake in the frustum computation that results in a very low near clipping plane or a very large far clipping value?

    EDIT: An example of the precision issue, clearly showing it is not a bias issue.
    Scene was constructed from an empty scene, with a plane (scale 20.000) at the origin and a box (scale [10, 4, 1]) at position [0, 3, 0].
    ShadowDepthPrecision.png

    EDIT 2: Opened a separate thread here, since this seems slightly off topic.
     
    Last edited: May 13, 2015
    BotHH, huemanru2 and Sir-Spunky like this.
  20. MrWhoof

    MrWhoof

    Joined:
    Oct 6, 2012
    Posts:
    17
    Has any one found a fix for this?
     
  21. BaconSanwich

    BaconSanwich

    Joined:
    Mar 16, 2013
    Posts:
    19
    Rumor on the street is Unity is aware of it and are working on a fix which is coming down the beta pipeline in an update, but not sure when the official fix will be released.. if anyone can chime in with more information it would be much appreciated.

    I'm pretty disappointed at how broken Unity 5 continues to be now months after its release.
     
  22. macdude2

    macdude2

    Joined:
    Sep 22, 2010
    Posts:
    686
    Yah, I'm not switching until 5.3 at least. Did the same with U3 to U4, seemed to work out pretty well.
     
  23. 8Infinite8

    8Infinite8

    Joined:
    Jul 27, 2013
    Posts:
    112
    I'm experiencing the same issue. Unity 5.1.2p2. Google brought me here.

    Notice the jaggies on the chair leg. There is no reason, they are mapped well and take up a large portion of the UV layout. Anti-aliaising samples does nothing.

     
  24. ronin3d

    ronin3d

    Joined:
    Jul 13, 2015
    Posts:
    30
    Can you show me your Uvs?
     
  25. 8Infinite8

    8Infinite8

    Joined:
    Jul 27, 2013
    Posts:
    112
    I don't think it has anything to do with the UV's.

    to do with the UV's.
     
  26. Teo

    Teo

    Joined:
    Oct 31, 2009
    Posts:
    564
    Try to use some decent seams before uv unwraping.

    EDIT: to don't look to critic.
     
    Last edited: Aug 18, 2015
  27. 8Infinite8

    8Infinite8

    Joined:
    Jul 27, 2013
    Posts:
    112
    Very constructive. Thanks. FYI the chair renders and bakes fine in UE4.

    I get zero errors from the UV mapping. Especially when baking in other applications!! The fact that Unity will totally alter UV1 or UV2 during light mapping is part of the problem.



    The UV's check fine in Marmoset. Thanks.

    Notice how Unity likes to ignore Preserve UV's even for UV2 during the lightmap process. It's a bug. It will do the same thing to UV1 or UV2. Unity will scale, shift, even cut the geometry.



     
    Last edited: Aug 17, 2015
    thempus likes this.
  28. ronin3d

    ronin3d

    Joined:
    Jul 13, 2015
    Posts:
    30
    It can be better but is not terrible.. is quite good.. try elements vertical or horizontal never in diagonal because you can get jagged lines. Maybe this is not the case but it could be...
     
    8Infinite8 likes this.
  29. 8Infinite8

    8Infinite8

    Joined:
    Jul 27, 2013
    Posts:
    112
    More evidence that this has nothing to do with the UV mapping.

    AA is not being applied during the lightmapping process, regardless of the Anti-alising Samples. Even if the chair legs take up a large portion of the lightmap.



     
  30. 8Infinite8

    8Infinite8

    Joined:
    Jul 27, 2013
    Posts:
    112
    Thanks. Surely AA should be applied here during the baking process, hence the bug? There is a setting for this but it seems to be ignored. We shouldn't have to baby sit every single process.

    UE4 handles this asset perfectly fine during baking.
     
  31. ronin3d

    ronin3d

    Joined:
    Jul 13, 2015
    Posts:
    30
    I have the same problem.. as you can see in my post
    http://forum.unity3d.com/threads/wrong-uvs.347863/#post-2251603
     
  32. 8Infinite8

    8Infinite8

    Joined:
    Jul 27, 2013
    Posts:
    112
    You totally ignored my post. "preserve UV" doesn't work. Unity will alter the UV's however it sees fit to pack. Rotate, move, scale etc.

    The chair maps totally fine. No smoothing issues, no normal issues (as visible in Marmoset). It tiles just fine. It is also split into parts.

    Anti-aliasing clearly isn't being applied during the baking process. It's a bug.
     
  33. Teo

    Teo

    Joined:
    Oct 31, 2009
    Posts:
    564
    You get same result with realtime GI?
     
  34. ronin3d

    ronin3d

    Joined:
    Jul 13, 2015
    Posts:
    30
    I am with you i think is a bug... what videocard do you have? Maybe some setting in your driver... just gessing... like you i am getting very frustated i see a lot of potential in enlighten but is full of bugs.. i also have the uvs incongruency problem and i will add. a lot of artifacts,light leaking,bad atlasing,slow render times and not smart enough to render just individual pieces.
     
  35. Teo

    Teo

    Joined:
    Oct 31, 2009
    Posts:
    564
    I doubt is a video card problem.
     
  36. rtargosz

    rtargosz

    Joined:
    Aug 22, 2012
    Posts:
    17
    To the OP: I don't see a screen shot of your model import settings. Do you have the Generate LightMap UVs option checked on the model? I was getting some very bad lightmap results until I enabled that setting.
     
  37. Jesper-Mortensen

    Jesper-Mortensen

    Unity Technologies

    Joined:
    Mar 15, 2013
    Posts:
    232
    So what you are showing are the UVs used for realtime. That's not going to shed a whole lot of light on the situation. I agree we haven't exactly named this too well. To view the UVs used in the baking then please select an object and select Baked Intensity in the "Lighting [Panel] -> Object -> Preview [Pane]" dropdown.

    Also, try using final gather to improve the baked lighting.

    In pre 5.2 we had bugs in the way UVs were handled so we have improved this in 5.2 and the results should be better there. If you are Pro customer you can grab it already. If not then wait till Tuesday.

    If that doesn't make your results better I will want to take a look.

    Cheers,
    Jesper
     
  38. Jesper-Mortensen

    Jesper-Mortensen

    Unity Technologies

    Joined:
    Mar 15, 2013
    Posts:
    232
    cliff_hardAngle88.png cliff_hardAngle10.png

    Had a look at the scene. The main problem is the UVs, they are all in a single island even though the normals should have introduced cuts between the faces, such that geometry with a hard cut between them end up in separate UV islands. If this does not happen there will be light/shadow bleeding between the faces which can show up as severe jaggies.

    This seems to be a bug in our unwrapper. Reducing the hard angle to 10 fixes the issue, but the angles between the faces are really obtuse so the default of 88 degrees should have caught that. So we will look into why this happens.
     
    hippocoder likes this.
  39. Jesper-Mortensen

    Jesper-Mortensen

    Unity Technologies

    Joined:
    Mar 15, 2013
    Posts:
    232
    cliff.png

    Nicer cliffs ;-)
     
    hippocoder likes this.
  40. alsharefeeee

    alsharefeeee

    Joined:
    Jul 6, 2013
    Posts:
    80
    Hello everyone;

    Actually for me the problem is still there even after unity 5.2.
    I have downloaded many 3d model from turbosquad from multiple modelers and the same problem keeps happening.

    lightmap.PNG
    please help me solve this, I never faced this in Unity 4!
     
  41. BaconSanwich

    BaconSanwich

    Joined:
    Mar 16, 2013
    Posts:
    19
    Hey all, first off, thanks for looking into the issue and for your responses. With that said, it has been suggested multiple times that the UV layout/unwrapping is the issue. While the UVs certainly have an influence over what the light bake looks like, it is still not solving the problem. In Unity 4.x, the UV layouts were identical, yet there was no jagginess at all. We have already identified multiple times within this thread that the issue is not with the UVs, but with the antialiasing which still after all this time seems to be completely and utterly broken, and has zero effect on the lightmaps whatsoever. Before assuming that a UV layout adjustment is the answer, please look into why the antialiasing is still broken. Adjusting the UVs will only go so far and is just a band-aid for a much larger problem.
     
  42. nickpappas

    nickpappas

    Joined:
    Mar 19, 2013
    Posts:
    18
    I've been following this thread for a few months now. This bug is probably the most painful of all the lighting bugs and is destroying the soft look of our game, "Lucky's Tale". Those jagged pixels are apparent everywhere. And none of these problems existed in Beast.


    Here's a ground plane. Direct shadows are not being anti-aliased like other parts of the map. The texture has a black background instead of having padding or edge bleeding. These 2 things are contributing to the jagged, muddy lighting. The GI seems are painful too. Anti- Aliasing samples neither works on baked GI nor AO parameters. Why does "edge stitching" only work in realtime GI?

    Your solution worries me a bit. You have final gather set to 2048!!! Of course that is a great work around but that's not realistic for a whole level because of the time it would take to bake a level at those settings. Also If I try to push Final Gather beyond 512 my computer with literally run out of memory or even blue screen. What are your system specs?

    I've been working on lighting in Unity 5 for 2 months straight trying to get a result similar to the results we had in 4.6. I've have been trying every patch and beta release waiting for the lighting bugs to be fixed. I'm very frustrated along with the others on this GI forum.

    -Nick Pappas
    Tech Artist at Playful
     
    mh114 and BaconSanwich like this.
  43. techmage

    techmage

    Joined:
    Oct 31, 2009
    Posts:
    2,133
    A baking engine is supposed to supersample the edges of high contrast lighting to get rid of aliasing. The main problem is not the UV's. The main problem is that the baking engine is not supersampling high contrast edges in the light map.

    Is this an issue of enlighten, or an issue of unity's implementation? Someone somewhere needs to be working on this because this is inexcusable for a modern baking engine.

    It's a little disenchanting to see someone with an 'Unity Technologies' tag come in and act completely ignorant to this then claim it is primarily because of the UV's and not because the baking engine is currently not functioning to a level equivalent with every other modern light baking solution on the market.

    I'm having this same issue as well. Can't really believe Unity 5 shipped like this and is at 5.2.2 and still not fixed.
     
    Last edited: Nov 15, 2015
    nickpappas likes this.
  44. frankn

    frankn

    Unity Technologies

    Joined:
    Nov 15, 2015
    Posts:
    10
    I have a repro :) The Anti-aliasing is skipped when the BlurRadius in the LightmapParameters is not 0 or 1 (sadly, default is 2...). But only for texels that are almost completely obscured by geometry that is very close in world space (affected by the Pushoff value).
    I have submitted a case with repro project for that.

    [EDIT] https://fogbugz.unity3d.com/default.asp?744804_5e9kifu8eruambg4
     

    Attached Files:

    Last edited: Nov 15, 2015
    nickpappas and AcidArrow like this.
  45. frankn

    frankn

    Unity Technologies

    Joined:
    Nov 15, 2015
    Posts:
    10
    I'm sorry that you were not satisfied with the way we handled your issue. But plenty of the people you are talking to in this Forum are actual engineers here at Unity, thus you should not expect them to be particularly polite or anything :D Now that we have the repro, I am sure Jesper will look into that and fix it! :cool:
     
  46. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Anyone know if mixed mode works? We're doing VR and need to bake as much as we can.
     
  47. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,756
    Last I checked, not really (it still has a ton of issues).

    Your best bet is baked mode and lightprobes for "lighting".
     
  48. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    That totally sucks :/

    Can I ask why mixed mode is an option in Unity if it doesn't (and hasn't for a year) worked?
    Not a tiny bit embarrassing?
     
    GoGoGadget and mike.xie like this.
  49. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,756
    As with many things related to lightmapping (final gather, gamma space, light probes etc), the features at first felt placeholdery at worst or a foundation to build upon at best. I mean they kinda did something, but it's not what they should or what you would want them to.

    Which was kinda fine for .0 release.

    But then new releases came out and they remained the same. And that was kind of bizarre.

    (well, in fairness, lightprobes are fixed in 5.3, and in general the Deferred/Linear/Realtime GI workflow is pretty decent now. Everything else besides that is still kinda broken)
     
    hippocoder likes this.
  50. frankn

    frankn

    Unity Technologies

    Joined:
    Nov 15, 2015
    Posts:
    10
    There have been many fixes to the mixed mode in the development branch. Not sure if all changes will be included in 5.3, but the 5.3 RC1 and some previous betas already include several fixes for mixed mode. You can test the beta if you have Unity Pro, or wait for the public release at 8th of December.
     
    hippocoder likes this.