Search Unity

Looking for general advice on lighting

Discussion in 'Global Illumination' started by MonkeyPuzzle, Apr 7, 2018.

  1. MonkeyPuzzle

    MonkeyPuzzle

    Joined:
    Jan 17, 2016
    Posts:
    70
    {Follow up]
    So I lowered the lightmap resolution from 40 to 4. That made a huge difference - back up to close to 80FPS and only three lightmaps. The quality is actually similar, although my setup is very basic.

    Updated questions:
    1) Will combining prefabs into larger objects help performance significantly, either with a plugin or in 3D? (I am currently using a lot of prefabs to create walls, floors, etc. in the hundreds)
    2) Are there good guidelines for lightmap resolution for detailed interior levels aimed at a mid-level PC?
    3) Any other thoughts or tips on performance/quality/settings as I go into production building out models?
    4) Static batching appears to not be compatible with GPU instancing? Is this true, does one of these tools generally provide better results?
    5) Are any of the static options for objects safe to uncheck, or ones that are particularly performance heavy or light?


    [Original Thread]
    I have been through several different forum posts and tutorials about lighting but still feel like I am missing something fundamental.

    I have been grayboxing a sci-fi level. How I am doing this is by making wall prefabs, floor sections, etc. and chaining them together to make hallways, rooms, etc. I use a lot of these, in the hundreds. My hope was to later iterate over the models in these prefabs, adding detail. I am now not sure about this path.

    The performance at this stage was good 80+ frames per second.

    I added a bunch of point lights set to bake and set the walls and floors to static. (static everything)

    1) My first question is why these lights are visible before I actually bake anything? It seems like they are acting like real-time lights?

    The performance took a big hit, again many lights - trying to add depth, about 15-30 fps

    I baked a solution, using mixed (I have one real-time light for shadows) disabled all of the point lights set to bake in the editor and the levels looked similar to when the baked lights were on, but the performance was then really bad - like 3-5 fps.

    It looks like it is baking a lightmap for every wall and floor prefab - so many lightmaps.

    2) Is the number of prefabs likely a big part of the problem?

    3) My third question is whether this plan of building with 'modules' is not the right way to go.

    I could bake lighting into the prefab textures themselves, and will definitely do some of that, but was hoping to have Unity handle some of this so I could add lights in the editor as well.

    Options that I am considering:

    a) use a plugin to combine prefabs into larger sections
    b) Combine prefabs into larger sections in 3D

    I thought that baking lights would greatly improve performance, but it did the opposite, so I feel that I am missing something basic.

    I have also tried forward and deferred rendering, which had an effect, but not a very big one.

    Any advice is appreciated. I am aiming for mid-level PCs, going with a high-key, cool sci-fi interior and know 3D pretty well.
     
    Last edited: Apr 7, 2018
  2. Stardog

    Stardog

    Joined:
    Jun 28, 2010
    Posts:
    1,268
    The same lightmapping advice from 1996 applies today.

    https://tf2maps.net/threads/guide-lightmap-optimization.33113/
    https://tf2maps.net/threads/tutorial-understanding-lightmaps.1693/
    http://www.hourences.com/tutorials-ue3-lightmapping/
    https://developer.valvesoftware.com/wiki/Lightmap

    If a surface doesn't receive any shadow or has consistent lighting across it, then put its lightmap resolution to low. The problem in Unity is that everythings a mesh, so you can't customise each face, so you end up with a simple wall taking up too much space. High resolutions should be saved for things that receive a shadow.

    For objects that are small, or have detailed/organic geometry (keys on a desk, cutlery, thin wires) should be lit using Light Probes. Spheres are not good for lightmapping due to seams.

    1) The lights default to realtime if there is no baked data so you can preview it somewhat. It shouldn't bake a seperate lightmap for every mesh. It will atlas them (join them together). If there is a seperate map for each mesh, then you probably have them at too high resolution, such as 1024 each.
    3) Modular building is fine. I have an old game where each wall/floor was a seperate module.
    nv8IRgR.png

    The problem is seams, but Unity 2017+ has options for stitching so maybe does a better job. The alternative is too do your design in a your modelling software, then merge them all into fewer meshes when you are happy. It would also speed up baking times, because you could optimise the faces of the floors.
     
  3. LightingBox2

    LightingBox2

    Joined:
    Mar 31, 2015
    Posts:
    2,776
    1) Will combining prefabs into larger objects help performance significantly, either with a plugin or in 3D? (I am currently using a lot of prefabs to create walls, floors, etc. in the hundreds)
    The most important part of the optimization is the Poly Count. just reduce poly count in maximum state like all other AAA games :

    2) Are there good guidelines for lightmap resolution for detailed interior levels aimed at a mid-level PC?
    use lowest possible resolution (under 10). The resolution is only will increase your bake time and it's not related to the performance(use 1024 as lightmap size)


    3) Any other thoughts or tips on performance/quality/settings as I go into production building out models?
    Optimize models using Simplygon. use substance painter for beautiful models. settings is not important for performance
    4) Static batching appears to not be compatible with GPU instancing? Is this true, does one of these tools generally provide better results?
    5) Are any of the static options for objects safe to uncheck, or ones that are particularly performance heavy or light?

    Always set all static models as static batching. it's good enouph

    I thought that baking lights would greatly improve performance, but it did the opposite, so I feel that I am missing something basic.
    After poly count, the lights (specially shadows) are most performance killer. So baked lights will solve this performance cost to 0
     
  4. MonkeyPuzzle

    MonkeyPuzzle

    Joined:
    Jan 17, 2016
    Posts:
    70
    Thank you so much! I followed your advice and now everything is working great. I think I am going to get another machine to do only baking.

    Do you know of a good workflow for working between two machines? I have a USB-C SSD I could probably store the project there.