Search Unity

  1. Click here to receive a gift with your purchase of Unity Pro or Unity Enterprise.
    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

Assets WIP Lightmapper (Editor/Runtime)

Discussion in 'Works In Progress' started by bocs, May 28, 2017.

  1. bocs

    bocs

    Joined:
    May 9, 2009
    Posts:
    360
    POST IF YOU WANT THIS PROJECT TO PROGRESS!
    Seriously, I want to know if it's something needed...even a "+1" or "cool" post will do!

    WHAT?
    Preview what baked lighting will look like QUICKLY!
    Bake Lighting at Runtime or Editor

    WHY?
    So many people are looking for an enlighten alterternative

    WHERE?
    Windows, Mac, Linux
    *just not going to work on Android, IOS, WebGL

    PREVIEW:
    Very Alpha! - Quickly preview how lightmaps would look if baked.
    Download: http://bocs.site/files/BocsLightmapperV0.1.1.unitypackage

    Bad video of me testing:
     
    Last edited: Oct 18, 2017
    Siccity, nirvanajie, Peter77 and 5 others like this.
  2. iamthwee

    iamthwee

    Joined:
    Nov 27, 2015
    Posts:
    2,155
    Last time I tried lightmapping with cycles it was slow and tested poorly for indoor scenes, even with portals and GPU support.

    What are your thoughts on this?
     
  3. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    5,570
    You mean blender cycles?
    else:
     
  4. Martin_H

    Martin_H

    Joined:
    Jul 11, 2015
    Posts:
    4,163
    I think the idea has merit, but you need to show people in screenshots how accurate of a preview it is compared to actually baking the scene in enlighten. If it isn't very close, it would be kinda pointless.
     
  5. iamthwee

    iamthwee

    Joined:
    Nov 27, 2015
    Posts:
    2,155
    @neoshaman, I'm aware of the ways to speed up render time in cycles, but what I was getting at it is impractical to use IMO for a lightmapper, especially with indoor scenes.

    Do a comparison in cycles and then in enlighten and tell me the time difference. I mean, the time is considerably slower for a room in cycles when you're using the GPU and you're just rendering the scene (NOT BAKING) which is involves doing light calculations for every conceivable angle you might view the scene.

    Admittedly, the lighting is better in cycles, afterall it is meant to capture light as is, but for the trade off, I don't think it's practical. That's why I asked the OP what he thought before going at this all the way.
     
    neoshaman likes this.
  6. bocs

    bocs

    Joined:
    May 9, 2009
    Posts:
    360
    @iamthwee
    I'm still testing, so I can't say it will magically cut a 20hour Enlighten bake down to 20mins..
    Not even sure I'll do baking now unless alot of demand for it.
    Video below shows it may be more useful as a faster Preview tool?

    @neoshaman
    Yes, he said blender cycles cause I've put cycles into a Unity native plugin.
    Great video, anything on cycles will apply to this plugin.

    @Martin_H
    I did post the unity package so people can test for themself....but
    I was just making another video that shows speed, and you can compare the results.
    remember, this "could" do the baking so it wouldn't have to be 1 to 1

    --------

    *Keep in mind this video is to show the speed of getting a "good" lighting preview on the screen.
    *this is not comparing baking times...so I understand enlighten is doing a full bake, point is how long to see the results

    Tested Enlighten, and the new Progressive Lightmapper...(default settings)
    *I doubled the samples from the unity package above from 64 to 128

     
    Martin_H likes this.
  7. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    5,570
    How does it compare to segi as in editor mode shader?
     
  8. iamthwee

    iamthwee

    Joined:
    Nov 27, 2015
    Posts:
    2,155
    That's all well and good, but can I ask what the benefit is especially when you can't actually use that in game.

    For example let's say you set up a special material for cycles and you preview it, and it looks good.

    When you bake in enlighten or progressive lightmapper it will be totally different. In other words isn't this asset exactly the same as 'Bocs Shot' ?
     
  9. bocs

    bocs

    Joined:
    May 9, 2009
    Posts:
    360
    We have 2 scenarios

    1. Use as a Preview tool
    It would not be used in-game
    It's faster then the progressive lightmapper to see how changes will effect lighting
    *Also can be used for versions before 5.6
    You would not make custom materials...let it convert and never touch them (in theory)

    2. Use as a lightmap baker
    Could be used in-game for procedural levels..but honestly the texture rez would have to be low
    *something like SEGI would be better IMHO
    Custom materials would not matter, enlighten would be out of the picture completely
    biggest unknown is how fast can it do a full bake? IDK yet

    closest asset I can find:
    https://www.assetstore.unity3d.com/en/#!/content/72162


    BOST Shot is focused on getting a final image...so it's ok to use a custom cycles material, substitute materials, use filters etc. I knew it was very niche, but some people like the convenience of rendering inside of unity.

    The focus for this will either be accurate and faster lighting previews, or just replace enlighten.

    anyway, thanks for the questions
     
    Last edited: May 29, 2017
    x4000 and jcarpay like this.
  10. zelmund

    zelmund

    Joined:
    Mar 2, 2012
    Posts:
    416
    tried...
    .... its just work. nothing less. and i think its GOOD.
    first i wanted to try - increase samples =)
     
    x4000 likes this.
  11. zelmund

    zelmund

    Joined:
    Mar 2, 2012
    Posts:
    416
    and ye, +2 =)
    how did you do that? what kind of knoweledge need?
     
    x4000 likes this.
  12. 4sascha

    4sascha

    Joined:
    Mar 9, 2017
    Posts:
    45
    This i great.
    Please go on.
    Some questions.

    Is it already possible or planned to
    - import cycles materials directly
    and?
    - render/save Blender Cycles Bake Combimed Pass directly in the Unity Lightmap Slot? This could be a game changer.
    - do you sample custom hdr skys with multiple importance sampling like in cyles world settings?

    I am baking a lot with blender cycles in combinatiin with the bake tool.
    So when you need real world examples.
    I could spend some.

    My personal opinion ist that cycles and vray are the best most advanced potentials for do this job. So you are completly on the right way. The bring the new progressive One in 2017 to this level could/would take.... years.)
    Cycles with 4x Titan bakes the s.... out of it all.
     
    Last edited: Jun 4, 2017
    x4000 likes this.
  13. bocs

    bocs

    Joined:
    May 9, 2009
    Posts:
    360
    *Keep in mind, cycles and blender are 2 separate things...I wrapped cycles into a native Unity plugin.
    *I took what I learned making BOCS Shot, and what we have here is a starting point.

    @4sascha

    "- import cycles materials directly"

    It does not currenlty import cycles materials, which I would assume you mean directly from blender files.
    doubt it would be too hard, as i've implemented almost all nodes (think maybe 3 I skipped mainly cause I was lazy with the GUI)
    Unity shaders are converted to cycles nodes.

    "- render/save Blender Cycles Bake Combimed Pass directly in the Unity Lightmap Slot? This could be a game changer."
    Should be able to bake using any options in blender.


    "- do you sample custom hdr skys with multiple importance sampling like in cyles world settings?"
    yes, I think it's on by default.

    "My personal opinion ist that cycles and vray are the best most advanced potentials for do this job. So you are completly on the right way. The bring the new progressive One in 2017 to this level could/would take.... years.)
    Cycles with 4x Titan bakes the s.... out of it all."

    Yes, exactly what I hope to see...throw more GPU power and the faster the bake.

    "So when you need real world examples.
    I could spend some."

    Thanks, that would be very useful.I'll contact you when I get to that stage.


    So at this point, I need to verify if baking will be faster.
    I think the video shows it's faster at previews even with the progressive lightmapper.
     
    x4000 likes this.
  14. bocs

    bocs

    Joined:
    May 9, 2009
    Posts:
    360
    SEGI is for "realtime", this would be for offline baking or maybe a quick preview of how the bake will look...undecided, but either way this is not a "realtime" solution.
     
    x4000 likes this.
  15. 4sascha

    4sascha

    Joined:
    Mar 9, 2017
    Posts:
    45

    so here are some things i found out....

    - bake the combined pass and ao per material out of blender per pbr cycles material
    - shot this via script to the unity lightmap slot. Scene got very messy. Skipped this.
    - 5x 4K maps with 1000 samples
    - generated some ShaderForge and Amplify Shaders who mix the non view dependent bake correct with view dependent pbr reflection stuff from Unity plus detail bump and albedo
    - stay always in linear with 32bit, bake should be exr too
    - added same tonemapping like blender filmic per post process stack in unity

    bake render time is around 15h.
    Thought i reach around 90% of the cycles raytrace quality from the rendering.
    Finally i got around 98%.
    At the end i had have a realtime moveable FullGi bake who performs with 90fps on Windows/Vive and around 30fps on Android.


    What i would say is that the rendertime of 15 hours (4x TitanX) is totally ok for me when you get cycles quality in realtime.

    When denoising is finally available in bake, 512 samples should be fine.

    Tested 8k bakes too. But then you need texture streaming for bakes. However, you can zoom in to microscopic level then when you use also detail bumps.

    Your method would allow me to rebake directly in Unity. Which would be amazing.

    Conclusion.
    Don t compare your bake time with Enlighten or the 2017 Progressive. You can rech far more quality. Therefore you must not be faster at beginning.)
     
    Last edited: Jun 5, 2017
    x4000 likes this.
  16. HeadClot88

    HeadClot88

    Joined:
    Jul 3, 2012
    Posts:
    713
    x4000 likes this.
  17. 4sascha

    4sascha

    Joined:
    Mar 9, 2017
    Posts:
    45
    Thats the work from Clement Foucault. I am following his work since 1.5yrs. He is doing a great job.
    However. Eevee is a great realtime viewport for cycles nodes.
    Creating Geo and bake in Blender is great. The possibility to rebake in Unity even better.
    Unity has some.) advantages for running 3D and VR Worlds. Blender unlimited power in creating. So this what bocs is working on has a lot of power.
    On monday i will make a deep dive in his first implementation.
     
    x4000 and HeadClot88 like this.
  18. bocs

    bocs

    Joined:
    May 9, 2009
    Posts:
    360
    FYI: Updated package to 0.1.1
    Fixed: Background shaders not being updated in node editor
     
    x4000 and 4sascha like this.
  19. 4sascha

    4sascha

    Joined:
    Mar 9, 2017
    Posts:
    45
    Hey. Is BOCS Lightmapper running with Unity 2017.2
     
  20. bocs

    bocs

    Joined:
    May 9, 2009
    Posts:
    360
    Yes
    *only issue I see is that the button icons don't show up after importing package - close and reopen unity to fix

     
    x4000 likes this.
  21. u3dxt

    u3dxt

    Joined:
    Jul 6, 2013
    Posts:
    317
    Are you able to bake the entire scene with BOCS, essentially replacing enlighten?
     
    x4000 likes this.
  22. bocs

    bocs

    Joined:
    May 9, 2009
    Posts:
    360
    Could? yes
    Does? no

    Right now it's a proof of concept...
    Faster preview of what baking would look like.

    with otoy octane doing baking now, i'm not sure this would have a huge market value.
     
    x4000 likes this.
  23. LightingBox2

    LightingBox2

    Joined:
    Mar 31, 2015
    Posts:
    2,846
    Quality is awesome

    Workflow is the best between all other renderers (very lovely and easy to use)

    Very fast preview without initializing delay

    CG Offline quality rendering with very good GI quality and reflections support


    Now what i needs?
    1. baking lightmaps
    2. Noise reducing
    3. Option to adjust Sample counts (currently i increased samples to 3000 from script)
    4. Public API (i don't know currently it's public or not - i will check it now)
     
    x4000 likes this.
  24. LightingBox2

    LightingBox2

    Joined:
    Mar 31, 2015
    Posts:
    2,846
    photo_2017-12-08_05-48-32.jpg
    photo_2017-12-08_05-48-29.jpg
    photo_2017-12-08_05-48-33.jpg
     
    x4000 likes this.
  25. LightingBox2

    LightingBox2

    Joined:
    Mar 31, 2015
    Posts:
    2,846
    Another idea is displaying Sample count during bake:
    Untitled.jpg
    photo_2017-12-08_06-06-53.jpg
     
    x4000 likes this.
  26. x4000

    x4000

    Joined:
    Mar 17, 2010
    Posts:
    315
    This is very interesting indeed, and if it winds up with the @aliyeredon2 seal of approval that would mean a lot more interest, too, from myself as well as others.

    I suppose my main concern is about custom materials in unity. What's not clear from a quick pass on that thread is if this supports me using whatever materials I want in terms of surfaces. I am typically painting my meshes in Substance Painter and then using them in custom shaders created in Amplify Shader Editor. These often include features like very specific partial emission based on emission maps and HDR emissive color assignments, and then other features like tessellation, normal maps of varying intensity, and so on. I don't think I could feasibly recreate all that in another shader language that I'd have to learn.

    The other question is if this would be able to bake to light probes -- without that, it's not too useful for most realtime applications. The quality of everything in the background will be amazing, but any small objects or dynamic objects will look out of place. I'm assuming that the usual unity-style approach of "don't lightmap small objects even if they are static, instead use light probes to light them" would apply.

    If the answer to those questions are positive... well, this could be an Enlighten-killer if the quality is that high, that's for sure. It would also be partly based around how it handles large scenes, I'd say; I have 32 GB of RAM, but if I can't do the bake for an outdoor scene, that would be a problem.

    But this is very exciting to see, and if it works as advertised and can fit into an existing workflow without requiring tons of hours of manual work, then I could see a lot of people, myself included, paying real money for something like this.
     
  27. LightingBox2

    LightingBox2

    Joined:
    Mar 31, 2015
    Posts:
    2,846
    photo_2017-12-08_09-36-54.jpg
    photo_2017-12-08_09-36-54.jpg photo_2017-12-08_09-36-57.jpg photo_2017-12-08_09-37-00.jpg photo_2017-12-08_09-37-02.jpg photo_2017-12-08_09-37-04.jpg
     
    x4000 likes this.
  28. x4000

    x4000

    Joined:
    Mar 17, 2010
    Posts:
    315
    Good freaking lord! Umm... what exactly did you do to get the below? And if I recall from your interrior demo scene, all of your materials are simply standard shader with colors. Though I guess that can't be true for the plant.
     
  29. LightingBox2

    LightingBox2

    Joined:
    Mar 31, 2015
    Posts:
    2,846
    These images was form render shot and not lightmapping (Rove3D and Octane renders , offline)
    Currently this tool doesn't support lightmapping

    interior
    Most interiors used simple colors (specially white) ...
     
  30. x4000

    x4000

    Joined:
    Mar 17, 2010
    Posts:
    315
    Got it.
     
  31. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    2,815
    If you can make it work with baking on the Mac thats cool because octane does not support Mac
     
  32. lolclol

    lolclol

    Joined:
    Jan 24, 2013
    Posts:
    212
    not working, getting a white preview in editor window?
     
  33. bocs

    bocs

    Joined:
    May 9, 2009
    Posts:
    360
    Windows version? Unity Version? Video Card?
     
  34. lolclol

    lolclol

    Joined:
    Jan 24, 2013
    Posts:
    212
    windows 10 pro
    unity 2017.2
    Nvidia 940m
     
  35. blogfather

    blogfather

    Joined:
    Mar 4, 2015
    Posts:
    2
  36. 4sascha

    4sascha

    Joined:
    Mar 9, 2017
    Posts:
    45
    Hey,
    did you still work on BOCS Lightmapper or do you plan do make it OpenSource on GitHub for mass development?

    best,
    Sascha
     
  37. poisonnuke

    poisonnuke

    Joined:
    Nov 22, 2016
    Posts:
    82
    Hello bocs,

    i have 4 more questions.

    1) is it possible to get the Environment Texture visible in maximized mode?

    000_EnvironmentTexture_notvisible.JPG

    like in the minimized preview.

    000_EnvironmentTexture_visible.JPG

    2) is it possible to activate the ShadowCatcher attribute somewhere.

    ShadowCatcher.png

    3) is it possible to select the compute devices somewhere.

    ComputeDevice.JPG

    4) What i must di to bake a combined pass from the Geometrys seen in the upper left corner.
    to an .exr texture. Here i use the bake Tool.

    bake_combined2.JPG
     

    Attached Files:

    Last edited: Apr 25, 2018
  38. bocs

    bocs

    Joined:
    May 9, 2009
    Posts:
    360
    @4sascha
    No, with Octane and Unity's GPU Lightmapper coming...this seems pointless now.

    @poisonnuke
    1. simple code change, it was done on purpose to be like that
    2. no? i'd have to look at what ShadowCatcher does.
    3. no it looks for a GPU, if not found falls back to CPU
    4. Baking was the next step, it's not possible.
     
  39. LightingBox2

    LightingBox2

    Joined:
    Mar 31, 2015
    Posts:
    2,846
    For Lightmapping it's pointless now, but for Offline render it's very good (the best workflow) . just add some features like Color grading options for film settings (Gamma,Contrast)
     
  40. bocs

    bocs

    Joined:
    May 9, 2009
    Posts:
    360
    I did that along time ago...original version used Luxrender, but later switched to cycles.
    https://assetstore.unity.com/packages/tools/utilities/bocs-shot-53774
     
  41. 4sascha

    4sascha

    Joined:
    Mar 9, 2017
    Posts:
    45
    Hi.
    I think there are a lot of reasons for cyles to do the job. 2 of them

    1) There are a lot of Blender Users out there who love cycles. If 2.8 comes out it think there will be a massive grow up too.
    Compare the amount of blender users to the octane users.)
    Model and create your content with blender. Check with cycles and eevee.
    Bake when you want. Deploy in Unity and have same rebake and look.

    2) Did you saw the prising from octane. You know the pricing from cycles.)

    This is ok for rendering
    For baking i prefer to use around 10GPU.s
    For future lightfield rendering. You need many many ....
    You get all this for free with cycles.

    You saw what the B2U guys are doing?
    Together with your work you have a nice bidirectional connection from Blender to Unity.

    I will give you some examples for shadow catcher and possible further use tomorrow.

    Btw. Because of your work i cloned blender and compiled full release and cycles standalone. Now i understand how you did it.

    @aliyeredon2. Thanks for all your tutorials. They really helped me to get fast into unity lighting and Post Processing Stack.
     
    Last edited: Apr 26, 2018
  42. Siccity

    Siccity

    Joined:
    Dec 7, 2013
    Posts:
    209
    Great work. The preview render worked straight out of the box and was easy to understand. I would definitely be interested in a replacement for Enlighten. Perhaps with the addition of being able to make lightmaps on a built application for procedural levels and such.
     
  43. dozhwal

    dozhwal

    Joined:
    Aug 21, 2014
    Posts:
    58
    Hi ! is there today a ambient occlusion runtime baker ? i'm looking for one.. but it seems it's not here i will find it :p
     
  44. keeponshading

    keeponshading

    Joined:
    Sep 6, 2018
    Posts:
    608
    Hey. Do you plan to go on with this project?
     
  45. Crayz

    Crayz

    Joined:
    Mar 17, 2014
    Posts:
    162
    Looking for a runtime lightmapping solution for an in-game level editor. What would it take to make that work?
     
unityunity