Search Unity

Network Distributed Baking

Discussion in 'Assets and Asset Store' started by theylovegames, Sep 3, 2012.

  1. theylovegames

    theylovegames

    Joined:
    Aug 18, 2012
    Posts:
    176
    Network Distributed Baking 0.5 Alpha Preview:


    This package is now available in the Unity Asset Store.
    http://u3d.as/3jo

    Lightmap baking and the nicer Beast lightmap baking can take minutes depending on the settings that you've used. So why not offload the work to slave computers, so that you can continue to work on other scenes. As master, you can request your slaves to remotely bake the scene or remotely bake the selected object. You can even send files directly between master and slave. I.e. you might have a modified material and you can send the changed file directly to the slaves. In larger projects, the scene file could be megabytes, so you'll find compression built-in. And for the networking bits, everything is completely standalone. You can host the master and slave directly from the Unity IDE. You can remotely bake to another Unity instance on the same machine. You can remotely bake to another machine on your local network. You can even remotely bake to machines over the Internet.

    I'll post a link to the asset store upon approval. Feedback is welcome. The next feature could be remote file browsing on the slaves, it's up to your feedback.

    Thanks for checking out the video.

    http://theylovegames.com
     

    Attached Files:

    Last edited: Sep 5, 2012
    IgorAherne likes this.
  2. techmage

    techmage

    Joined:
    Oct 31, 2009
    Posts:
    2,133
    How did you do this? I'm really curious to know from a technical standpoint. I didn't think the Beast functionality was open enough to allow a third party developer to do this.

    Very cool stuff.
     
  3. theylovegames

    theylovegames

    Joined:
    Aug 18, 2012
    Posts:
    176
    This package is now available in the Unity Asset Store.
    http://u3d.as/3jo

    The Beast API isn't exposed at all. There are async methods for baking. And baking saves content to the scene and to texture files.

    Add a little networking, compression, and the content (lightmaps, offsets, materials, shaders, models, and baked textures) can be transferred between master and slave.

    The alpha is full source, I made no effort to hide it's implementation. Purchase the package, dive in and look at the guts.

    The networking component of the Master is an HttpListener. There are worker threads spawned to accept http requests. The Master could potentially have an administration panel accessible from a browser outside of Unity.

    The networking component of the Slave are WWW objects. No threads are necessary in the slaves. Lightmap baking is completely async via the Unity API.
     
    Last edited: Sep 5, 2012
  4. theylovegames

    theylovegames

    Joined:
    Aug 18, 2012
    Posts:
    176
    The next feature will be baking history, so you can easily switch between previous bakes. That's something you can't get from the existing Unity baking.
     
  5. theylovegames

    theylovegames

    Joined:
    Aug 18, 2012
    Posts:
    176
    I noticed in the store description that it says: "1 seat per license".

    Of course you need a Unity license to run this software. Given that you have an active license, you should be able to launch several instances of Unity on the same machine.

    Each slave computer also requires a license of Unity.

    And of course, to bake with Beast you must have a Unity PRO license.
     
  6. theylovegames

    theylovegames

    Joined:
    Aug 18, 2012
    Posts:
    176
    To host a master server, make sure you aren't already running a server on the port that you want to host. If you want to host on port 80, make sure you've turned off IIS, Apache, and even Skype might be listening on 80.

    You'll find in the edit preferences in Skype, a setting that should be turned off if you want to make your master listen on port 80.

    $SkypeNetworking.jpg
     
  7. pkamat

    pkamat

    Joined:
    Dec 13, 2009
    Posts:
    20
    Hello,

    just to clarify, if i have two slaves and the master bakes a particular scene. Will that work be distributed to both the slaves or just one?

    thanks
     
  8. theylovegames

    theylovegames

    Joined:
    Aug 18, 2012
    Posts:
    176
    The job is sent to the first available slave. If the slave reports that it's busy, it will send the job to the next slave. Idle slaves remain available to take on more jobs while the other slaves are busy working. It won't send the same job to multiple slaves and do redundant work.
     
    Last edited: Nov 2, 2012
  9. pkamat

    pkamat

    Joined:
    Dec 13, 2009
    Posts:
    20
    So slaves don't share the job?

    if it doesn't then is it in the road map?
     
  10. theylovegames

    theylovegames

    Joined:
    Aug 18, 2012
    Posts:
    176
    The next update will be kind of neat. I've partnered with Just Good Design to optimize the network layer to work with other products and simplify the API. The next update is a couple months out.

    And then this new product will have something related to Android, kind of like DropBox, but cooler. You'll see something soon...
     
  11. theylovegames

    theylovegames

    Joined:
    Aug 18, 2012
    Posts:
    176
    What would the use case be? So you bake a scene and each slave would work on a part of the scene to get the job done faster. Hmmm that could be possible. So each slave could get a selected object to bake. And then the master gets pieces and assembles the final lightmap together.

    I see so you could reduce a 20 minute job to 10 minutes because the work was split in two.

    Okay yes, that is on the roadmap, and definitely a cool feature.

    They didn't expose the API around this, but I think it will be possible.

    I only wish they exposed the baking progress and then I could show a progress bar and track that.

    If you want to help, head on over to the feature requests and cast a vote to expose the progress.
    http://feedback.unity3d.com/unity/all-categories/1/hot/active/expose-progress-for-lightmap-bak
     
  12. pkamat

    pkamat

    Joined:
    Dec 13, 2009
    Posts:
    20
    Yeap thats exactly what it would be used for.. the problem most of us face is not multiple bakes but the time taken for a single bake. The only work around at the moment is the bake selected objects until you get the right bake settings and then do a scene bake.
     
  13. theylovegames

    theylovegames

    Joined:
    Aug 18, 2012
    Posts:
    176
    The need appears clear to me.

    In the new API it's got notification bubbles and popups so you will have a better idea what the slaves and master are up to.
     
  14. fieldztime

    fieldztime

    Joined:
    Sep 1, 2012
    Posts:
    13
    Dear friend, this great asset work with unity 4 and lightmap manager 2 ?

    Many thanks.
     
  15. theylovegames

    theylovegames

    Joined:
    Aug 18, 2012
    Posts:
    176
    I have not tested with Unity 4 yet. I'll let you know...
     
  16. theylovegames

    theylovegames

    Joined:
    Aug 18, 2012
    Posts:
    176
    I talked with the developer of Lightmap Manager 2 and they are totally up to do integration so stay tuned!
     
  17. theylovegames

    theylovegames

    Joined:
    Aug 18, 2012
    Posts:
    176
    We had a ninja camp of sorts this week to review our networking code, stay tuned for updates...
     
  18. theylovegames

    theylovegames

    Joined:
    Aug 18, 2012
    Posts:
    176
    Last edited: Nov 30, 2012
  19. theylovegames

    theylovegames

    Joined:
    Aug 18, 2012
    Posts:
    176
    Continued Ninja Camp sessions. We are refactoring the network to share the connection across panels.
     
  20. deram_scholzara

    deram_scholzara

    Joined:
    Aug 26, 2005
    Posts:
    1,043
    Hey there, I'm having issues getting this to work on my local mac network.

    When I try to connect the master, I get this message continuously:
    Same thing if I try to connect a slave.

    Any advice?
     
  21. tgraupmann

    tgraupmann

    Joined:
    Sep 14, 2007
    Posts:
    828
    You likely have a process already using port 80 like httpd or apache. Try hosting the master on a different unoccupied port like 8080? And make sure you all the firewall to use that port for incoming and outgoing.
     
  22. xenius

    xenius

    Joined:
    Sep 30, 2010
    Posts:
    523
    Man, this is pretty cool. I have one question though, is this circumventing the licence that you implicitly have of Autodesk Beast when using Unity? I know they sell a separate licence for distributed rendering. I don't know the specificities of such legal issues though. Have you gotten any official word on whether this is kosher?
     
  23. tgraupmann

    tgraupmann

    Joined:
    Sep 14, 2007
    Posts:
    828
    No comment, except to say it's kosher. Unity lacks an API to check for Free or PRO. So expect users to just follow the EULA.

    If your team uses free, the Beast features won't be available.

    If your team uses PRO, the Beast features will be available.

    If your team happens to use FREE and PRO and Beast features are available, that's against the EULA.
     
    Last edited: Jan 18, 2013
  24. tgraupmann

    tgraupmann

    Joined:
    Sep 14, 2007
    Posts:
    828

    Okay I have one mac that works, and another mac that throws this security exception. I turned off the mac firewall, but I still see this socket exception. Were you able to figure it out? I'll have to dig into what I did on my mac laptop to get around the Access Denied SocketException...
     
  25. tgraupmann

    tgraupmann

    Joined:
    Sep 14, 2007
    Posts:
    828






    On Mac, you have to run Unity with elevated permissions to host sockets. Try the following command:


    sudo /Applications/Unity/Unity.app/Contents/MacOS/Unity
     
    Last edited: Apr 9, 2013
  26. Kunani

    Kunani

    Joined:
    Apr 14, 2013
    Posts:
    16
    Just purchased and installed on two machines, one Mac and other PC. Does not work in either one. Shows the same socket error for the Mac and says cant connect to slave error (on the slave machine/windows). Does not matter which port I type in and all firewalls are off. Sudo did not solve the problem on my Mac. I have latest version of OSX installed. Any other data I can send to help you resolve this?

    $Screen Shot 2013-05-19 at 11.34.48 PM.png

    The machines finally connected but this is what I get when I select any object in my scene, the console fills with warnings and errors and I can't send anything due to these.
     
    Last edited: May 20, 2013
  27. theylovegames

    theylovegames

    Joined:
    Aug 18, 2012
    Posts:
    176
    I would suggest running with Unity 3.5.7. That was the platform that I used to write the software. Using 4.X is not fully tested...
     
  28. ironbelly

    ironbelly

    Joined:
    Dec 26, 2011
    Posts:
    597
    Any word on if this runs on Unity 4.0? I'm looking at buying some seats for our studio here but we've been off 3.5 for a while now. Any update on when the next version is coming out?
     
  29. tgraupmann

    tgraupmann

    Joined:
    Sep 14, 2007
    Posts:
    828
    FYI, one thing that blocks server/client communicate is McAfee Virus Scan. Make sure your virus protection isn't blocking you from working. Remember Skynet is the Virus (Terminator 3).

    The Just Good product suite is nearly packaged up and when that ships we'll integrate the workflow and UI enhancements. One of the products in the suite is Good SVN for Unity/SVN integration.

    https://www.assetstore.unity3d.com/#/content/7242

    And of course I've been working on the OUYA launch!
     
    Last edited: Jun 26, 2013
  30. ironbelly

    ironbelly

    Joined:
    Dec 26, 2011
    Posts:
    597
    Did anythign come about from your talks with the Lightmap Manager people about integration?
     
  31. tgraupmann

    tgraupmann

    Joined:
    Sep 14, 2007
    Posts:
    828
    Totally. They are all up for it. I just have to let them know when I'm ready to integrate.
     
  32. vizerra

    vizerra

    Joined:
    Jul 10, 2013
    Posts:
    4
    It looks very promissing! Are you planning to continue development? No news about a half of the year.
     
  33. tgraupmann

    tgraupmann

    Joined:
    Sep 14, 2007
    Posts:
    828
    I've been improving the same tech in my Scene Explorer product which I'm expanding to support mesh data. After the materials, shaders, models, and animations synchronize I'll move on to realtime lighting which will display on the target device while it's running skipping the deployment process.

    http://forum.unity3d.com/threads/179306-Scene-Explorer-Remote-scene-editing

    I do plan on collaborating with the author of Light Manager 2 and adding network synchronization for that too.

    After the last six months I also made a product with my brother called GoodDrop. Which if you've done Android programming, is a gui wrapper around adb.

    https://www.assetstore.unity3d.com/#/content/5424

    In that time, I co-authored a game called "Gravi" that made it through Steam greenlight, we should be going live on Steam shortly.
    http://www.playgravi.com/

    And of course my day job I work for OUYA, and I've been adding support for engines. Now I'm up to 7 engines. Most recently feeling awesome writing C++ and Java code again after a long hiatus.
    http://ouya.tv

    I do a little bit on my hobby projects all the time. I've started to get into Mixamo and Mechanim and recorded a tutorial yesterday. This series will expand on to another tool that I'm writing which can blend mechanim states and trim/generate new animations:


    So yeah big plans. More to see as soon as we ship Gravi, which is only a few days away.
     
  34. Kablamo

    Kablamo

    Joined:
    Aug 9, 2013
    Posts:
    7
    hi there,

    I am trying to get the baking plugin to work for some of my users and am running into connection troubles.

    I have verified that the system I'm testing on is open as far as ports are concerned, I have removed the firewall entirely, and for some reason the master does not find any slaves.

    I have verified that the systems can ping one another, and that they are on the same subnet.. so I'm not sure what the problem is. We are using a newer version of Unity (4.3, I believe). Every time I try to turn on the Master it keeps showing a "connection has been reset" error.

    Any ideas??
     
  35. tgraupmann

    tgraupmann

    Joined:
    Sep 14, 2007
    Posts:
    828
    Is this on Mac or Windows? On Mac because of security you need to run Unity with sudo to be able to host sockets.

    On Mac, in the terminal to get Socket Hosting Permissions, run:
    sudo /Applications/Unity/Unity.app/Contents/MacOS/Unity

    And then Network Distributed Baking was submitted with Unity 3.X.

    I found a bug in Unity 4.X where it doesn't like empty web responses, I'll double check that my workaround is added for 4.X.

    Thanks,

    ~Tim Graupmann
     
  36. Kablamo

    Kablamo

    Joined:
    Aug 9, 2013
    Posts:
    7
    Thanks for the quick reply Tim!

    My test was using two windows boxes.. I did see the note earlier in the thread about trying with Mac and will be sure to do as suggested with that side of it.
     
  37. tgraupmann

    tgraupmann

    Joined:
    Sep 14, 2007
    Posts:
    828
    Okay so I was successfully able to use Unity 3.5,7 and connect with Unity 4.3.3. I tried both host and client.

    Make sure that when you host that it's serving pages. Just hit the server : port in the browser to verify a response is being made.

    And then your client should be on the same network as the host. Make sure the client can ping the host. Use the IP address in the client if you need to.

    If the client browser can hit the host : port it should be working.

    I should add you do all this in edit mode. You don't hit play.
     
    Last edited: Jan 15, 2014
  38. Kablamo

    Kablamo

    Joined:
    Aug 9, 2013
    Posts:
    7
    Success! we have got it to connect and its baking successfully now, so thank you for the extra information!

    One last question though.. when a scene is baked on a remote system, it seems that the user then needs to go to that system and pull the completed bake back into the master.. is this supposed to work like this? I was under the impression that a scene would get sent to the slaves, and the once completed, would be available back on the master.. or is this not an automatic step.. does this need to be done manually?

    Thank you!
     
  39. tgraupmann

    tgraupmann

    Joined:
    Sep 14, 2007
    Posts:
    828
    The system should tell the clients to "Bake" and when the scene is done baking it's sent back to the master. The Master should get a prompt that the bake is complete and clicking YES will load the update on Master.
     
  40. Kablamo

    Kablamo

    Joined:
    Aug 9, 2013
    Posts:
    7
    Okay I think then that this isn't happening.. my user Miguel who's been testing it is mentioning that in the log its showing errors occurring when the bake finishes and that the completed scene is not being sent back to the Master.

    I will try to get exactly what the log says and post it.
     
  41. tgraupmann

    tgraupmann

    Joined:
    Sep 14, 2007
    Posts:
    828
    Keep in mind some baking operations are PRO features of Unity.
     
  42. Kablamo

    Kablamo

    Joined:
    Aug 9, 2013
    Posts:
    7
    Indeed.. all of our users are on Pro versions :)
     
  43. Kablamo

    Kablamo

    Joined:
    Aug 9, 2013
    Posts:
    7
    I had my user grab a screenshot of the error..

    $Screen Shot 2014-01-20 at 10.16.58 AM.png

    (Sorry its small.. if you right click and save image and then open it will open it full size)
     
  44. tgraupmann

    tgraupmann

    Joined:
    Sep 14, 2007
    Posts:
    828
    It looks like I was trying to load the bytes from the bake, but I didn't check if the path is empty.

    Can you PM me your user's email and I'll send them a new package?
     
    Last edited: Jan 20, 2014
  45. tgraupmann

    tgraupmann

    Joined:
    Sep 14, 2007
    Posts:
    828
    Excellent thanks. Sent along a new package, let me know if that works...
     
  46. Kablamo

    Kablamo

    Joined:
    Aug 9, 2013
    Posts:
    7
    Hey Tim,

    Thanks again for your help.

    We have a different error now after using the new package..
    $Screen Shot 2014-01-21 at 10.14.52 AM.png
     
  47. tgraupmann

    tgraupmann

    Joined:
    Sep 14, 2007
    Posts:
    828
    It's saying the lightmap texture is missing with a good old null reference error. Sending a fixed package update...

    and... sent!
     
    Last edited: Jan 21, 2014
  48. Metron

    Metron

    Joined:
    Aug 24, 2009
    Posts:
    1,137
    Hi,

    a small question:

    In your first description you say that it's not possible to bake ONE scene on multiple machines but you wanted to include that.

    Is this done? Can I now bake one scene distributed?

    Thanks for answering.
     
  49. tgraupmann

    tgraupmann

    Joined:
    Sep 14, 2007
    Posts:
    828
    I am in the process of refactoring the networking layer to make room for this feature. I'll have to talk with my artists to see if this feature is possible. Unity's API does not allow for multiple computers to bake the entire scene at the same time. You you can individually bake different objects in the same scene. It would be great if before something was baked if you could know how long it might take. And then never exposed the async progress percentage.
     
  50. bitenvy

    bitenvy

    Joined:
    Jan 16, 2013
    Posts:
    2
    Hi Tim,

    On my Windows 8.1 box running Unity3D Pro 4.3.4f1, when starting either a Master or Slave I'm getting this error:

    MasterLogic: Listener.Start host=HOSTNAME exception=System.Net.Sockets.SocketException: Only one usage of each socket address (protocol/network address/port) is normally permitted.

    at System.Net.Sockets.Socket.Bind (System.Net.EndPoint local_end) [0x00000] in <filename unknown>:0
    at System.Net.EndPointListener..ctor (System.Net.IPAddress addr, Int32 port, Boolean secure) [0x00000] in <filename unknown>:0
    at System.Net.EndPointManager.GetEPListener (System.Net.IPAddress addr, Int32 port, System.Net.HttpListener listener, Boolean secure) [0x00000] in <filename unknown>:0
    at System.Net.EndPointManager.AddPrefixInternal (System.String p, System.Net.HttpListener listener) [0x00000] in <filename unknown>:0
    at System.Net.EndPointManager.AddListener (System.Net.HttpListener listener) [0x00000] in <filename unknown>:0

    On my Windows 7 box running the same version of Unity3D, I'm getting this error:

    Request error=Recv failure: Connection was reset url=http://hostname2:80/slave?j=%7b%22guid%22%3a%22bb8393c3-e842-4e6e-aecf-1741c91d76be%22%2c%22uid%22%3a%22HOSTNAME2_5892%22%2c%22date%22%3a%2204%2f03%2f2014+14%3a49%3a38%22%2c%22command%22%3a4%2c%22innerJSON%22%3a%22%22%7d
    UnityEngine.Debug:LogError(Object)
    SlaveLogic:NetworkUpdate() (at Assets/NetworkDistributedBaking/Editor/NetworkManager.cs:494)
    NetworkManager:NetworkUpdate() (at Assets/NetworkDistributedBaking/Editor/NetworkManager.cs:631)
    DistributedPanel:panelUpdate() (at Assets/NetworkDistributedBaking/Editor/DistributedPanel.cs:786)
    DistributedPanel:Update() (at Assets/NetworkDistributedBaking/Editor/DistributedPanel.cs:127)
    UnityEditor.EditorApplication:Internal_CallUpdateFunctions()

    Either way, I'm not able to even start the server/slave...

    Can you please advise?

    Thanks!
    Bill