Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

Unity Progressive CPU Lightmapper

Discussion in 'Global Illumination' started by Kuba, Feb 2, 2017.

  1. JamesArndt

    JamesArndt

    Joined:
    Dec 1, 2009
    Posts:
    2,674
    Yeah this was a big problem I was trying to talk about in another thread about the PLM CPU version. I needed control over what geometry pieces went on which atlases and found no way to do it. Supposedly tags or ID were supposed to be able to be used to tell the lightmapper which UVs went on which atlases, but it doesn't respect the setting.

    "That's why I was using the "Baked Tag" on these geometry objects via custom lightmap parameters, the documentation says it will force these objects onto the same lightmap and that's not happening. I need to keep the geometry separated for culling purposes so not really a workaround for that. I did pack these separate geometry objects onto one texture atlas in the hopes Unity wouldn't automatically shift and scale them around. I would intuitively think if forced on the same lightmap texture they would maintain their orientation and scale. I guess I'm coming from the workflow with Beast for baked lighting. It maintained the UV structure of imported UV2 coordinates."
     
  2. Jesper-Mortensen

    Jesper-Mortensen

    Unity Technologies

    Joined:
    Mar 15, 2013
    Posts:
    200
    The docs on "Baked Tag" -> https://docs.unity3d.com/2017.3/Documentation/Manual/LightmapParameters.html

    Basically it says:
    Objects with different Baked Tag values are never put in the same atlas

    and it goes on to say:
    there is no guarantee that objects with the same tag end up in the same atlas, because those objects might not necessarily fit into one lightmap

    However, we have a bunch of work being done in the packing area:
    1) Being able to set a count of lightmaps to use for a given bake tag (close to landing)
    2) Spatially coherent atlassing (also close but delayed because of 1)
    3) Pass through lightmap UVs - being able to do manual atlassing in DCC without Unity messing with the UVs

    I think 1) and/or 3) should help you.
     
    syscrusher and JamesArndt like this.
  3. JamesArndt

    JamesArndt

    Joined:
    Dec 1, 2009
    Posts:
    2,674
    "there is no guarantee that objects with the same tag end up in the same atlas, because those objects might not necessarily fit into one lightmap"

    This was a problem I couldn't solve. I tried literally everything, adjusting the "Scale in Lightmap" parameters, adjusting the map resolution, size. I even did all of the atlassing in 3ds Max first to make sure certain objects all fit nicely onto an atlas. However Unity would just go ahead and ignore that and scale and rotate the UVs on it's own to deem what it felt was the best packing. It even rotated my UV shells!

    It would still make lightmaps with huge gaps in spacing, super inneficient. When I could get a decent group of UVs onto one atlas they would be packed very inneficiently and I had no way to adjust the tightness of their fit, not to mention rotating my DCC created UV atlases.. It just made it extremely hard to get optimized, tightly packed UVs for my mobile racing game so I had to halt development until this was sorted out. I hope those points you've listed help with these things. That would be really awesome.
     
  4. Jesper-Mortensen

    Jesper-Mortensen

    Unity Technologies

    Joined:
    Mar 15, 2013
    Posts:
    200
    So for your specific issue you would need full control of the UV creation, so item 3) will be for you.
     
  5. JamesArndt

    JamesArndt

    Joined:
    Dec 1, 2009
    Posts:
    2,674
    Yes! That would be a godsend of a feature.
     
    pitibonom likes this.
  6. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    5,964
    What does this mean exactly?
     
  7. adpok

    adpok

    Joined:
    Oct 26, 2017
    Posts:
    28
    Im hoping that it either means : every object's uv shell is treated as a single shell that can be placed reducing wasted space. Currently if I have a single object which has multiple uv shells, they only get placed as a group, which invariably means a lot of empty space cant be avoided.

    Or that if i have an oval object, the space in the middle will be utilised.

    Or both..im hoping :)
     
  8. adpok

    adpok

    Joined:
    Oct 26, 2017
    Posts:
    28
    Is there an update on when the cpu utilisation issue going to be fixed? And will it be fixed in 2018.2.8f1? Seriously cant believe a version came out with such an error.
     
  9. WermHat

    WermHat

    Joined:
    Jul 13, 2012
    Posts:
    62
    Any ETA on this? We're stuck on Unity 4 until cookie baking support gets added.
     
  10. rasmusn

    rasmusn

    Unity Technologies

    Joined:
    Nov 23, 2017
    Posts:
    32
    With spatially coherent packing, Unity will try to place objects that are close together (in the scene) into the same lightmap. This is done to improve locality of reference. For example, if lighting information for all objects in a room is stored in a single lightmap, then all objects can be rendered at once by only loading that particular lightmap.

    On the other hand, if lighting information for the objects in the room is stored in 10 different lightmaps, then we can only render a 10th of the objects at once, then change lightmap, then render the next 10th of objects, then change lightmap, etc. In practice the process is more involved, but I think you get the point.

    Here is a GIF showing the difference with and without spatially coherent packing. Colors indicate lightmap ID.
    ezgif-4-580b7db4ff75.gif
     
    syscrusher, MAK11, Peter77 and 7 others like this.
  11. LightingBox2

    LightingBox2

    Joined:
    Mar 31, 2015
    Posts:
    2,796
    My benchmarks on GPU vs CPU progressive :

    cpu : 3770 gpu:GTX 780
    hr:min:sec
    CPU : 2 hours and 30 min bake time
    GPU: 30 min bake time
     
  12. robinjansen51

    robinjansen51

    Joined:
    Nov 6, 2017
    Posts:
    4
    Hi,

    Today I was baking a lightmap and canceled it while it was preparing (force quit unity). Now I get the next messages in my console and can not get rid of them.. I tried new scenes, deleting project settings, library folder, temp, etc but nothing seems to be working. Of course I also tried to change the lighting settings.

    Assets/Editor/x64/Bakery/scripts/ftRenderLightmap.cs(1516,90): error CS0619: `UnityEditor.LightmapEditorSettings.Lightmapper.Radiosity' is obsolete: `Use Lightmapper.Enlighten instead. (UnityUpgradable) -> UnityEditor.LightmapEditorSettings/Lightmapper.Enlighten'

    Assets/Editor/x64/Bakery/scripts/ftRenderLightmap.cs(1520,93): error CS0619: `UnityEditor.LightmapEditorSettings.Lightmapper.PathTracer' is obsolete: `Use Lightmapper.ProgressiveCPU instead. (UnityUpgradable) -> UnityEditor.LightmapEditorSettings/Lightmapper.ProgressiveCPU'

    Do you have any idea what could cause this?

    Thanks
     
  13. robinjansen51

    robinjansen51

    Joined:
    Nov 6, 2017
    Posts:
    4
    Btw, also when creating new projects I get the same messages.
     
  14. thefranke

    thefranke

    Unity Technologies

    Joined:
    Jun 20, 2015
    Posts:
    88
    Hey robinjansen51,

    you can get rid of the warning by either replacing the two enum values with their new version or by upgrading the project. Did you perhaps open the project with a new version of Unity?

    Cheers
     
  15. robinjansen51

    robinjansen51

    Joined:
    Nov 6, 2017
    Posts:
    4
    Hi TheFanke,

    Thank you for your response. I did open the project in a newer version of Unity yesterday, but it continued worked after that. After force quiting Unity while the Bakery was preparing stuff for the bake it gave these errors. Also when opening / starting new projects and importing Bakery these errors continued. Until now I have always dismissed the API update dialog. But when I tried to update them, the errors disappeared...
     
  16. thefranke

    thefranke

    Unity Technologies

    Joined:
    Jun 20, 2015
    Posts:
    88
    Hey robinjansen51,

    Bakery is not from our codebase. You need to talk to the author of Bakery to resolve those issues.

    Cheers
     
  17. robinjansen51

    robinjansen51

    Joined:
    Nov 6, 2017
    Posts:
    4
    A sorry wrong thread
     
  18. GoGoGadget

    GoGoGadget

    Joined:
    Sep 23, 2013
    Posts:
    656
    Recently upgraded my PC to a Threadripper 2950X - thought I'd share one of the benchmarks I did with lightmapping in this thread, for those who are wondering if they should upgrade their CPU/how well cores scale with lightmapping. Haven't had a chance to test out GPU yet but of course assume it would be even faster.

    TLDR: Well done to Unity on thread scaling in the progressive lightmapper, it's much better than Enlighten!
     
    JamesArndt, thefranke and KEngelstoft like this.
  19. fred_gds

    fred_gds

    Joined:
    Sep 20, 2012
    Posts:
    184
    Hey,
    I am trying to bake a scene for my mobile game with the progressive lightmapper, but I am not sure about how to get the settings right. Currently I am baking the scene with the these settings: image
    The bake is not done yet (as it takes like 3 days on my Mac mini) but it currently tells me that it baked 82 lightmaps at 1024p assembling 0,64gb, which for a mobile game is way too much. I guess that the best option to reduce the file size would be by reducing the texels per unit (suggestion for outdoor/city scenes would be welcome) or reducing the objects which are baked, but maybe there is something more I can do?
    Thanks, Fred :)
     
  20. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    5,964
    Reduce lightmap resolution. Also, for really big objects (that maybe are not viewed that up close?) you can select them in the scene and in the mesh renderer greatly reduce the "scale in lightmap" number.
     
    syscrusher likes this.
  21. fred_gds

    fred_gds

    Joined:
    Sep 20, 2012
    Posts:
    184
    Thanks, the "scale in Lightmap" is definitely something I will try.
     
  22. XRA

    XRA

    Joined:
    Aug 26, 2010
    Posts:
    189
    are there plans to add light direction encoded as L1 Spherical Harmonics to the Progressive lightmapper? It enables a huge boost in quality to baked lighting, especially when using it as an approximated light source for specular.

    (As seen in Frostbite engine for example and the Bakery GPU lightmapper for Unity)

    *edit: as seen here, not referring to lightprobes but storing L0 and L1 x,y,z for much better directional lighting + indirect specular from lightmaps https://media.contentapi.ea.com/con...-precomputedgiobalilluminationinfrostbite.pdf
     
    Last edited: Jan 15, 2019
    keeponshading likes this.
  23. konsic

    konsic

    Joined:
    Oct 19, 2015
    Posts:
    799
    SH are part of GI

    http://fileadmin.cs.lth.se/cs/Education/EDAN35/lectures/Stefanov10-gi-in-games-notes.pdf

    https://developer.amd.com/wordpress/media/2012/10/Tatarchuk_Irradiance_Volumes.pdf
     
  24. XRA

    XRA

    Joined:
    Aug 26, 2010
    Posts:
    189
    Lars-Steenhoff likes this.
  25. konsic

    konsic

    Joined:
    Oct 19, 2015
    Posts:
    799
  26. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,379
    I think unity have this before, it was called Directional Specular lightmap, but they remove it. I don't remember why.
    Also it have the same issue as in Slide 77.
    What i'm curious is why unity didn't give us access to use Proxy Lightmap Geo, since this is built in Enlighten features.
     
  27. Jesper-Mortensen

    Jesper-Mortensen

    Unity Technologies

    Joined:
    Mar 15, 2013
    Posts:
    200
    We do have this in our backlog. However, we are focussing first on improving the probe lighting as this has even more potential for improving baking quality. These improvements are both on the authoring side (volumes, auto placement, etc), the feature side (participating probes, env occlusion etc) and the tech side (probe deringing, streaming etc).

    Probes are flexible, you don't need geometry unwraps and they can be arranged in 1D, 2D or 3D.
     
  28. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,379
    Hang on, are you talking about the Probes for dynamic object or probes for baked static objects?
     
  29. Jesper-Mortensen

    Jesper-Mortensen

    Unity Technologies

    Joined:
    Mar 15, 2013
    Posts:
    200
    So soon you can have probelit objects fully participating in the GI calculations, making probes far more useful as they can be used for static objects too. In fact you could have a scene completely lit with probes.
     
  30. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,379
    Ooohhh, now that is looks "Lit"
     
  31. indieDoroid

    indieDoroid

    Joined:
    Jan 25, 2016
    Posts:
    224
    EXCITING!!!! Can't wait to hear more about this.
     
  32. Adam-Bailey

    Adam-Bailey

    Joined:
    Feb 17, 2015
    Posts:
    230
    So taking the approach ReCore used and making it an officially supported lighting method? :D
     
  33. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,379
    They way ReCore used are supported already in unity AFAIK, it called LightProbeProxyVolume
     
  34. Jesper-Mortensen

    Jesper-Mortensen

    Unity Technologies

    Joined:
    Mar 15, 2013
    Posts:
    200
    The main difference is that it will be a fully supported feature to light objects with lightprobes, while those objects fully interact with the GI system, so affecting both lightprobes and lightmaps in the scene. This is a big win for things that don't lightmap well but affect their surroundings like foliage, trees etc. On top you get the benefit of much better directional support as the probes are L2 spherical harmonics.

    Basically, the lightmap and probeset become symmetric as a container for GI.
     
    Reanimate_L, Adam-Bailey and konsic like this.
  35. konsic

    konsic

    Joined:
    Oct 19, 2015
    Posts:
    799
    When will this be available as production ready ?
     
  36. Adam-Bailey

    Adam-Bailey

    Joined:
    Feb 17, 2015
    Posts:
    230
    That sounds good, is it much different to the current trick of giving things a lightmap scale of 0?
     
  37. Jesper-Mortensen

    Jesper-Mortensen

    Unity Technologies

    Joined:
    Mar 15, 2013
    Posts:
    200
    We are aiming for 19.2 for this feature (if everything goes to plan).
     
    Reanimate_L and Adam-Bailey like this.
  38. Jesper-Mortensen

    Jesper-Mortensen

    Unity Technologies

    Joined:
    Mar 15, 2013
    Posts:
    200
    Yes, the problem of using lightmap scale 0 in the current system is that the object will not have correct emissive and albedo information as that was previously tied to the lightmapped objects resolution. This is now decoupled so it will work seamlessly now. The UI also reflects these changes so you can pick the GI container for the object and it is not some side-effect of another parameter.
     
    AcidArrow and Adam-Bailey like this.
  39. Adam-Bailey

    Adam-Bailey

    Joined:
    Feb 17, 2015
    Posts:
    230
    Ah, nice. Really looking forward to playing with it, should be a nice way of getting around a bunch of limitations with the current lightmapping.
     
  40. Jesper-Mortensen

    Jesper-Mortensen

    Unity Technologies

    Joined:
    Mar 15, 2013
    Posts:
    200
    Out of interest can you share what those limitations are so I can make sure we meet them?
     
  41. Adam-Bailey

    Adam-Bailey

    Joined:
    Feb 17, 2015
    Posts:
    230
    Nothing overly particular to Unity. Things you mentioned already like vegetation and smaller props that you want to contribute to the GI but aren't really good candidates for light mapping themselves. Up to now I have been getting around those issues by using lightmap scale 0 and you already addressed how this approach will help with the problems encountered with that approach. :)

    edit: I also imagine it will be good for lighting larger open spaces where you don't want to waste a bunch of lightmap memory on fully lit ground, but want to have some areas underneath shade. Rather than having to break up a mesh into different parts with different lightmap resolution settings, presumably you could just place a higher density of probes in the areas where it is desired?
     
    Last edited: Jan 17, 2019
  42. Jesper-Mortensen

    Jesper-Mortensen

    Unity Technologies

    Joined:
    Mar 15, 2013
    Posts:
    200
    All of you are aware of denoising in the lightmapper right? The short is that you can get smooth bakes with a 1th of the samples, so you can bake out high quality lightmaps much, much faster.

    So in 19.1 we have introduced Optix for CPU Lightmapper, in 19.2 we will have Optix for GPU Lightmapper, and (crosses-fingers) another denoiser that will work on all GPUs and that also works across Mac and Linux as well as Windows of course.

    Use it now in CPU Lightmapper in 19.1 and let me know what you find!

    Enter_the_Room.png
     
    JamesArndt, Total3D, mh114 and 5 others like this.
  43. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    2,233
    When is 2019.2 planned to go in alpha?
     
  44. konsic

    konsic

    Joined:
    Oct 19, 2015
    Posts:
    799
    I would say March/April.
     
  45. Jesper-Mortensen

    Jesper-Mortensen

    Unity Technologies

    Joined:
    Mar 15, 2013
    Posts:
    200
    Its in alpha now, transitions to open beta end of March.
     
    Lars-Steenhoff likes this.
  46. konsic

    konsic

    Joined:
    Oct 19, 2015
    Posts:
    799

    Is it possible to achieve realtime indirect lighting with these lightprobes without baking lightmaps?
     
  47. Jesper-Mortensen

    Jesper-Mortensen

    Unity Technologies

    Joined:
    Mar 15, 2013
    Posts:
    200
    Depends on what you mean by realtime. The probes have full indirect lighting in them including all the objects that are marked to `contribute to GI` so to all intents and purposes behave as lightmaps.

    Basically there are now two containers for GI: lightmaps and lightprobes. And regardless of the container they contribute to the GI solution in the same way.
     
    syscrusher, Adam-Bailey and konsic like this.
  48. konsic

    konsic

    Joined:
    Oct 19, 2015
    Posts:
    799
    Please take a look at this project brechpunkt.de/q2vkpt/

    https://github.com/cschied/q2vkpt/
    Maybe some similar solution can be for Unity.
     
    Lars-Steenhoff likes this.
  49. Jesper-Mortensen

    Jesper-Mortensen

    Unity Technologies

    Joined:
    Mar 15, 2013
    Posts:
    200
    Lars-Steenhoff likes this.
  50. MAK11

    MAK11

    Joined:
    Nov 24, 2017
    Posts:
    11
    Is it safe to assume (given that the GPU Lightmapper uses RadeonPro render) that the "other" denoiser will be AMD's upcoming RadeonPro render denoiser which is planned for Q1 2019 ?
     
    JamesArndt likes this.