Hello! My team and I have just created our first complex map and we are having troubles with optimization. The artist made the map in a modullar way, I think too much modullar because the map is composed at least by 2k objects. In the editor the load time of that scene from the main menu is short (around 3s) but in a build the scene load time is about 40s !! it is unacceptable for a multiplayer online game with short matches. so, I think the artist have to make the map in another way because the 2k objects is increasing the scene load time a lot and dropping the FPS. Is that the way? or may I can do something to reduce that time as a programmer? Thanks!!
Don't think the number of gameobjects in the scene is the issue. I have 10k gameobjects in our game and load time is around 10 seconds on android
And what could be? because it is not normal, in the editor it goes fast as hell but in the build :/ I don't know what happens
That 2k more or less modular objectss (all have a renderer) and lights, I disabled all but the walls and duplicated all the walls like 5 times to reach the number of all objects and it is lasting more or less like before (3~4s in editor 40~s in build)
You need to provide more information on what type of objects are in your scene, how many vertices are used by the all the meshes, and any code that might be using reflection or loops inside any of the functions Unity calls.
Thanks for your answers, I'll take a closer look but there is only one background sound, no plugins and the common PBR shader, in textures we use 4K and 2K textures. There are 3 reflection probes in the scene but they are not active. There isn't any code in the scene, is only a map where I spawn the players that in other map works perfect and fast. How do you check how many vertices are used in a unityScene?
I believe you can click and enable the "Stats" button when using the "Game" view in the Unity editor. It will display the total number of "Tris"(triangles) and "Verts"(vertices) if you zoom the camera out to encompass the entire scene. My guess is an over abundance of 4K and 2K textures if there are no scripts in the scene. It would also be helpful if you provide a picture of the scene view, the number of textures, the total file size of the client folder after building, the target build platform, the specs of the system you're running the build on, and the current version of Unity3D that you are using.
Ok, here is the Stats view if I align a camera in a view where I can see all the scene but when I'm playing looks like this I don't understand anything It is supposed that our artist used low poly :/ and the player is inside a room so... I don't know how unity is rendering 11.1M tris, he is in a room not seeing all the map, I suppose that unity doesn't use oclussion culling and frustum culling automatically right? EDIT: I have 1970 Gameobjects (counted them by script) and our wall modules for example Have 86 verts, I don't know how is rendering 15M verts because that means 7.614 verts per Object in average :/. I've counted the number of vertex by script of all gameobjects and the is 1.7M vertex (counting all the gameobjects.sharedMesh.vertexCount), I don't know how Unity reach the 15M. I know now what happens, if I deactivate the lights It goes down to 1.7M vertex but with lights it raise to 15M
Unity automatically culls objects that are not in view. I wanted the total vertex count to see how many vertices you are trying to load at run time. Please provide the rest of the information I requested.
Unity 5.4's new deep memory debugger in the profiler can tell you exactly what is being loaded into memory and how much memory it is taking. Should be able to work out problem area's from there
I had an issue with thing's being loaded into memory that didn't need to be in the build at all. Fixed the issue by tagging them OnlyInEditor before doing a build
To improve my loading times, when my level is saved in the editor, a script removes all meshes and meshrenderers and saves the meshes and the gameobject's name to a serializableDictionary in a ScriptableObject. When I load my game, I use a mesh combiner to combine all the meshes stored in the dictionary, using the gameobjects transform scales rotations and positions. Also to prevent any objects from popping up, I have my camera fade in to the level. I should add that my game is 2d, and that you might not want to do this if you want to combine every mesh together if you plan to use occlusion culling. You could combine small portions of meshes that are in the same place
Modular scenes are a GOOD thing. You actually, on big projects, don't want to have 10 million tri's combined to a single object. This will prevent you from taking advantage of occlusion culling although it will benefit your draw calls (batches). There are a bunch of ways to optimize this, and as mentioned above, some issues you need to consider. Generally speaking, breaking your level up into smaller chunks and bringing them in through LoadLevelAdditiveAsync is a good way to go for faster loading. Another important step, is LOD. Then you can load say, only a Cube first (think : immediate load) then lazy load the rest of the scene in at a reduced LOD (think reduced simplified meshes) and let the system up the mesh count slowly. You can also use this to take advantage of GI and light baking, so it doesn't have to rebake the entire background level for example, if you are re-using it through 50 scenes. That said, the second issue you are going to run into quickly is your FPS. Generally speaking, you want to aim for around 1.5 million tri's and 2,500 batches at most on desktop (this is where I've found the sweet spot to be on VR anyway). Vive excluded, it has some bad SteamVR stuff that needs to be optimized in their camera loops if you want to push that much to their minimum spec systems (nested, iterative, GetComponent calls per frame, just bad design - but I digress).
Thanks for all your replies, I've been in a place without internet so I couldn't connect to the forums. Our performance problem (FPS drops) is because not using oclusion culling so it will render all the vertex of the scene in some views (1.7M but with lights almost 15M even using the standard shader). The loading time is weird, in the editor loads almost inmediatly ~3s but in build is 52s, too much time, does anybody know why this is happening? We are talking to make the map less modullar because 2k objects to make a small map is a nonsense (each tile is a gameobject), they event have spaces so we are changing all this. My system is a msi laptop GE60 CPU: Intel core i7 4200HQ GPU: Nvidia GTX 860M RAM: 12 GB DDR3 1600MHz Our final build weights 1.88 GB but we have 6 weapons with 4K textures and their audio, 2 Player models with 4k textures and another map with an 8K texture, when I say textures I mean diffuse map, normal map and metallic map. Here is a screenshot of the memory profiler, the peaks of the right is where I load the scene in the editor.
Is a multiplayer game, I'm testing with the LAN so I derived a class of networkDiscovery (as it says in the manual) and called startAsHost() who calls LoadSceneAsync If I'm not wrong
Yes, as should be apparent. In the editor, your meshes and textures are already in memory. Unity doesn't have to read them from the disk again when you enter play mode. In a build, you have to load the meshes and textures from scratch. I bet that the first time you open the scene or enter play mode in the editor, it takes about the same amount of time as loading into a build. I'd suggest loading as many of your levels meshes and materials during your intro sequence (intro movies & main menu). Then the actual level loading can be snappier. Additionally, as someone else mentioned, break your big scene into several smaller ones and load them additively in an order that makes sense. eg, if you start in a small room, only load up that room and its neighbors, then slowly load in the surrounding area until the whole scene is in. Breaking your big levels up in to smaller scenes, then loading and unloading them selectively as the user moves around, is the standard way to get high poly scenes onto the screen with reasonable load times.
I supposed that difference was because of that, and yes, the first time I open the scene in the editor it takes time, I think not that much but more or less. How can I load the materials and meshes through main menu and movies? Resources.Load()? but what Should I do with that Object?
In the Memory profiler change simple to detailed and click take sample, can take a long time but shows exact memory usage of each gameobject.
Right there! For some reason, the function LoadAsync its causing that time to be so long. It has happened to me before and switching back to Application.LoadLevel(), made it work a LOT faster, in like 3 seconds! I hope that helps!
In the memory profiler it looks like the textures have a lot of memory usage: And also Other -> Objects And it seems that the GC Allocation is in that map because I set a map (with the same player but different map only) and I have around 170 GC per frame with a few peaks to 1400
Seriously? I'll take a look Edit: I took a look with SceneManager.LoadScene because Application.LoadLevel is obsolete but the result is the same, around 50s of loading time
Maybe Find out the problem texture and adjust the compression settings, also you have 300mb of Lightmap data which seems rather large, is it a enormous level or something
Nope, is not enormous, it is like two floors of a building but the 2k objects I think have something to do with that lightmap data
Maybe compare your lightmap and texture settings on the map to you other map settings.... We have a large scene with thousands of objects and our lightmap data is only 5mb
In the lightmap windows and you can also adjust the texture settings of the baked lightmap that is generated.
Looks like I'm a little late to this discussion, but in case this helps anyone else.... if you're using more than a few Substances in your project, you may want to prebake or at least cache them as opposed to building on level load each and every time. You may notice a difference.
We don't use any substance in this moment, We deleted that level, it was usable in that moment but hey, thanks for the info XD
Browsing through comments - am I the only one concerned by your scene having 11M triangles? This is a huge amount and way beyond what should game have o.o
It was the lightning, too many lights in forward rendering cause that much triangles, I would use occlusion if I have to set it again
Had 20+ substances in my scene and didn't realize that they were the scene loading problem. Didn't even know you could prebake them. Went from 20+ min load times down to a few seconds, so thank you so much!
Maybe make a copy of your scene (and GI data) and try to remove stuff, starting with the baked lighting. Once you get a loading boost you know that that thing caused the loading time and you can start optimizing. But when I see >1GB of Textures, that is not just loaded in in a fraction of time. Of course the editor already has that data loaded so I bet this has a big influence. So one solution is to use AssetBundles and load that textures e.g. the first time the player starts a match and before you load the level. Or will Unity even keep those Textures in memory if you unload the scene? I think not but I don't know for sure. Probably not hte case: Are you sure that it is the loading of the scene or maybe also caused by Awake() and Start() mehtods? But that should then also be happening in the Editor.
hi there , looks like i'm little bit late to the party but , same here i had about 40 ~ 45 seconds of load scene and i'm just reduced that to less than 25 seconds on android build by removing the songs from game but now by taking samples of memory in profiler i faced with this : so the textures 2d is way far off the bounds , but when i expand it iface with this : what the hell is going on??? what are those unnamed hidden files ???
If you were in front of me i would kiss you man! I have 2 days to finish my project and everything is ready besides the 2 mins loading time! After doing this it went to 9 secs... By the way if someone reading this and trying it, you should reimport the substance material. Will save you headache later!
Even 70 to 80 plus start producing lags for 3d games I always try to make them lower to 30 to 70 always.