Search Unity

Realtime vs. Baked lighting inconsistent results

Discussion in 'Global Illumination' started by spryx, Mar 6, 2015.

  1. spryx

    spryx

    Joined:
    Jul 23, 2013
    Posts:
    557
    I apologize if this has been answered, but I can not seem to get decent results using baked lighting in an indoor scene (for mobile). My current workflow is to leave point lights realtime until it is time to bake them.

    The problem is, they look vastly different. Can anyone recommend enlighten settings for a scene such as this.
    Surely, there must be a way to get baked results similar to realtime.

    Its almost as if the falloff behavior of the light or intensity changes when you bake it.

    ss.png

    I should clarify this was baked using Baked GI, no final gather, without Precomputed realtime GI
    at 50 tx/unit, uncompressed.
     
    DChap, KRGraphics and theANMATOR2b like this.
  2. erana79

    erana79

    Joined:
    Jun 26, 2013
    Posts:
    61
    I have the same problem with directional lights. Once i bake them they change their intensity (at least visually). Also interested in an answer to this problem.
     
  3. spryx

    spryx

    Joined:
    Jul 23, 2013
    Posts:
    557
    I wish someone from UT would reply.... I don't understand how we are supposed to be able to achieve certain results with baked lighting without being able to visualize it.
     
    jc2 likes this.
  4. erana79

    erana79

    Joined:
    Jun 26, 2013
    Posts:
    61
  5. bakanekofr

    bakanekofr

    Joined:
    Feb 28, 2014
    Posts:
    122
    I'm also interested in this!
     
  6. Korno

    Korno

    Joined:
    Oct 26, 2014
    Posts:
    518
    Well, I guess the bake process is much more accurate in simulating the light while realtime has much more simple abstractions of the lighting formulee. Id would guess baked is how it should actually look and realtime is what is wrong.

    Also be careful with pixel lights, and render path when you are using realtime as that seems to change how the lights behave.
     
  7. Neoku

    Neoku

    Joined:
    Oct 27, 2014
    Posts:
    261
    I am senior arch visualizer and see better ligthing in the left image (more lealistic) and the right image with over exposition (more apropiated for games), i am not know Enligthen but you can obtain the result that you find with more intensity in your lights, with a fill light (or lights) or see if Enligthen have a exposition parameter. Your art work is cool, good luck.
     
  8. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,735
    Are you running in DX 11 mode? Unity 4 had a bug with lightmaps and running in dx11 mode when your project is set to Android/iOS. I'm not sure if it's still around in Unity 5.
     
  9. plasmabazooka

    plasmabazooka

    Joined:
    Mar 8, 2015
    Posts:
    70
    For me on Unity 5 baked result also always overexposed in comparison with a real time result.
    Especially if I'm using light probes. Did not get it why it is so different from real time and how to predict a result.
     
  10. spryx

    spryx

    Joined:
    Jul 23, 2013
    Posts:
    557
    I am reinstalling Unity 4 to do a couple tests on this. Will report back
     
  11. spryx

    spryx

    Joined:
    Jul 23, 2013
    Posts:
    557
    After testing the project in Unity 4, I can conclude that it is much more difficult to predict the lighting results you will get with baked lighting in Unity 5. A composite image of Unity 4 vs 5 is below - it is difficult to see differences in this one, so I advise you to expand the image group.

    composite.png

    Unity 4 and 5 realtime lighting look very similar (without the added features of U5) as it should. Importing a scene from Unity 4 maintains lighting fidelity.

    U5DI.png

    This is the scene as it appears in Unity 4 with realtime, deferred lighting.

    U4RT.png

    Unity 4 Lightmapping gives results that are very similar to lighting conditions in realtime, so you can anticipate what the scene will look like using baked lighting:

    U4LM.png

    Baking the lighting in Unity 5 yeilds results that are not even close to realtime, (or visually pleasing)

    U5LM.png

    While I understand that the renderer was changed quite a bit between the two versions, I don't understand why lighting results are so different. I also realize this could be my fault entirely (I'm not familiar with enlighten).

    Do we literally have to add lights one-by-one and wait for them to bake in order to get an idea of how they will look? This seems very counter-productive at the moment. The lights also appear different when baked. In particular, the falloff and shape of the light seems to change between realtime and baked. Correct me if i'm wrong, but isn't the point of baked lighting to represent a good approximation of realtime lighting while reducing the performance hit?

    If anyone has any advice, i'm all ears.....as it stands right now, and I hate to admit it... baked lighting is almost useless in U5 (without using GI) compared to U4.

    @AcidArrow I am in DX9 mode. That silly bug is one of the first things I change when in an Android project. I really wish someone from UT would fix it. I have reported it numerous times.

    @Neoku The assets are actually from 3DForge...he produces some great stuff. You are correct, the image on the left (from my previous post) is correctly lit...the one on the right is overexposed.
     
    Last edited: Mar 8, 2015
    S4G4N likes this.
  12. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,735
    Could you share the scene? (or a simplified version of it?). I'd like to take a look as well. Are you using final gather for baked, or just upscaled precompute?

    Baked should actually look better than realtime, since you could push for much higher resolution with final gather. With similar resolution though, realtime tends to look better.
     
  13. spryx

    spryx

    Joined:
    Jul 23, 2013
    Posts:
    557
    @AcidArrow Unfortunately, I can't share the scene, as I am using purchased assets. I have tried using final gather with 1024 rays only, but that seems to exponentially increase baking time and results in no visible difference that I can see. When I refer to baked, I am just using the "baked gi" option with no precompute.

    I will try a few more tests today with final gather to see if I can achieve a more realistic result.
     
  14. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,735
    Are you using point lights to light the scene, or luminous materials?
     
  15. spryx

    spryx

    Joined:
    Jul 23, 2013
    Posts:
    557
    Just point lights at the moment
     
  16. Stardog

    Stardog

    Joined:
    Jun 28, 2010
    Posts:
    1,913
    No solution here, but I have also noticed baked lighting in 5 not being as nice as in 4.
     
  17. spryx

    spryx

    Joined:
    Jul 23, 2013
    Posts:
    557
    ok, using final gather seems to do nothing but increase bake time. This is 4096 rays and baked gi

    U5FG.png
     
    Last edited: Mar 9, 2015
    S4G4N likes this.
  18. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,735
    I did some tests as well. It appears that generally Baked GI is significantly brighter than realtime.
     
  19. spryx

    spryx

    Joined:
    Jul 23, 2013
    Posts:
    557
    @AcidArrow I didn't really see a difference with FG, but I am not using many lights. FG does increase the bake time quite a bit though.

    Can someone....anyone.. from UT give us any information?
     
  20. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,735
    The theory is, that without FG on, the baked GI is using the indirect GI from realtime and just upscales it (while direct light is at full res), while using Final Gather, recalculates the GI using FG at full res.

    So, without FG turned on, the indirect lighting should look very similar. In theory. In practice, as far as over colors and light amount, the two baked GI methods look almost the same.
     
  21. spryx

    spryx

    Joined:
    Jul 23, 2013
    Posts:
    557
    I have almost given up on getting the lighting right. I am going to try another platform (PC) and see if that corrects the issue.

    If it can't be fixed, I suppose I could just delete the lights and start again in Unity 5
     
  22. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,735
    I think a bug report is in order.
     
  23. spryx

    spryx

    Joined:
    Jul 23, 2013
    Posts:
    557
    Ok... changed the type of lightmap to non-directional...and it is much closer to where it should be. Technically, still not ideal..but I can live with it. The lights still seem to blend too much for my taste...but that is probably more realistic,.

    So anyone having trouble with their baked lighting, try Baked GI only with a Non Directional General GI. UPDATE: This only really works for this scene... baked light still look vastly different from rt lighting.

    U5BND.png
     
    Last edited: Mar 10, 2015
    S4G4N and theANMATOR2b like this.
  24. spryx

    spryx

    Joined:
    Jul 23, 2013
    Posts:
    557
    Ok, after converting a few other scenes to Unity 5, it is clear that using non directional lightmaps does not work for many scenes. In short, you will probably need to re-light your entire scene again in Unity 5. As it stands now, there is no way to predict what the lighting will be like without iteratively adding lights and allowing them to bake :/
     
  25. Zolt_Hero

    Zolt_Hero

    Joined:
    Mar 9, 2015
    Posts:
    7
  26. spryx

    spryx

    Joined:
    Jul 23, 2013
    Posts:
    557
    @Zolt_Hero
    erm? Did you read my first post? That is exactly the problem I was(am) having.
     
  27. KEngelstoft

    KEngelstoft

    Unity Technologies

    Joined:
    Aug 13, 2013
    Posts:
    1,366
    Hi @spryx! Is your project in linear or gamma mode?

    It would be great if you could post a screenshot of your Lighting window and tell us what materials are assigned (is it the new Standard shader or some of the legacy materials?).

    While the project is baking, you can see what is used as input to Enlighten by looking at the Albedo and Emissive scene view modes. This is an area that changed, compared to 4.x. Knowing how the albedo is looking should give you an easier time figuring out if the output is correct.

    Also, do you have light probes in the scene?
     
    theANMATOR2b and spryx like this.
  28. spryx

    spryx

    Joined:
    Jul 23, 2013
    Posts:
    557
    @KEngelstoft Hi there!
    This is an Android project (DX9) in gamma mode targeting mid to high end devices. Currently there are no light probes in this scene, but I will add these in later. The scene screenshots above are using legacy shaders. Switching the scene to the standard shader (below) seems to give similar results (as expected). The models here only use an albedo layer. There are a total of 7 point lights in this scene, each set at a range, intensity, and bounce intensity of 9.83, 2, and 1 respectively. No emissive materials are present.

    I have included a screen shot of my typical lighting settings post Unity 4. Unfortunately, I can not figure out how to get to the albedo and emissive views.

    new ss.png

    In any case, I would like the lighting to be close to realtime if possible. When I bake them, for lack of a better term, the lights seem to spread. I must admit that this could entirely be my fault as I am not familiar with how enlighten works. Thank you for the suggestions.
     

    Attached Files:

    S4G4N likes this.
  29. KEngelstoft

    KEngelstoft

    Unity Technologies

    Joined:
    Aug 13, 2013
    Posts:
    1,366
    A bounce intensity of 9.83? That sounds like a lot... How does it look if you set the bounce intensities for the lights back to 1 and compare again? I suspect the differences you see are due to the fixes we did to gamma and linear lighting. The values make a lot more sense in 5.0 so it should be easier to tweak and get consistent results, but there might be something going on with high bounce intensities in gamma mode.

    Albedo view can be found next to wireframe, overdraw etc. in the scene view dropdown. http://docs.unity3d.com/Manual/ViewModes.html
     
  30. spryx

    spryx

    Joined:
    Jul 23, 2013
    Posts:
    557
    @KEngelstoft The bounce intensity is 1, range is 9.83, and intensity is 2. I left these unchanged from Unity 4. I did find the albedo input...but nothing shows up, The entire map is gray. Have the lighting fixes been applied to only baked lighting? Real-time lights appear in intensity as they did in Unity 4.
     
    Last edited: Mar 13, 2015
  31. KEngelstoft

    KEngelstoft

    Unity Technologies

    Joined:
    Aug 13, 2013
    Posts:
    1,366
  32. spryx

    spryx

    Joined:
    Jul 23, 2013
    Posts:
    557
    @KEngelstoft I am not using custom shaders, just the unity 5.0 standard shader. I think I may just be expecting too much in regard to rendering baked lighting as it looks in realtime. I was operating under the assumption that baked and realtime should look similar. Perhaps my best solution is just to re-light the scene?

    I know some work is being done (for future 5.x releases) in regard to pre-visualizing baked results...perhaps this will improve the workflow for baked lighting?
     
  33. KEngelstoft

    KEngelstoft

    Unity Technologies

    Joined:
    Aug 13, 2013
    Posts:
    1,366
    Realtime and baked are very different resolution wise. From this conversation it is unclear where that extra bounce light is coming from. It would be interesting to take a look at your scene and see if there is something wrong with our lighting code or if this is simply the resolution of the bounced lighting that gets added on top that makes it look so different. Would you mind posting a bug report with your test scene attached?

    Yes, once we have pre-viz working using PowerVR the workflow should become a lot better.
     
  34. spryx

    spryx

    Joined:
    Jul 23, 2013
    Posts:
    557
    @KEngelstoft I have attached the scene and a brief description in a bug report. Case 681137 (now 681444) Thanks for your help
    Edit: This has been updated. I assumed the bug reporter would attach my project when the root folder was added. I have uploaded another bug report with a package attached. The case number is 681444
     
    Last edited: Mar 17, 2015
  35. spryx

    spryx

    Joined:
    Jul 23, 2013
    Posts:
    557
    @KEngelstoft Just for fun, I tried comparing the same scene using linear lighting (switched the project to PC). It seems as though linear lighting in realtime and baked is similar in intensity. The tweaks made to lights seems to affect them both in linear and gamma mode. Baking the lights in gamma mode however, results in amplified intensity in baking.

    Summary: Lighting is predictable in real-time and baked applications in linear space only. Gamma baking yields results similar to linear baking, while gamma space real-time is completely different.

    I will try to post additional screenshots
     
    twobob and theANMATOR2b like this.
  36. KEngelstoft

    KEngelstoft

    Unity Technologies

    Joined:
    Aug 13, 2013
    Posts:
    1,366
    Thank you for taking time to upload the package.
     
  37. GunLengend

    GunLengend

    Joined:
    Sep 24, 2014
    Posts:
    54
    Sorry for bump this topic, but i still facing with same problems.. and with Unity 5.1.
    So it already fixed or have any solution ?
     
    spryx likes this.
  38. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,822
    How do you disable DX11 mode in Unity 5 when your project is set to Android?
     
  39. spryx

    spryx

    Joined:
    Jul 23, 2013
    Posts:
    557
    @Meltdown it used to be in the PC player settings... looks as though it has been removed, so I don't think you need to manually uncheck it anymore.

    I had the best results using non-directional lightmaps in Unity 5. Despite this, I was never able to get things looking as good as I did with Unity 4 (on an imported project). The best suggestion is just to re-light your scenes for Unity 5. This stinks, but it seems that the lighting has been changed fundamentally.

    You can still vote for the issue here!

    Maybe someone on the Unity team can update us on this issue?
     
    Last edited: Jul 17, 2015
    S4G4N and Meltdown like this.
  40. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,822
    I can't seem to get anything satisfactory with lightmapping in Unity 5, it's very frustrating and I've spent countless hours on it.

    Non-directional removes any normal maps, and normal maps are a must for my game's race tracks. And Directional gives me results that never look right on the device compared to what's in the editor. So right now its just a lose lose lose situation. I hope they fix it.
     
    spryx likes this.
  41. Sparrowfc

    Sparrowfc

    Joined:
    Jan 31, 2013
    Posts:
    100
    normal maps shader works pretty different between mobile and PC, it seems the scale parameter of normal map is always 1 on mobile
     
  42. spryx

    spryx

    Joined:
    Jul 23, 2013
    Posts:
    557
    @Meltdown I feel your pain here. I put this project on hold because the baked lighting workflow is just not worth the result at the moment. Perhaps when a linear lighting workflow is available for mobile, things will be different. I don't necessarily mind long baking times.... However, I think it is paramount to be able to visualize lighting as you do it. Why changing the real time lights to baked yields completely different lighting results is beyond me....

    I hate to be one of "those" people....but I wish there was a way to emulate legacy lighting in U5...at least to the point that I would know what i'm getting when I press bake. I realize putting Beast back in is not the answer. I would be interested to hear about anyone's workflow for baked lighting in Unity 5...especially in gamma space. I admit that this all could be due to my knowledge on enlighten...so if anyone has any tips, I'm all ears..
     
    Last edited: Aug 24, 2015
    S4G4N likes this.
  43. Martin_H

    Martin_H

    Joined:
    Jul 11, 2015
    Posts:
    4,436
    I have never touched the light baking, but isn't baked lighting supposed to look a lot different than realtime lighting? I thought in general the baked approach calculates light bounces which lighten up areas that with realtime light might be very dark. If you want to have less difference in the result, did you try reducing the calculated bounces? If there even is such a setting... I'm sorry if this has been discussed before, I didn't read the whole thread.
     
    spryx likes this.
  44. spryx

    spryx

    Joined:
    Jul 23, 2013
    Posts:
    557
    @Martin_H Perhaps it does, but I assumed that most people used it for mobile and performance critical applications. In this regard, it makes it difficult to predict what happens when you bake the lighting in. I left my bounce boost at 1 for baking. I'm not sure if you can reduce calculated bounces. I have no clue what final gather does...other than increase bake time from "make coffee" to "make dinner".

    I failed to consider other uses for the baked lighting system such as the situation you presented...perhaps I need to look over the documentation again just to see if anything changes when baking. This does seem somewhat counter-intuitive though, especially if you are trying to achieve a certain degree of lighting without guesswork. In Unity 4, the lighting was similar to realtime when you baked it in. I initially thought Unity 5 would work in the same manner. I am somewhat dumb when it to comes to lighting though, so it could just be that enlighten is designed to be used differently than the purpose I am using it for.
     
    Last edited: Aug 24, 2015
  45. Martin_H

    Martin_H

    Joined:
    Jul 11, 2015
    Posts:
    4,436
    @spryx: Afaik the concept of lightbaking is a lot older than the whole mobile games market and it's original intention was to achieve a quality of lighting that was/is not possible in realtime. Therefore it makes perfect sense to me if you can't use lightbaking to "freeze the realtime lighting in place". The problem that you don't know how exactly the baked lighting looks before you actually bake it, is also as old as the lightbaking technique itself. Do small test-cases and build up experience to cut down on the number of iterations you need.

    I don't know either, but I've heard it before. Google it, I'm sure it is in the unity documentation somewhere. If it isn't, google it in a general cg global illumination context, the concept and connected implications are probably similar enough.
     
  46. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,822
    I know 5.2 is coming with tons of baking bug fixes and improved lightmapping etc.
     
  47. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,735
    If you don't have final gather on, direct light is calculated at the baked resolution, while indirect light is calculated at the realtime resolution (which is/should be less than baked).

    Ticking on Final Gather, switches the whole algorithm to a final gather technique. Indirect light is then at baked res. Which means, you can have (assuming the resolution is enough) things like contact shadows and penumbras from really indirectly lit scenes (a room with one open window and no sunlight), etc etc. Drawback is it takes a while longer to calculate and it produces a lot of noise.

    The current implementation is a bit.... brute-force-y. I don't remember where I read it (too lazy to search it now), but implementing some sort of smarter sampling is something they will do eventually.
     
    Meltdown and spryx like this.
  48. spryx

    spryx

    Joined:
    Jul 23, 2013
    Posts:
    557
    @AcidArrow Thanks for the clarification on final gather. I assume you should only use this in certain scenes (i.e. harsh transitions). Otherwise, it adds ages to build time.

    Hoping the PowerVR Raytracing tech comes in a beta build before the end of the year.

    I have tried lighting scenes in U5 alone..and it seems that lights need lower intensity values...which is a good practice, imho.
     
    Last edited: Aug 31, 2015
    theANMATOR2b likes this.
  49. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,735
    Well, ticking Final Gather on, is closer to what Beast was doing in 4, so it isn't that slow necessarily. But as I said, the current implementation is a bit brute force-y and it needs a ton of rays to give clean results, so it's slow atm.
     
  50. HalversonS

    HalversonS

    Joined:
    Jan 24, 2014
    Posts:
    28
    Scoured the web. Didn't see anything was updated beyond this. Bump?

    I'm also finding that if you use a fair amount of reflection probes and many lights that certain lights will not bake. Also layers that are ignored will still have the lights baked onto them (I'm aware of the 4 layer limit and have not exceeded it). Bounces are all turned off, I've played with every possible setting combination in the lighting window. Things are static that should be, lights set to bake, I gave the light pixel count a ridiculously high number. I've gone over everything. Half the scene bakes PERFECTLY. The other half does not. The meshes in some areas that are not correct are almost identical in size and shape. I just want my real time results to look like baked... Why is this such an issue? To go through and "guess" how things are going to look is absurd.