Search Unity

Official Progressive GPU Lightmapper preview

Discussion in 'Global Illumination' started by KEngelstoft, Sep 26, 2018.

  1. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,794
    CPU:
    1 cpu.png

    GPU:
    2 gpu.png

    Case 1310621

    Please fix.
     
    KEngelstoft likes this.
  2. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,794
    Also, GPU needs like 10 times more rays to be as clean as CPU. With that in mind GPU isn't really all that fast.

    These are with the same rays.

    CPU
    upload_2021-1-31_4-29-5.png

    GPU
    upload_2021-1-31_4-30-4.png
     
    JamesArndt likes this.
  3. KEngelstoft

    KEngelstoft

    Unity Technologies

    Joined:
    Aug 13, 2013
    Posts:
    1,366
    Not 10x, just 4x... Due to implementation differences, the GPU lightmapper will need up to 4 times more indirect light samples to achieve the same result, compared to the CPU lightmapper.

    We are adding this info to the manual.

    The CPU lightmapper is launching more light rays when reaching a surface. This is called "branched path tracing" the path is the same as in path tracing (the path made by red rays followed by green ray on the sketch).
    WIN_20210201_11_55_12_Pro.jpg
    Branched path tracing is good for convergence but can be really bad for GPUs. The reason behind that is that you can have multiple threads running in parallels that have different number of shadow rays to test, therefore some will be waiting for the other to finish their shadow work. If you decide to launch only one shadow ray at maximum when you reach a new surface (new bounce) you minimize that effect. You increase coherency of work and therefore performance.
    We could batch all the shadow queries in a big buffer and compute that in a dedicated step but that's a lot of work and memory and we don't have that yet in the GPU Lightmapper.
    Also there is no perfect strategy for amount of shadow rays you launch at each bounce, this is still an open research field. The solution of just launching 1 is convenient because it works well and it's easier to implement.
     
    JamesArndt and AcidArrow like this.
  4. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    Any chance to have an option in GPU lightmapper somekind of "Ray Multiplier" ?
     
  5. DefyGravity

    DefyGravity

    Joined:
    Mar 26, 2020
    Posts:
    6
    I have to say the GPU lightmapper is very fast. We build large projects for Naval simulations, scenes with around 95 2k lightmaps. It would take 3 days to bake with CPU vs. 30 minutes with GPU.
     
    PutridEx, ADufay and KEngelstoft like this.
  6. steve_mmsoft

    steve_mmsoft

    Joined:
    Apr 29, 2020
    Posts:
    4
    I'm trying to use the progressive GPU lightmapper in 2019.4.5f1 (I can't move up to 2020, sorry) and I'm getting an error about being out of resources on my 1070GTX. I've seen that the suggestion in other threads is to disable progressive updates, but I can't figure out how - there doesn't seem to be an option to do that anywhere obvious, and google has been no help.
     
  7. uy3d

    uy3d

    Unity Technologies

    Joined:
    Aug 16, 2016
    Posts:
    187
  8. Mikekan13

    Mikekan13

    Joined:
    May 30, 2015
    Posts:
    90
    I have a GTX 1080 and I can't get the GPU lightmapper to work no mater what I do. I can set it to tiny settings and it still errors out with :OpenCL Error. Falling back to CPU lightmapper. Error callback from context: CL_OUT_OF_RESOURCES error executing CL_COMMAND_WRITE_BUFFER on GeForce GTX 1080 (Device 0).

    Or : OpenCL Error. Falling back to CPU lightmapper. Error callback from context: CL_UNKNOWN_ERROR
     
  9. hasseyg

    hasseyg

    Joined:
    Nov 16, 2013
    Posts:
    82
    Hi, I have found that on a fairly large scene, the baking switches from gpu to cpu, unless I take the scene view camera, place it underneath the scene and face it downwards, so there are no meshes in view. It then seems to work successfully and I have been using this trick for at least a couple of years now, but have no idea why it works, so you may want to try that.

    I would also like to add I have progressive updates turned off and my lightmap size at 2048, due to using a 2060 super.

    thanks
     
  10. UnityLighting

    UnityLighting

    Joined:
    Mar 31, 2015
    Posts:
    3,874
    benchmark bake time:
    02:14 on 4790K CPU (2 hours and 14 minutes)
    00:24 on GT1030 GPU (24 minutes)
    photo_2021-03-05_17-03-35.jpg
     
    KEngelstoft likes this.
  11. UnityLighting

    UnityLighting

    Joined:
    Mar 31, 2015
    Posts:
    3,874
    My spec:
    Q8400 cpu + GT 1030 gpu + 6gb RAM
    I decided to buy a powerful computer but now I don't need it with GPU lightmapper
    My system is very fast when working with Unity and I only had a lightmap problem that was solved with gpu lightmapper

    I had never tried the gpu lightmapper because I always had the OpenCL error on 2020.2
    But now with the 2019 lts installation, my problem was solved and I was able to test it
    the result:
    The scene already baked on 4790K in few hours but for the now i baked it again in 34 minutes using GT 1030 2gb gpu :
    GTX 780 : 12 minutes
    1.jpg 2.jpg 4.jpg 5.jpg 8.jpg
    4.jpg
     
    Last edited: Mar 5, 2021
  12. UnityLighting

    UnityLighting

    Joined:
    Mar 31, 2015
    Posts:
    3,874
    Code (CSharp):
    1. Failed to find a suitable OpenCL device for the GPU Lightmapper, falling back to CPU lightmapper. Please install the latest graphics driver.
    Unity 2019 works well but in 2020.2f1 i have the problem
    My driver is most up to dated
    GT1030 Windows 8.1 64bit Driver 461.72
     
  13. KEngelstoft

    KEngelstoft

    Unity Technologies

    Joined:
    Aug 13, 2013
    Posts:
    1,366
    Minimum GPU memory requirements in 2020 was increased to 4GB, so this is likely your GPU isn't found.
     
  14. UnityLighting

    UnityLighting

    Joined:
    Mar 31, 2015
    Posts:
    3,874
    This is very bad news
    I have a powerful GTX 780 3gb
    So there is no solution?
     
  15. KEngelstoft

    KEngelstoft

    Unity Technologies

    Joined:
    Aug 13, 2013
    Posts:
    1,366
    I understand that you would like to use your GPU and for now you can keep using it with version 2019 LTS. We are working on reducing memory usage of the GPU lightmapper for version 2021.2 and will re-evaluate the minimum requirements once the GPU lightmapper is out of its preview state.
     
    UnityLighting likes this.
  16. aeonfitzgerald

    aeonfitzgerald

    Joined:
    Aug 6, 2019
    Posts:
    4
    Same Issue how'd you fix this?
     
  17. newguy123

    newguy123

    Joined:
    Aug 22, 2018
    Posts:
    1,248
    What am I missing here. With Bakery I bake a very simple scene wit high settings, in less than a minute.

    With Progressive GPU, I get an OpenCL Error withing 10 seconds and it falls back to CPU, with the error of Available GPU memory: 3.46 GB (on a RTX 2070 Super)

    I then lower the res back down to 20 texels, progressive GPU bakes quickly and I can see the effect in scene view and game view, but then when playing, it reverts to no bake, until I stop playing, then it shows the bake again.

    This is in 2021.2.0a8 and HDRP DX12 (no raytracing)


    upload_2021-3-17_18-45-3.png
     
  18. Zylex

    Zylex

    Joined:
    Nov 25, 2008
    Posts:
    238
    You need at least 16GB of VRAM in my experience with GPU baking, especially if you want to bake 4K maps. Had this problem here as well with 2070 super but upgrading to AMD 6800XT with 16 GB VRAM solved it.

    Note that the Nvidia 25% limit on OpenCL allocation sizes will require you to use a 24 GB Nvidia GPU to fit the geometry BVH. AMD doesn't have this limitation, so for example AMD 6800XT should suffice. You would still have to dedicate the entire GPU to the baker for everything to fit (one GPU for the editor and a different one for the light mapper).

    I know this is not a ideal 'solution' since it should simply not run out of memory but that is just the way things are right now with Unity and GPU baking being in Preview.
     
    Last edited: Mar 18, 2021
  19. newguy123

    newguy123

    Joined:
    Aug 22, 2018
    Posts:
    1,248
    Yeah hope they fix this soon because that is rediculous. Bakery bakes the same scene in less than a minute. Also I'm not getting an AMD GPU just to get light bake working. I also use raytracing and you need NVidia for that (also use other apps and everything revolves around CUDA and RTX)

    Maybe in the future they will autodetect your hardware and auto use OpenCL for AMD and RTX or CUDA for NVidia....
     
    fuzzy3d likes this.
  20. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Or, you can just, you know, buy Bakery.
     
    Thomas-Pasieka and fuzzy3d like this.
  21. newguy123

    newguy123

    Joined:
    Aug 22, 2018
    Posts:
    1,248
    I already did, bit currently it doesn't play nicely with HDRP 12
     
    JamesArndt likes this.
  22. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,794
    Any ETA for this regression getting fixed?
     
  23. YuriyPopov

    YuriyPopov

    Joined:
    Sep 5, 2017
    Posts:
    237
    So i put a extra rtx 2070 in my rig to use for baking. Even with that I still get "OpenCL Error. Falling back to CPU lightmapper. Error callback from context: Not enough GPU memory to fit lightmap in memory, even in tiled baking mode. Available GPU memory: 2.49 GB". I dont see how the available memory is 2.49gb when there is almost 8gb free. I used to make sure that the right devices is selected for baking : "-OpenCL-PlatformAndDeviceIndices 0 1". What am I doing wrong? Baking at 2k resolution loads about 3gb of memory on the gpu and stays at 1% utilization.
     
    Last edited: Apr 6, 2021
    James_Arndt and JamesArndt like this.
  24. shin-sim

    shin-sim

    Joined:
    Dec 16, 2015
    Posts:
    4
    I'm currently tested out GPU baking with GTX1060 3GB
    On a new project with HDRP,
    Unity 2019.4.24f1, able to baked with standard settings.
    but
    Unity 2020.3.3f1, will crash upon start bake.
     
  25. Mauri

    Mauri

    Joined:
    Dec 9, 2010
    Posts:
    2,665
  26. KEngelstoft

    KEngelstoft

    Unity Technologies

    Joined:
    Aug 13, 2013
    Posts:
    1,366
    We are planning on fixing it in our current sprint. It turned out to be a complicated issue, probably related to orthonormal basis precision.
     
    AcidArrow likes this.
  27. KEngelstoft

    KEngelstoft

    Unity Technologies

    Joined:
    Aug 13, 2013
    Posts:
    1,366
    Are you able to select it using the baking device dropdown in the Lighting window? If OpenCL device selection isn't working, please report it. How do I submit a bug report? – Unity
     
  28. KEngelstoft

    KEngelstoft

    Unity Technologies

    Joined:
    Aug 13, 2013
    Posts:
    1,366
    Please report the crash, the editor should gracefully fall back to the CPU lightmapper instead of crashing. Thanks. How do I submit a bug report? – Unity
     
  29. YuriyPopov

    YuriyPopov

    Joined:
    Sep 5, 2017
    Posts:
    237
    No, the second GPU never showed up in the baking device dropdown. Do you still need a bug report for this ? Also Im not sure what files I could include to help you out.
     
  30. KEngelstoft

    KEngelstoft

    Unity Technologies

    Joined:
    Aug 13, 2013
    Posts:
    1,366
    Yes, please file the bug report. It will give us the log files we need to investigate this. Thank you.
     
  31. MDADigital

    MDADigital

    Joined:
    Apr 18, 2020
    Posts:
    2,198
    What settings do you recommend for PLM GPU?
     
  32. KEngelstoft

    KEngelstoft

    Unity Technologies

    Joined:
    Aug 13, 2013
    Posts:
    1,366
    Can you please elaborate, do you specifically mean for sample counts or in general?
     
  33. MDADigital

    MDADigital

    Joined:
    Apr 18, 2020
    Posts:
    2,198
    Yeah ray sample count, for a good starting point. We based our scenes on the old default

    upload_2021-4-15_10-13-29.png
     
  34. KEngelstoft

    KEngelstoft

    Unity Technologies

    Joined:
    Aug 13, 2013
    Posts:
    1,366
    Your settings look like a good starting point. I think it would be ideal to start a new thread with some screenshots of artifacts that you are trying to get rid of and ask for suggestions, as it can be very content dependent what settings to use.
    4K lightmaps require a lot of GPU memory in the current versions of Unity, but version 2021.2 should improve this significantly.
     
  35. MDADigital

    MDADigital

    Joined:
    Apr 18, 2020
    Posts:
    2,198
    Thanks, will do.
    I'm on a 24 gig VRAM (nvidia 3090) and it works even for our biggest scenes. (Sometimes I need to restart Unity because it fall backs to CPU anyway, maybe a memory leak or something).

    I found a new bug btw, it seems that you bake ref. probes too early so they become black. I need to bake them again for them to be correct.
     
    JamesArndt likes this.
  36. KEngelstoft

    KEngelstoft

    Unity Technologies

    Joined:
    Aug 13, 2013
    Posts:
    1,366
    Sounds like you hit Unity Issue Tracker - Reflection probes doesn't contain indirect scene lighting after the on-demand GI bake from the Lighting window (unity3d.com) which is fixed but hasn't landed in a public build yet.
     
  37. MDADigital

    MDADigital

    Joined:
    Apr 18, 2020
    Posts:
    2,198
    James_Arndt likes this.
  38. jakkritjak

    jakkritjak

    Joined:
    Feb 24, 2018
    Posts:
    1
    I still have problems with the GPU Lightmapping. VRChat still use Unity 2018.4.20f1. So that mean Unity still using a preview version for lightmapping.
    My PC have AMD Ryzen 5 3600x and AMD RX 5700XT. (Driver 21.3.1)
    I tried to remove the OpenCL.dll file from the folder. It doesn't work
    I tried to copy a newer version of OpenCL.dll file from the amd driver to editor folder. it doesn't work too
    I checked on the log file.

    Code (Boo):
    1. -- Listing OpenCL platforms(s) --
    2. * OpenCL platform 0
    3.     PROFILE = FULL_PROFILE
    4.     VERSION = OpenCL 2.1 AMD-APP (3224.5)
    5.     NAME = AMD Accelerated Parallel Processing
    6.     VENDOR = Advanced Micro Devices, Inc.
    7.     EXTENSIONS = cl_khr_icd cl_khr_d3d10_sharing cl_khr_d3d11_sharing cl_khr_dx9_media_sharing cl_amd_event_callback cl_amd_offline_devices
    8. -- Listing OpenCL device(s) --
    9. * OpenCL platform 0, device 0
    10.     DEVICE_TYPE = 4
    11.     DEVICE_NAME = gfx1010
    12.     DEVICE_VENDOR = Advanced Micro Devices, Inc.
    13.     DEVICE_VERSION = OpenCL 2.0 AMD-APP (3224.5)
    14.     DRIVER_VERSION = 3224.5 (PAL,LC)
    15.     DEVICE_MAX_COMPUTE_UNITS = 20
    16.     DEVICE_MAX_CLOCK_FREQUENCY = 1870
    17.     CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE = 7059013632
    18.     CL_DEVICE_HOST_UNIFIED_MEMORY = false
    19.     CL_DEVICE_MAX_MEM_ALLOC_SIZE = 7059013632
    20.     DEVICE_GLOBAL_MEM_SIZE = 8573157376
    21.     DEVICE_EXTENSIONS = cl_khr_fp64 cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_int64_base_atomics cl_khr_int64_extended_atomics cl_khr_3d_image_writes cl_khr_byte_addressable_store cl_khr_fp16 cl_khr_gl_sharing cl_khr_gl_depth_images cl_amd_device_attribute_query cl_amd_media_ops cl_amd_media_ops2 cl_khr_d3d10_sharing cl_khr_d3d11_sharing cl_khr_dx9_media_sharing cl_khr_image2d_from_buffer cl_khr_subgroups cl_khr_gl_event cl_khr_depth_images cl_khr_mipmap_image cl_khr_mipmap_image_writes cl_amd_liquid_flash cl_amd_copy_buffer_p2p cl_amd_planar_yuv
    22. -- GPU Progressive lightmapper will use OpenCL device 'gfx1010' from 'Advanced Micro Devices, Inc.'--
    23.    use -OpenCL-PlatformAndDeviceIndices <platformIdx> <deviceIdx> or -OpenCL-ForceCPU as command line arguments if you want to select a specific adapter for OpenCL.
    No GPU shown on or Unity doesn't detect my GPU for lightmapping.
    What should I do... I really want to make the GPU lightmapping work so much or it will take like 3 - 6 hours for baking the scene.

    OpenCL Error. Falling back to CPU lightmapper. Error callback from context: CL_INVALID_PROGRAM always happen
     
  39. KEngelstoft

    KEngelstoft

    Unity Technologies

    Joined:
    Aug 13, 2013
    Posts:
    1,366
    Sounds like this issue Unity Issue Tracker - GPU lightmapper doesn&#39;t work on Radeon RX 5700 (unity3d.com) which is fixed in 2019.3 and later releases. I have requested a backport.
     
  40. UnityLighting

    UnityLighting

    Joined:
    Mar 31, 2015
    Posts:
    3,874
    GPU PLM is extremely fast (GTX1650 4GB)
    I don't know why users say bakery is better or faster
    GPU PLM quality is amazing

    I will compare soon ...
     
    KEngelstoft likes this.
  41. KEngelstoft

    KEngelstoft

    Unity Technologies

    Joined:
    Aug 13, 2013
    Posts:
    1,366
  42. useraccount1

    useraccount1

    Joined:
    Mar 31, 2018
    Posts:
    275
    Well, I have never used bakery so I can't compare how fast it is, but the plugin does have several features the default Progressive light mapper doesn't have, for example:
    - Bakery can use normal maps from the materials and believe me, this feature makes a big difference in how the lightmaps look.
    - You can recalculate light probes without rebaking the whole scene (unity is making a new system for light probes so this will change).
    - Seems like they have some automatic toolkit for fixing lighting leaks and UV seams. This sounds like a big deal because in standard unity you have to deal with UV maps manually. It burns a lot of time because you never know why is that happening (too low padding between UVs? Backfire Tolerance? Something else?). It's worth noting that this is a problem only for the unity engine, I haven't seen that kind of issue anywhere else, even in the decade-old tools.
    - Probably also have better presets, which is a big deal because the default one in the unity engine is terrible. It forces you to wait forever until baking is done and also doesn't provide good quality. I'm surprised the team still didn't make several presets so everyone can prototype quickly.

    And maybe they also (still) have better memory management, but that's also on the way. Well, that's my tiny bit of feedback, I've lately had experience with lightning in ue4 so expect more of that, possibly in a separate thread.
     
  43. UnityLighting

    UnityLighting

    Joined:
    Mar 31, 2015
    Posts:
    3,874
    The main problem with Bakery is that it does not work with Unity default light sources
    With PLM, you can use standard Unity lights and achieve the desired result without much difference with real-time light.

    Bakery and Unreal Engine lightmappers are around Beast lightmapper
    PLM is much higher quality and more professional

    PLM is out of the box and is seamless with unity's lighting workflow

    UV:
    UV unwrapping is very simple...
    1. Use unity's Auto Generate unwrap in import settings from textured model
    2. use maya uv automatic unwarap for interior models with white surface

    Your all problems will be solved easily!!!

    I will try again on bakery and i will share the results
     
  44. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,794
    I mean, it auto adds a component, not sure what the issue is.
    What do you mean?
     
  45. UnityLighting

    UnityLighting

    Joined:
    Mar 31, 2015
    Posts:
    3,874
    1. All features(normal map bakes , bake reflection probes...) was available in the beast lightmaper on unity 4
    2.I worked with Unreal Engine 4 a few years ago
    And I know that there is no such thing as Indirect Light sources in Unreal Engine 4 and you have to simulate it with Spotlight and planes
     
  46. useraccount1

    useraccount1

    Joined:
    Mar 31, 2018
    Posts:
    275
    I wish it would be true but that's not always the case. Sometimes you lower the texel density. After a long process of baking, it appears some meshes just look wrong because you have to also deal with the padding. Of all options in to set up, this one is pointless. You always want it to be the smallest possible but also to not cause any problems. I personally feel like the proper value could be found with an unknown to me calculation. Again, every other engine successfully takes care of your project so that I never have to deal with randomly generated problems because a piece of a UV is too close to the border of the map.

    But there are also some other cases, like:
    Sometimes you want to use unity's probuilder for fast prototyping, and since it does all UV wrapping automatically, you can't deal with it to make it work with PLM.
    Sometimes you (or any artist) might do something wrong with UV wrapping and the result will be UV overlap. You can see the number of texels that are overlapped (sadly only after baking) but not the percentage of the whole UV map, so you can never clearly see whether it's a big deal.

    They have them to lower baking time in closed spaces. Also, remember that it's easier to do these cheats in ue4 than in unity since you have several specific options just for that.

    Oh and also, If you have worked only a few years ago, you have missed a lot. Fortnite happened and they improved that part of the engine too.
     
  47. UnityLighting

    UnityLighting

    Joined:
    Mar 31, 2015
    Posts:
    3,874
    UV problems mostly happens on incorrect modeling ways

    Some tips that make your lightmapping uv problems away:
    1. Always use cubes instead of plane for walls. in real world we don't have 0 z axis scale plane as wall
    2. As i said before, always use simple maya automatic unwrapper for UV2 to fix 100% of the unwarps issues
    3. Always use proper surface culling directions (normal direction)

    Because of the automatic UV fixing solution on offline renderers , most modelers always model the scene in the most wrong ways (plane as wall, wrong normal direction) that make the whole game lighting trouble

    Anyway, so far I have not had a single uv/unwrap related problem with the above tips

    I have some uv fixing solutions in my old videos. i will share if i found them

    About UE4 lightmapper:
    The speed is too much slower than unity's PLM CPU:
    In the below scene the UE sample is from evermotion(as i remember). The baking time is ~5 hours by default author settings
    I have baked with higher indirect lighting and indirect shadows inside unity in 10 minutes using same cpu. Now using GPU lightmapper you can bake in seconds with the same result!!! You don't need to wait long time to see the result



    Lightmapping settings:
    In unity, you have 100% real world physical lightmapper. So finding a true settings are very simple. You have a physical sky light (color or ibl) and 3 simple direct light sources with true physical indirect light/shadows results. Also you have emissive materials as indirect lighting + area lights

    In unreal engine everything is fake !!! in unity you can also use UE fake style for indirect shadows or lighting to reduce noise and bake time:
     
    Last edited: May 10, 2021
  48. UnityLighting

    UnityLighting

    Joined:
    Mar 31, 2015
    Posts:
    3,874
    Some comparison results +


    Fake indirect in UE4 (tested 3 years ago):







    This is what that Bakery can't do i think:
     
  49. useraccount1

    useraccount1

    Joined:
    Mar 31, 2018
    Posts:
    275
    Please next time try to read my messages. None of this is addressing what I'm writing about and it's not even fully true. There always existed specific cases which automatic unwrapper can at best cause, definitely not fix.

    Also, I will point out this again with UV maps, there are issues with the default unity settings (and sometimes changing them) that I haven't been able to replicate in any other engine, with the same meshes.

    I can't confirm this as for me they were pretty much the same with minor differences. Yeah, the PLM provides more realistic results, the settings are nicer in unity, the GPU renderer is faster than the CPU renderer thus unity can be faster than ue4.

    One more thing about the speed, in ue4 you have a dedicated toolkit to see exactly how much time it takes to bake each mesh. It helped me to speed up the baking process by about 11%, a really nice thing unity could copy too.

    Oh and also, these screenshots you have provided here are misleading, There are a lot of parts towards making complete lightning, including post-processing, choosing the right method of AO for your type of project, sky settings, environmental settings, materials settings, shaders, and others. While there are differences between PLM and Beast (which I won't try to confirm whether they actually exist), all differences between ue4 and unity are choices of the user.
     
  50. UnityLighting

    UnityLighting

    Joined:
    Mar 31, 2015
    Posts:
    3,874
    I don't like to upset anyone. I'm sorry;)

    Please send me one of the examples of UV problem in Unity