Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Unity Level Streaming

Discussion in 'General Discussion' started by hippocoder, Mar 19, 2014.

  1. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Could I please have a little bit more information about this feature to whet my appetite? I am interested in a brief explanation what it actually is, and if it supports other things like enlighten, occlusion, navmesh etc. I consider Level Streaming to be a killer feature.
     
    CharlieSamways likes this.
  2. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,614
    Yeah, being able to load non-GameObject data additively would rock. I was pretty dissapointed to find that I couldn't use NavMesh (easily) on a particular project because I needed to load stuff additively.
     
  3. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    After this Sony title we have plans to move into 3D big time, and have had some of the team evaluating other options. The timely arrival of Unity 5 has thrown us all here a curve ball.

    Open world is the plan, and you may have noticed me moaning for at least a year or more, about open world stuff despite doing 2D. This is because the game is designed and waiting for the budget, I just needed to spend a year evaluating. We'd had just settled on our choice then Unity 5 comes along! but it's truly impressive to me that Unity is on the ball, on the same wavelength.

    I've been asking for enlighten, new physx, native pbr and level streaming among other things for quite a while in prep for this. And it's happened! It is for sure coincidence, but perhaps it just means the things I most wanted may well have been the things that made the most sense. The only thing that I still wait to see cleared up is a very high performing garbage collector, or one where we can prevent it pausing gameplay :)

    But some more info about Level Streaming would be wonderful.
     
  4. orb

    orb

    Joined:
    Nov 24, 2010
    Posts:
    3,037
    I hope they post a blog on each specific new feature. I'm particularly interested in level streaming, the new audio toolkit and that funky shader stuff. I'm guessing the streaming and new asset bundle stuff are vaguely related (better ways to store and reference data?).
     
  5. Meltdown

    Meltdown

    Joined:
    Oct 13, 2010
    Posts:
    5,816
    Especially when a solid brick wall gets streamed right into your character's head during gameplay.
     
  6. HeadClot88

    HeadClot88

    Joined:
    Jul 3, 2012
    Posts:
    736
    I would love some information about level streaming as well... Might not be using it in my current game. But in the future maybe...
     
  7. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    I'm also quite interested in the level streaming and the new multithreaded job system (also quite useful for open world games).
    Auto Level Streaming, multithread, new PhysX, new Sound system, speedthree, Physical Based Lighting + real-time GI all the nifthy ingredients to help us create bigger larger open worlds easier/faster.... geezz give me a min, I need to breath. ^^
     
  8. Mikko Mononen

    Mikko Mononen

    Unity Technologies

    Joined:
    Sep 6, 2013
    Posts:
    14
    NavMesh supports additive loading in Unity 5.
     
  9. kaiyum

    kaiyum

    Joined:
    Nov 25, 2012
    Posts:
    686
    Pardon my ignorance,
    Without unity5, we can load a whole level additively. We can do this normally or in background asynchronously.

    Via
    https://docs.unity3d.com/Documentation/ScriptReference/Application.LoadLevelAdditive.html
    and
    https://docs.unity3d.com/Documentation/ScriptReference/Application.LoadLevelAdditiveAsync.html

    We can load any asset(that includes partial or full scene) from any URL or a file via asset bundle.
    https://docs.unity3d.com/Documentation/ScriptReference/AssetBundle.html

    http://docs.unity3d.com/Documentation/Manual/LoadingResourcesatRuntime.html

    Those were pro only features.

    However we can load gameobjects at runtime, via prefab instancing or placing them accordingly. This works on both free and pro.
    Now then, what the heck is "unity 5 level streaming"? What new features will it bring? :confused::confused:
     
  10. TJHeuvel-net

    TJHeuvel-net

    Joined:
    Jul 31, 2012
    Posts:
    838
    Some assets such as Lightmaps and Navmeshes dont work well with AsyncLoad/streaming. Perhaps this is fixed?
     
  11. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    It's not the same as Level Streaming. It will pause constantly as it unpacks, allocates and sets up. It's not an ideal fit at all.Those are loading levels async, not streaming levels.
     
  12. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Still need more info on this little whippet.
     
  13. imaginaryhuman

    imaginaryhuman

    Joined:
    Mar 21, 2010
    Posts:
    5,834
    Oh so you're talking about being live in the gameplay while content streams to the gpu seamlessly as you move around. Streaming textures is I think the biggest issue because unity's texture upload speed is very bad to the point where a 5-year old average computer can't even send 1 1024x1024 texture at 60hz. Sounds like you might be looking for a kind of 'megatexture' streaming thing?
     
  14. Justei

    Justei

    Joined:
    Aug 31, 2012
    Posts:
    133
    I'd like to bump this, as it's very interesting to me too.
     
  15. sandboxgod

    sandboxgod

    Joined:
    Sep 27, 2013
    Posts:
    366
    The main crux is that navigation meshes cannot be streamed easily. I think there might have been some workarounds but I might be totally wrong. I seem to recall bookmarking a link
     
  16. sandboxgod

    sandboxgod

    Joined:
    Sep 27, 2013
    Posts:
    366
    Well, that is all level streaming does. I know in games where we implemented the feature we spawn a resource loading thread and async load everything in the background. The player shouldn't see a hitch because you async load everything while the player is on an elevator (ala Mass Effect) or running through a tunnel / or long hallway

    edit- To be clear I am not 100% on what Unity means by 'Level Streaming'. to my knowledge only navigation meshes might encounter issues and perhaps baked maps?
     
  17. kaiyum

    kaiyum

    Joined:
    Nov 25, 2012
    Posts:
    686
    So unity API is thread safe now? Good to know. I always thought of separating the "loading of resource" to multiple independent parts. And then off load them on separate cpu core(or gpu core through compute shader) via C# threading. But I have heard unity API isn't thread safe, so did not attempted it. And without using transform class, I have no idea right now, of how we should head for this direction.
     
  18. khan-amil

    khan-amil

    Joined:
    Mar 29, 2012
    Posts:
    206
    Same here. tried recently to load with "plain" loadlevelAsync, and clearly it's not working as intended, with all orts of slow downs/hitches..
     
  19. Graham-Dunnett

    Graham-Dunnett

    Administrator

    Joined:
    Jun 2, 2009
    Posts:
    4,287
    The 5.0 version avoids that hitch by spreading out the decompression over multiple frames. 4.x background loaded the data files, and once they were in memory, uncompressed them. That could eat up CPU.
     
    AlteredPlanets likes this.
  20. sandboxgod

    sandboxgod

    Joined:
    Sep 27, 2013
    Posts:
    366
    ah ok I see
     
  21. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Hi Graham,

    Thanks. Would it be possible to include instructions for Unity 5 workflow/how we should set up our assets for it and so for (when the time comes of course).

    Also how about cleaning up / removing streamed data? Will this still be slow or? I'm guessing we need to handle it all ourselves still.
     
    Last edited: Mar 23, 2014
  22. tatoforever

    tatoforever

    Joined:
    Apr 16, 2009
    Posts:
    4,364
    Alright so what about the new multithread job system? How will it work, kind of dying to know!
     
  23. sandboxgod

    sandboxgod

    Joined:
    Sep 27, 2013
    Posts:
    366
    Sorry for the confusion and not responding earlier. I was referring to a title I worked on that was in C++ in an engine we wrote from scratch.

    In Unity, I try to keep my project simple so I am hoping to stay single threaded. I did loadAsync some stuff just to test it out and get familiar with the API.
     
  24. gilley033

    gilley033

    Joined:
    Jul 10, 2012
    Posts:
    1,181
    Great, so 5.0 implements load level async as it was intended, without the hitch in gameplay.

    Yet this feature should already be implemented in Unity 4 Pro, as stated here in the docs (this is from the LoadLevelAdditiveAsync page):

    Don't get me wrong, I will gladly update to Unity 5 Pro for this feature alone, because it will improve the usefulness of my Dynamic Loading Kit exponentially and the increased Asset Sales will pay for the upgrade (assuming it actually works as intended).

    But why is an upgrade to the Load Level Async methods being pushed to 5 and not implemented in 4? I don't think it's right to advertise a feature, and then push the actual working version of said feature to a later version where users will have to shell out another $600 (assuming the Async methods are still Pro only) for it.

    Am I possibly missing something here?
     
  25. PhobicGunner

    PhobicGunner

    Joined:
    Jun 28, 2011
    Posts:
    1,813
    Looking forward to seeing what this actually means. I was working on an open-world game and abandoned it because I just couldn't make Unity's terrain work with streaming in any remotely performant manner (and not streaming things is just not an option). Would love to pursue the game idea later (maybe Unity 5.0 fixes some of the issues? I hope so)
     
  26. tswalk

    tswalk

    Joined:
    Jul 27, 2013
    Posts:
    1,109
    I would imagine the streaming would function similar to UE's where zones trigger loads that may be cached?...

    I too am interested in knowing more.
     
  27. djweinbaum

    djweinbaum

    Joined:
    Nov 3, 2013
    Posts:
    533
    I made a system that manages a bunch of scenes in a single scene. Its got a "distribute objects" button to make sure everything is in its rightful scene, so you can just work in one "world" scene and not worry about what goes in which sub-scene. You can deactivate parts of the world so editor performance is good while your working. You can even change the size of the scene grid tiles and redistribute your stuff, save all your scenes off again. Then at run time scenes are asynchronously loaded based on position, and when they're unloaded they're replaced with a giant lod (sometimes called an imposter). I'm considering selling it (maybe for tens of dollars) after I work with it for a while to make sure it doesn't have any hidden issues.
     
    blueivy likes this.
  28. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    The optimizations to loading scenes we have done are:

    There is a loading thread which does all deserialization construction of the loaded objects. In Unity 5 a lot more work has been moved to the loading thread. Also we have changed how MonoBehaviours are deserialized. It now guarantees that file reads are done linearly even when two monobehaviours have cross references between each other. A lot of optimizations have been done to minimize the work done on the main thread.
    This ranges from small optimziations in various classes to rewriting half of the serialization layer that it is built around and more effective timesliceing.

    We also did some work on optimizing texture mesh uploads, both reducing memory consumption performance.

    We have also done a lot of work on optimizing the Unloading / Destruction of objects. Most work has been moved to another thread.

    Loading is now done in paralell to integration on the main thread (eg. calling Awake on scripts on the main thread). Eg. if you load multiple asset bundles one after another, and the main thread is still integrating, then the loading thread will already start working on loading the next asset bundle.

    We have also introduced a new Virtual File system which allows us to do decompression of asset bundles on the fly on another thread on demand.
    We have introduced some new decompression formats that work better for live decompression. The new decompression may ship in 5.1 or 5.0, we are not 100% sure yet.

    We have also Multithreaded Resources.UnloadUnusedAssets and done a lot of general optimizations on it.

    Essentially we have taken all the pieces involved in loading optimized them with a focus on not causing any hiccups on the main thread so your game can run at 60 FPS while loading scenes assetbundles.
     
  29. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Thank you for the clarification. Clearly yet another reason for people to choose U5. I'm really impressed by this. Has there been any work on Destroy? - ie cleaning up and removing things we don't want in the scene any more?

    Long term, perhaps basing automated streaming on Umbra data could make sense. Or access to it's data for hinting.

    Not just for large open world:
    - A mansion could be packed with detail from room to room.
    - Low ram scenarios can be dealt with.
    - Consoles do not yet have SSDs and a streaming game means you're able to make more challenging games, more interesting games without gamer frustration.

    Interesting times.
     
  30. Brainswitch

    Brainswitch

    Joined:
    Apr 24, 2013
    Posts:
    270
    Nice. Will this effect setting Mesh.vertices etc as well?

    Sounds great! :)
     
  31. lilymontoute

    lilymontoute

    Joined:
    Feb 8, 2011
    Posts:
    1,181
    With these changes, I'd be really interested in a non-blocking Instantiate.

    Use cases would be for times when you want to instantiate an object, don't care about having it *right now*. It would ideally be used for things that don't need the whole asset bundle workflow, and allow the actual instantiate call to happen over several frames if needed (of course integration into the scene and the Awake/OnEnable call would happen whenever those are usually processed).

    Even better, if that works with Unity 5's new job queue system (along with other Unity API calls) that would be quite awesome.

    Agreed with pretty much all of this.
     
  32. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,649
    Is there anything planned for subresource streaming?

    The described changes to improve scene and assetbundle loading are cool, but for an open-world game what we often need is the ability to load and unload individual mip levels of a texture at runtime... e.g. a billboard in the distance is visible but only needs the low mips at first, but as you move towards it through the level, we'd load the higher mips (while unloading high mips from textures that we're leaving behind).
     
    hippocoder likes this.
  33. PhobicGunner

    PhobicGunner

    Joined:
    Jun 28, 2011
    Posts:
    1,813
    Actually, I have a big question.
    I noticed when working on terrain streaming that with lots of terrain chunks, in the profiler my terrains were eating up MASSIVE amounts of CPU time whenever the camera moved. The time was being spent on Terrain.CullAll or something (I can't remember). Whenever the camera moved, the FPS dropped from 60 FPS down to less than 30. Which, to me, is unacceptable.
    Is it possible this will get an upgrade in Unity 5.0? At the moment I consider it unusable for large open worlds with reasonable draw distance.
     
  34. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    If the streaming thing is solved, then simply having a ton of meshes will result in a better looking terrain and better resource utilisation regardless, so let's focus on that first.
     
  35. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,614
    That sounds awesome. Lookin' forward to it!
     
  36. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,614
    Yep, and then it'd be super simple to make a tool to manage those within the Editor. And if someone is willing to make it a little less simple, there's no reason they have be heightmap-style meshes, so we could do cooler, more arbitrary stuff.
     
  37. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    I've got this whole geeky vibe about the fact we can have super large worlds, but you can go in a small town, and inside a single room in that town, it's packed with stuff. Detail everywhere. That's the magic of streaming.
     
  38. TylerPerry

    TylerPerry

    Joined:
    May 29, 2011
    Posts:
    5,577
    I always was under the impression that the real challenge with making a huge game was making the art assets not programming the streaming? Like isn't that why GTA 5 was so expensive.
     
  39. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Yeah and we've got a decent budget coming up :)

    Also for those without budgets, I'm sure they'll appreciate the very quick loading times, ability to run normal levels on mobile hardware/low ram situations and more. It benefits everyone. Frankly, if we really look forward, then the concept of a game which *doesn't* stream in some way is absurd. Nobody really needs loading times.
     
    thempus likes this.
  40. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,614
    Well, one is a challenge of scale, the other is a challenge of tech. Once the challenge of tech is overcome, the challenge of scale typically still hangs around for a while. ;)
     
  41. paintbox1

    paintbox1

    Joined:
    Jan 20, 2014
    Posts:
    36
    Is this new loading thread only accessable via LoadLevel?
    I mean can I somehow avoid the main thread to freeze when doing GPU related things like setting terraindata(heights, splats, trees, details)?
    It was always impossible to do such things in background threads.
     
  42. IzzySoft

    IzzySoft

    Joined:
    Feb 11, 2013
    Posts:
    376
    I would like to see attaching of a delegate callback for streaming data... So we can have a separate function that is called whenever these assets are loaded for a certain room (lets say 100 assets, which are set at a higher priority) in the mansion. :)

    Code (csharp):
    1.  
    2. ...
    3.  Application.assetStreamingChanged += OnAssetStreamingChanged;
    4. ...
    5. void OnAssetStreamingChanged( GameObject go, StreamingStatus stats, Etc... )
    6. {
    7.    ...
    8. }
    9.  
    Maybe the same approach can be added when streamed assets are unloaded as you exit a certain room?
     
  43. Julien-Lynge

    Julien-Lynge

    Joined:
    Nov 5, 2010
    Posts:
    142
    Hey Joachim, can you give me a bit more clarification about a couple things you mentioned?

    Specifically, regarding your notes about multithreading the part about

    Is the texture uploading asynchronous (meaning it doesn't block the main Unity / rendering thread while creating the texture in memory), or faster while staying synchronous? In our tests, using native texture pointers unmanaged code to create a texture was only ~3x faster than using LoadRawTextureData, meaning that even if it's highly optimized, trying to load a 4096x2048 texture is still going to hiccup your game below 30 fps if it's synchronous to the main Unity thread.

    (However, that being said, I really appreciate you guys putting the time into this. Loading textures dynamically at runtime (that we can't get into an asset bundle beforehand) has been probably our biggest stumbling block).

    Additionally, just to check: with the change to how MonoBehaviours are serialized, does this by any chance mean we can include assemblies in assetbundles in 5.x? (I'm guessing not, but it's important enough to us that I thought I'd ask).

    Thanks!
    -Julien
     
    Last edited: Apr 3, 2014
  44. derkoi

    derkoi

    Joined:
    Jul 3, 2012
    Posts:
    2,255
    Well, I've pre-ordered Unity 5 despite some other interesting alternative options coming up lately. For me anyway, now is not the time to learn another engine.
     
  45. judah4

    judah4

    Joined:
    Feb 6, 2011
    Posts:
    256
    yes, please!
     
  46. jeff-smith

    jeff-smith

    Joined:
    Feb 24, 2012
    Posts:
    19
    I would also be interested in the answer to Julien's questions.
     
  47. goat

    goat

    Joined:
    Aug 24, 2009
    Posts:
    5,182
    I understand the streaming and such as being desirable from a sell game objects to monetize your game and such and for syncing game state easily for massive online game worlds but I'd be interested in seeing it used to make Unity Pro and all it's add-ons free via streaming game objects at certain points in the game directly from big businesses such as a player drinks a bottle of soft drink or buys / drive a certain make car and so on.

    In effect: Unity should create an advertising department and start taking ads from business. I think it's a good ideal and one that fits well with Unity's corporate culture. The big caveat is Unity's advertising department and the businesses that use it to advertise would have to respect a game programmers self designated 'game rating' to limit the advertising streamed to the game. No sending R rated ads to a G rated game (well the ESRB rating are more appropriate) and although folk tend to poo-poo the idea the people should simply suffer advertising I think having sense enough not to send advertising regarding zombie games to a child's game is common sense. It is offensive and some common sense should be used. I think the game designer should be able to censor whole categories of advertising if they choose too - even for games rated adult. You don't want sexual porn advertising littering your zombie porn / violence porn / ... or vice versa? You should then ban the appropriate categories. Your game is aimed at Mormons and they ban caffeinated drinks? Ban caffeinated drinks in the game. It's about being respectful to the end users, the game players, and not abusing your access to them.

    Seeing as there is a new competition for indies from UE4 it'd be nice to see a model where Unity and it's competition didn't skeletonize their Pro profits from Indies. Big companies making obscene profits can use Unity placed advertising to save on ridiculous advertising rates sounds like a win, win to me and the business advertising knows the advertisement will be at least seen if the game is played and maybe engaged directly according to game play. The advertisers will have much better feel knowing if an ad is present on screen and the player is actively playing the game rather than Tivoing it out or using other ad blockers. My suggesting this be integrated into game play kind of ruins my ideal of writing a framework in Unity to do just that and I rake in the profits from these big companies rather than current advertising agencies but I'm a pragmatic as realistically speaking I don't have the time or budget or access to key decision makers that decide on advertising budgets but I don't see why my lack of access should prevent me from suggesting it in the Unity forums. Unity has the influence to get heard in corporate board rooms - I do not. You could take the troll's view I'm trying to get myself Unity Pro and the add-ons for free; even though I don't particular need Unity Pro and the add-ons.

    Oh, and I would like to add that this might be conceived as ruining the opportunity for some game developers to make money via in-game ads I'd say that Unity can use an ad placement sharing agreement as a replacement. Say for every viewed ad the game developer gets a very small percent - meaning it will work like traditional advertising - it will take a very large installed game base and the players actually playing the game for the game developer to make money to support themselves let alone become rich. Of course Unity's new advertising division, it they decide to do this, would need to figure the math.

    It'd take a while to get this going but I think it's worth the effort - for Unity, for businesses needing to advertise, and oddly enough it works out best for the recipients of advertising if it leads to a more respectful, less offensive, and less wasteful advertising model. Saving can be passed on to customers. Big business looking to place advertising can place advertising campaigns and then advertise the game in other venues such as placards in stores and storefronts saying to download the games used in the advertising campaigns.

    If you think this is a pipe dream that you couldn't make a lot of advertising revenue with consider this ideal I've has for 2 or 3 years now: various car manufacturers can stream their new yearly introduction of car models into racing games and other games in the correct context and gain instant interest for the games receiving these new car models. A ad flyer sheet can be attached to the model so the player can look at the model in more detail right in the game. Do you know how much money these car companies spend yearly to create some truly nice looking advertising? LOL, of course Unity would need to step up the production of art and model freebies to put the nice models the car manufacturers are bound to demand in a good light.

    And maybe you'll have the purists saying advertising would ruin game play all while watching the football match with players that look like their uniforms were stitched together from one of the piecemeal quilts my grandmother made or like one of those Friday handbags stitched together from old pieces of semi tarps.

    Another suggestion is I would like to see Facebook messages / Skype messages so that players can be messaged in games by non-players and do speech to text conversion from the player as a prefab and the message stream should be inconspicuous. I helped a Chinese company translate their English properly and they had such a feed for Weibo and it was nice.

    I forgot to add the businesses could still choose to pay for Unity Pro and that would disable in game advertising. A business using Unity as simulation or presentation software would want this as would government. Businesses that wrote their own games as advertising would want that. And other special cases.
     
    Last edited: Apr 4, 2014
  48. paintbox1

    paintbox1

    Joined:
    Jan 20, 2014
    Posts:
    36
    @goat: Dont understand a single word, but Im pretty sure it doesnt have anything to do with level streaming
     
  49. goat

    goat

    Joined:
    Aug 24, 2009
    Posts:
    5,182
    @paintbox1 - And I'm pretty sure you're wrong. It's a suggestion of new framework of how to monetize steaming...kind of like people figure out how to use new plants to eat. Not rocket science here.

    Aspiring artist are you by chance?
     
  50. TylerPerry

    TylerPerry

    Joined:
    May 29, 2011
    Posts:
    5,577
    Is this level streaming from the hard drive or level streaming over the net? I was under the impression it was streaming files in from the users hard drive not over the net?