Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

POLM - GPU Lightmapper - NLM denoising test !

Discussion in 'Assets and Asset Store' started by Vagabond_, Feb 5, 2016.

  1. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    961
    Thanks :) i really like the results from the testing as well... !

    There is one thing though, as i am not really a graphics programmer i am having some difficulties of loading all the necessary textures needed for the baking to the GPU memory... ComputeShader.SetTexture() works for a single texture only... I guess i need something like SetTextures( list of textures ) but i am not sure how this should be done !

    So may i ask you guys if you know someone who is into graphics programming and especially into ComputeShaders if can give a suggestion how one should load all the collected textures from a scene to the GPU memory... If someone could give a suggestion will be great as this is the only thing currently that is stopping the dev process...


    I can not find any info about this. There is a TextureArray2D option but all the textures should be same size and format... Not sure if this is the right way of uploading multiple texture to the GPU ( textures should be resized as i understand )...!
     
  2. SilverStorm

    SilverStorm

    Joined:
    Aug 25, 2011
    Posts:
    573
    That's strange that you are expecting an array. Wouldn't you just use that method in a for loop or something to get each texture and do the same actions on it per texture available?

    Or you can contact a Unity developer directly-here is a list of all the staff members the forum provides, they all work at Unity so you can try to get in contact with any of them since they all have that "Unity Technologies" logo on their forum name when they post.

    https://forum.unity3d.com/members/?type=staff

    to be honest asking anyone of them the question and to forward it to someone who can help you at Unity should also work since they all work together lol.
     
  3. Freznosis

    Freznosis

    Joined:
    Jul 16, 2014
    Posts:
    270
    I'm not experienced in shader writing but I would just write my own function like this.

    Code (CSharp):
    1.         public void ComputeArray(Texture2D[] computeArray)
    2.         {
    3.             foreach(Texture2D t in computeArray)
    4.             {
    5.                 computeShader.SetTexture(kernel, "source", outputRenderTexture);
    6.             }
    7.         }
    Anyways I like the stuff I'm seeing in this thread, the asset seems very promising and much more straightforward than baking in 3DS Max. I am fine with baking in 3DS Max but I'd like users to be able to bake and optimize their scenes in a level editor without having certain limitations and that's why I like this tool. Keep up the great work! :)
     
  4. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    961
    Thanks for suggestion. May be i should try ask some of the developers.

    That's the point, doing the bake in Unity instead of external package.

    Here is some progress:
    This is a video showing the progress... Light mapping is now kind of an implemented feature however there are some issues yet:

    THIS IS NOT YET AVAILABLE

     
  5. Mark_T

    Mark_T

    Joined:
    Apr 25, 2011
    Posts:
    303
    Your asset looks interesting. I have a few questions:
    1. What is the radius maximum value? What If I have to bake AO of some huge buildings and some other smaller props in the same scene? Is t possible to have a higher radius value than 1, something like 100-500 m? Looking to the interface it doesn't seem that's possible.
    2. Is it possible to bake all the objects in the scene without selecting them with the mouse? Easier and more convenient to click a button or a checkbox. Or maybe having this as an option in the options panel? (if there is one).
     
  6. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    961
    Hi,

    1. With the current available version in the store, 2 meters is set as a maximum value. This can be easily changed in the script. However ambient occlusion is a thing that can not be set to bake huge and small objects with the same settings. This is how ambient occlusion is working in general, because it is a fake shadow calculation it requires a max radius. It could be made somehow by calculating ray distance and angles in order to remove the need of setting a max radius...
    In general, if you scale down a huge object so a radius of 1-2 meters could do the job you will get a good result and after you bake the object just revert to original scale.

    2. Currently objects should be selected and added to the tool ( this was the initial idea - just a tool which baked AO per object ). I still work on the next update and will consider adding an option where you can tell POLM to bake all the objects in the scene.
     
  7. Mark_T

    Mark_T

    Joined:
    Apr 25, 2011
    Posts:
    303
    1. Sounds like a valid workaround. Objects can e sorted and loaded separately, after all. An automated version might help, but it's also good to have manual control when something goes wrong.
    2. I would even go further and have an option to add a list of premade scenes just for baking. Having to bake loads of objects such an option might be really helpful here.
    Thanks for the prompt answers.
     
  8. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    961
    Hi guys,
    just a little update on the work i've done on POLM tool.

    IT IS ALL CONSIDERED AS EXPERIMENTAL !


    The GI part is now implemented.

    Rendering GI/AO per object is re-implemented.
    Rendering GI/AO to lightmaps is implemented (needs optimization though).
    Rendering GI to the scree is possible as well.

    Rendering the screen is implemented as experimental feature as i still do not know a way to upload all the needed textures to the GPU. (All the textures in the image are the same resolution and compression! )

    This image below shows rendering the screen at 1280x720 resolution using low end nVidia 750 Ti GPU...

    POLM_Screen_Render.png

    Here is the link to the build ( Windows x64, 150 MB ZIP file ).
    https://drive.google.com/open?id=0B0xBuF57cNyNRG1NSFdoVll4YzQ

    I will be glad if you give it a try and give me the time needed to render the scene.
    You can download it and just click the screen when is loaded. It will need a few seconds to precompute the scene and than it will start rendering. After all the 500 samples are completed, the total render time will be displayed, you can post it here with the GPU model. Thank You :) !
    Give it a try at 1280 x 720 res !
     
    Last edited: Oct 7, 2017
  9. Tenebris_Lab

    Tenebris_Lab

    Joined:
    May 23, 2017
    Posts:
    35
    Awesome, It tested on GTX 970 at 1280x720 and it rendered in 48 seconds
     
  10. IanStanbridge

    IanStanbridge

    Joined:
    Aug 26, 2013
    Posts:
    334
    Hi it rendered in 41 seconds at 1080p on a vega 56. It doesn't appear to show the rendered image after it completes the render though only the time. It shows the scene at the start but the scene disappears when it starts the samples and then just shows a total time when it reaches 500 samples.
     
  11. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    961
    That's 3 times faster than the GPU i am using - that's cool - thank you !

    Hmm, we tested with AMD card but non of the new ones... 41 Seconds at 1080p is awesome though !
    P.S. it is interesting if it is some incompatibility with the new GPU or may be it is the driver !
     
  12. gurayg

    gurayg

    Joined:
    Nov 28, 2013
    Posts:
    232
    I've got 19 sec on a 1080Ti. Very good job @Vagabond_ :)
    What exactly does the rendering do?
    Is this a full 3d bake of the scene?
    or is this taking the render passes and calculating GI based on that just for a still frame?

    Thanks for sharing.
     
  13. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    961
    Hi thanks for the test - 19 sec is great result.
    Currently what it does in the demo is to calculate GI for the current still frame but progressively in time using path tracing.

    The actual point of the tool is to implement baking per object AmbientOcclusion/GlobalIllumination data to texture(s) or the scene to Lightmaps on the GPU ( which is already implemented in a way ) but rendering to the screen was used just while implementing the algorithm - it was much easier to debug the result. Same algorithm is used for baking as well !
     
  14. layola

    layola

    Joined:
    Aug 6, 2013
    Posts:
    94
    I so glad the hear that ?when will you public this version?I can't waiting for use.
     
  15. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    961
    Hi, thanks for interest...
    This is still experimental and there are things that do not work ok yet. I actually can't say when or if all these features will be released because still hitting a few road blocks...
     
  16. LightingBox2

    LightingBox2

    Joined:
    Mar 31, 2015
    Posts:
    2,817
    Unity still needs an GPU lightmapper (after losing Beast)
    Great work
     
  17. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    961
    Thank You !
    It is still work in progress though but moving forward!
    Textures are now supported as well !
     
    Lars-Steenhoff likes this.
  18. LightingBox2

    LightingBox2

    Joined:
    Mar 31, 2015
    Posts:
    2,817
    After finishing beta version, send me to test on different scene styles + beautiful scenes

    i'm going to buy your asset now, Does current version support AO baking for Tree?
     
  19. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    961
    Sure. Doing my best!

    Not yet. I did try a speed tree model, but seems to have strange uvs. Will look into it at some point !
     
    LightingBox2 likes this.
  20. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    961
    Hi guys, to give you small update on the Lightmapping work...
    today i switch to using texture arrays which is much nicer ( it seems so currently at lest ) to deal with the Lightmapping part...
    Before all the lightmaps was baked one after another and now all of them are updated per frame (sample) which is much nicer. You can seen in the video but it feels a bit laggy because of the screen capture. I expect performance on high end graphics cards to be better.

    Still need to improve the algorithm and better shadows !

     
    Tenebris_Lab and LightingBox2 like this.
  21. LightingBox2

    LightingBox2

    Joined:
    Mar 31, 2015
    Posts:
    2,817
    Create work
    Just send me a test version. I love all lightmappers and i like to help you to improve it
     
  22. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    961
    Thanks! Will do it probably tomorrow !
     
  23. LightingBox2

    LightingBox2

    Joined:
    Mar 31, 2015
    Posts:
    2,817
    Thank you
     
    Vagabond_ likes this.
  24. Tenebris_Lab

    Tenebris_Lab

    Joined:
    May 23, 2017
    Posts:
    35
    will we be able to use this at runtime. I am loading geometry at runtime and would like to do some nice GI?
     
  25. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    961
    Hi,
    there is a good chance. This is still experimental though but i am working on that direction as well !
     
  26. Tenebris_Lab

    Tenebris_Lab

    Joined:
    May 23, 2017
    Posts:
    35
    Epic! Let us at it. Glad for whats happening in GI right now. Some nice conversations starting in the forums.
     
  27. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    3,125
    Nice little plugin. AO though, it's handled in post process pretty nicely. You think you can bounce some colors around and add some form of GI?
     
  28. dozhwal

    dozhwal

    Joined:
    Aug 21, 2014
    Posts:
    58
    hi, i just bought this asset because i love AO :p

    i want to use it for a mobile game, with texture baking (to avoid to many triangles)
    if i understood well, i must 1 material by object ? so it will destroy performance...
    the unity lightmap can't be used instead ?
    i know there is the unity system for that but i don't like it :p

    i have also a noob question that the documentation didn't answer.
    in the demo scene, texture baking work without a bug.
    in my scene, baking don't produce any visible results. the occlusion map stay white. any idea why ?
    (object are colored with the same color palette texture so UVs are very smalls, maybe it's that ?)


    Also, for vertex baking, it could useful to take account of existent vertex color.
    this free asset for exemple : https://github.com/slipster216/VertexPaint
    leave the choice with AO to multiply with existent vertex color, add or replace.

    thank for you answer.
     
    Last edited: Nov 4, 2017
  29. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    961
    Hi,
    do you mind to start a conversation. I will need some more info or may be you will send me the model so i can check !
     
  30. LightingBox2

    LightingBox2

    Joined:
    Mar 31, 2015
    Posts:
    2,817
    You can bake generated AO texture into your albedo texture using Photoshop

    Shader : Realtime Image Processing

    Photoshop : Offline Image Processing

    So you can combine image and color both in photoshop or shader.

    Photoshop is only optimized case for mobile developments.

    Shader is useful when you want to calculate specular effects in realtime that's not possible in photoshop (because it is offline)
     
  31. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    961
    In the POLM package is included a tool which multiplies two textures. It is found in the Tools/Vagabond... menu...
    You can use it to multiply the AO texture over the albelo !
     
    LightingBox2 likes this.
  32. LightingBox2

    LightingBox2

    Joined:
    Mar 31, 2015
    Posts:
    2,817
    It's very good

    And where is my test version for GI ?
     
  33. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    961
    I am working on it without stopping.
    Currently moving (sorting) part of the code and shaders to be easier to read.
    I could send you later if you do not mind that it will be a bit messy yet !?
     
    LightingBox2 likes this.
  34. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    961
    Hi guys, more updates on the GI Lightmapping using the GPU.
    This is Work In Progress!

    New improvement
    : triangles rasterization part which is the preparation step for Lightmapping is now moved to the GPU using Compute Shader and it is much faster. Currently around 10 times faster on the GPU which is used for testing.

     
  35. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    3,125
    simple geometry but still this is fast. can you show baking of a high poly count (terrain)?
    Does it Bake to probes?
     
  36. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    961
    Hi, terrain is not yet supported nor light probes !
    The development of the GI part started recently and it is yet experimental !
    Only supports directional light plus diffuse and emissive materials from colors and textures !
    Supports objects using multi material setup !

    The GPU i am using is considered a low end regarding GPU path tracing. It is a GTX 750 Ti. In order to bake high dense scenes you will need a high end GPU. I will probably show how it behaves with baking high poly count at some point !
     
    laurentlavigne likes this.
  37. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    3,125
    For recent development it's crazy good. I guess if rasterization is done in compute shader now you need more VRAM.

     
  38. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    3,125
    Consider also Transmissive material - it would allow to simulate the diffuse light under a tree canopy.

     
  39. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    961
    Well the rasterization is done per atlas and all the GPU memory that's being used for that part is released after it is done for every atlas and when you start bake you should have all of your GPU memory that was available.
    The point is that a lot of other stuff should be stored to the GPU memory and it seems that 2GB is not enough for baking a lot of objects.

    I just tried to bake 1.3 million polys and it seems that 2 GB are not enough, apparently. So like developers of Octane require high end GPU it seems will be valid for POLM as well !
     
    laurentlavigne likes this.
  40. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    961
    Sure, will add this to the list !
    There are some other things that need work before attempt to try add some extra stuff though !
     
    laurentlavigne likes this.
  41. LightingBox2

    LightingBox2

    Joined:
    Mar 31, 2015
    Posts:
    2,817
    I tested this solution:
    1. Speed was same as Octane and all other GPU renderers (with faster noise redution)
    2. Diffuse bounce was not to much high
    3. Similar to octane, you needs GPU memory for baking so in high resolutions you needs higher GPU memory.
    So we must bake objects separately
    4. Used unity Lightmape window (disappear after inter to play mode)
    I prefer to use custom shader with your own Lightmapping implementation to always save the lightmap in the model
    Also i don't know how to access to Standard shader _LightMap sampler. Maybe it's possible

    The speed is too fast in 512 resolution (like Octane with faster noise reduction)

    After implementing Spot and point light, i hope this ready to use in action .

    If you implement Soft Shadow Radios option in spot and point light setting, We don't needs Area lights. Also an option make shadow radios customizable and add some blur
     
    laurentlavigne likes this.
  42. laurentlavigne

    laurentlavigne

    Joined:
    Aug 16, 2012
    Posts:
    3,125
    The great thing I just realized is POLM bakes mesh by mesh, environments are made of multiple meshes and 1 Mpoly is rare in one mesh so vram limitation won't be that big a deal.

    By the way I think it's quite great that you manage to develop a gpu baker with a low end graphics card like the 750!
     
  43. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    961
    The current version in the store bakes Ambient Occlusion only and it is a separate process for every object. The idea behind this was that sometimes you have some important object which needs some detail and you need to open it in a 3D package and bake AO texture. This was the goal of POLM to not have to deal with external packages for the purpose of baking AO.

    Now the new version which is in development is packing many objects into one atlas texture for baking into lightmaps but should keep the old functionality as well (baking per object). There might come an option which will allow you to bake just a group of objects into one atlas texture which you can then use in the AO or Detail Slot of the standard shader for example of in any custom shade which can be feeded with detail textures.

    Thanks. I am really happy too and the good thing is that the acceleration structure may boost performance if i manage to optimize it because currently is not built in its optimal variant for GPU traversal !
     
    Last edited: Nov 7, 2017
    laurentlavigne likes this.
  44. LightingBox2

    LightingBox2

    Joined:
    Mar 31, 2015
    Posts:
    2,817
    I tested again in Depth:


    - Samples limited to 2000. Should be up to 100.000(30.000 is good enough)
    - Texture size is limited to 2K. Should be 8K
    -Using unity lightmap data is not good idea. Using separate texture with different texture size for each object is better. Also we have option to customize Sample counts and texture size selection for each object
    * Ability to bake each object separately and move the next one after finish (to reduce memory usage in GPU)

    Overall Quality is same as Octane without slow downing the system. Great Job

    Customized Sample count without Blur/Dilate the texture :


    7 min using GTX960 from 2000 to 40000 samples count calculation
    1.jpg
    photo_2017-11-07_01-12-49.jpg

    After implementing Spot and Point lights, It's ready to use i n action
     
    laurentlavigne likes this.
  45. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    961
    Sure, these limits should be increased ! Will do it !
    This is how the current version in the store is working. The good thing is that many different types of baking could be implemented now - lightmapping, baking list of objects ( per object ) or group of objects ( i think also could be implemented with adding additional mesh buffers for overriding uvs ). Just have to implement all the different types of sub tools.

    I like the result in the images except that there are still some issue visible like seams etc... Trying to find a way of improving this !
     
  46. LightingBox2

    LightingBox2

    Joined:
    Mar 31, 2015
    Posts:
    2,817
    Currently simulating Point lights is possible using Emissive materials, But emissive materials has too much noise.
     
  47. LightingBox2

    LightingBox2

    Joined:
    Mar 31, 2015
    Posts:
    2,817
    10.000 samples without filter(dilate):

    photo_2017-11-07_02-27-45.jpg
     
  48. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    961
    Yes, as far as i know there is a way of improving the contribution of emissive objectс by implementing an importance sampling technique though but currently i am not aware of it plus such feature will most likely increase the branching in the code which will eventually increase the time for baking with low end GPUs. That makes me think that it is better to invest time in implementing other type of lights first .
     
    laurentlavigne and LightingBox2 like this.
  49. LightingBox2

    LightingBox2

    Joined:
    Mar 31, 2015
    Posts:
    2,817
    The issue only happens on more than 1 bounce. With default 1 bounce everything is normal:
    30.000 samples :
    photo_2017-11-07_02-33-38.jpg
    photo_2017-11-07_02-35-34.jpg
     
  50. LightingBox2

    LightingBox2

    Joined:
    Mar 31, 2015
    Posts:
    2,817
    1 Bounce vs 2 bounce
    10.000 samples + blur + Dilate

    photo_2017-11-07_03-32-07.jpg
    photo_2017-11-07_03-32-11.jpg
     
unityunity