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

[RELEASED] Mesh Combine Studio 2 (Boost Performance)

Discussion in 'Assets and Asset Store' started by eagle555, Oct 24, 2017.

  1. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
    Yes I have this planned, I made an advanced multi threaded mesh combine job manager for this that can combine meshes per frame and has lowest possible memory and GC overhead (this is already implemented and working).

    Currently MCS already saves memory compared to Unity's static batching as it has filtering with vertex input limit of each sub mesh. Combining big meshes doesn't help improve performance much and it adds more memory usage since they are big meshes. What is planned next is:

    - Finishing runtime API to add/remove objects.
    - Stream around the camera (like you request).
    - Texture atlassing.

    At the moment I'm working on making more demos and tutorial videos.

    Nathaniel
     
    blitzvb likes this.
  2. blitzvb

    blitzvb

    Joined:
    Mar 20, 2015
    Posts:
    284
    Awesome!

    Also it would be nice to have an example that use LOD.
     
  3. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
    Thanks a lot for the review :)

    Yes I will show how it works in the video tutorial.

    Nathaniel
     
    blitzvb likes this.
  4. JesterGameCraft

    JesterGameCraft

    Joined:
    Feb 26, 2013
    Posts:
    452
    Hi eagle555,

    I had a few question about this asset. I want to make sure it will work in my scenario.

    1. Does it matter what kind of shaders are being used. I'm targeting mobile and will be mostly using Vertex Coloured shaders, will this pose a problem?
    2. I have some water in my game. The mesh is static and the water effect is being calculated on the GPU. Will your tool handle this correctly?
    3. If I'm targeting a lower and mobile like iPad 2 are there any issues I should be aware of?
    4. Unity static batching in unity is not really an option for me because it generates large amounts of vertex data, too much memory consumed. What can I expect if I use MCS?
    5. If I have large objects in my environment like a large lake or large mountains I should not expect to see much benefit in terms of performance, is that right?

    Thank You,
    Regards.
     
  5. skinwalker

    skinwalker

    Joined:
    Apr 10, 2015
    Posts:
    509
    Should we disable Dynamic Batching if we are not combining dynamic objects with MCS?
     
  6. skinwalker

    skinwalker

    Joined:
    Apr 10, 2015
    Posts:
    509
    I can say that I use AQUAS Lite and combining the water (I have a few sources of water in my game) does not look good so I had to delete the combined objects and use the old ones.
     
    Anon32 likes this.
  7. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
    That are good questions.

    1). This doesn't matter. If static batching works, MCS will work as well.
    2). Yes just don't include it in the GameObject parent that MCS uses. As it's probably already one mesh, and since it has big bounds it shouldn't be included.
    3). Point 4 like you point out.
    4). Basically MCS also combines and memory increases, but the difference with static batching is that you have more filters to exclude objects. E.g. you should only combine the small meshes in this case, with a maximum vertex count of like 1000-2000. With MCS you can put this as a parameter (vertex input limit). Combine only small meshes takes a lot less memory and combining big meshes (above 5000 vertices) doesn't help much anyways, so above that it can be a waste of memory. Also you can exclude automatically big meshes with 'max bounds factor' (if a mesh bounds are x timer bigger than the cell size it won't be included).
    5). No these large objects should probably not be combined. What MCS can improve is performance of rendering of meshes like rocks, props, houses, fences, etc.

    MCS replaces static batching, but you can still use dynamic batching. You can test in a build what runs faster with or without.

    Nathaniel
     
    Quique-Martinez likes this.
  8. JesterGameCraft

    JesterGameCraft

    Joined:
    Feb 26, 2013
    Posts:
    452
    Thank You kindly for getting back and information. Much appreciated.
     
  9. shamsfk

    shamsfk

    Joined:
    Nov 21, 2014
    Posts:
    307
    Hi!

    Just bought an asset. And it makes my fps worse...

    look at this please: https://imgur.com/a/skWQC

    I have a lot of objects not marked static under one parent; I use runtime batching pointing to that parent, the static batching is off, the dynamic is on.

    When MCS kicks in fps drops from 25 to 21. The number of batches goes down for sure, but the number of tris and verts rises several times (the reason for the fps drop?)

    :(

    EDIT: turning dynamic batching off doesn't make MCS faster.
    Using the notruntime batching doesn't have any result on fps.
    In the end, dynamic batcher beats MCS, how the hell?

    EDIT 2: side note - why MCS removes occlude/occluder static flags?

    EDIT 3: Now I checked graphics jobs experimental feature. And played with batch size. I was able to make MCS just 2 fps lower than non-MCS. https://imgur.com/a/LU7qq
    Yet it is still sad, optimisation asset shouldn't lower your fps.
     
    Last edited: Nov 21, 2017
  10. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
    Yes that is exactly the reason. Without MCS you have 1.3M vertices after 4.7M, so 3.6x the amount of geometry and only 4 fps lower, that is promising ;). This probably happens because you use LOD meshes and the initial release had to be setup for each LOD separately. However with the latest release this is completely automatic.

    You need to download the latest update here:
    https://forum.unity.com/threads/mesh-combine-studio-boost-performance.501543/page-4#post-3293019

    Can you show me a screenshot of your Unity window, with MCS Inspector after you click the 'Search' button (after updating MCS). Also the Scene window visible with the cells and mesh bounds (MCS will draw them), and zoomed out so a nice overview.

    The new MCS update disables only the static batching flag on the combined meshes, because MCS is a replacement for it. Having this enabled would have static batching combine the meshes again which would double the memory of the combined meshes.

    Nathaniel
     
  11. shamsfk

    shamsfk

    Joined:
    Nov 21, 2014
    Posts:
    307
    But it does remove both occlusion flags.

    Will test new release now.
     
  12. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
    Yes but update has it enabled. Can you still show me the screenshot? As MCS settings are very important.

    Nathaniel
     
  13. shamsfk

    shamsfk

    Joined:
    Nov 21, 2014
    Posts:
    307
    Woohoo, new release is actually faster than dynamic batching )

    https://imgur.com/a/LU7qq
     
  14. shamsfk

    shamsfk

    Joined:
    Nov 21, 2014
    Posts:
    307
  15. shamsfk

    shamsfk

    Joined:
    Nov 21, 2014
    Posts:
    307
    But here is a new problem, when I have reflection prob from AQUAS, it less than double draw call with dynamic.
    But more than doubles with MCS.
    https://imgur.com/a/LU7qq
     
  16. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
    Yes geometry shouldn't be double. Probably the reflection probe excludes the layer that is assigned to your probs GameObjects. Have to set the 'Output Later' in MCS Inspector output settings to the same layer as your original GameObjects.

    Also the cell size is probably too big as there are too few cells. Can you show me the screenshot where MCS draws the cell and mesh bounds in your Scene view?

    Nathaniel
     
  17. shamsfk

    shamsfk

    Joined:
    Nov 21, 2014
    Posts:
    307
    I don't know how to make them show, but i decreased cell size to 8, it reduced a number of draw calls but dynamic batching is still faster I just don't know why now. It shouldn't be.

    https://imgur.com/a/LU7qq
     
  18. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
    Disable the 'Combine in runtime' and click the 'Search' button. Can you show with cell size 16?
     
  19. shamsfk

    shamsfk

    Joined:
    Nov 21, 2014
    Posts:
    307
    https://imgur.com/gECWPt8
     
  20. shamsfk

    shamsfk

    Joined:
    Nov 21, 2014
    Posts:
    307
  21. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
  22. shamsfk

    shamsfk

    Joined:
    Nov 21, 2014
    Posts:
    307
    https://imgur.com/CPMuENK

    got me some time to figure out how to enable this)
     
  23. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
    Yes like this, 16 looks like a good cell size setting. You can enable 'Combine in Runtime' and attach the MCS_FPSCounter to the main camera and measure the performance difference in a build with MCS enabled/disabled (as only in build in can be measured correctly, stats window is an approximation).

    Nathaniel
     
  24. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,513
    I don't see the MCS inspector setting for make readable?

     
  25. tylo

    tylo

    Joined:
    Dec 7, 2009
    Posts:
    154
    I have a question about your asset.

    Let's say I have a game level where I want each individual mesh to be moveable at runtime. For example, an empty warehouse where the player is able to decorate the interior with many meshes (in other words, a level design tool for the player at runtime, not editor-time).

    Would your asset be able to handle the fact that I would still like the player to be able to move these individual pieces of the level after they are placed? Or would any mesh I play in the game become a permanent fixture of the warehouse due them being combined?
     
  26. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
    Yes it will be possible, I'm still working on porting this technology from D.R.O.N.E. and expose the API. In Drone we do this for the arena editor blocks, everything you see is recombined on the fly at runtime on every change for 3 lods and 1 collision mesh.



    Hmm that is strange, there should be a flashing red button in MCS Inspector that says 'Make Meshes Readable'. I will look into this.

    Nathaniel
     
    Last edited: Nov 23, 2017
  27. shamsfk

    shamsfk

    Joined:
    Nov 21, 2014
    Posts:
    307
    Holy Molly! This is so awesome!
     
    Lars-Steenhoff likes this.
  28. damian0

    damian0

    Joined:
    Sep 3, 2014
    Posts:
    4
    Hi,

    I seem to be getting multiple instances of MeshCombineJobManager created at runtime and none of the creation goes via MeshCombineJobManager.CreateInstance.

    ( I am logging out CreateInstance, Awake (and asserting instance == null which fails), OnEnable, OnDisable, OnDestroy etc).

    We are not using runtime combining, its all done manually in editor and saved (not sure why MeshCombineJobManager should be created at all in this case).

    We have multiple instances of MeshCombiner (set to handle different layers).

    We are additively loading multiple scenes many of which contain their own MeshCombiners.

    When I run on hardware (xbox one) I also get the following exception spamming :

    System.IndexOutOfRangeException: Array index is out of range.
    at MeshCombineStudio.MeshCombineJobManager.ExecuteJobs () [0x000c6] in Z:\BeastQuest\Development\Assets\MeshCombineStudio\Scripts\Mesh\MeshCombineJobManager.cs:310
    UnityEngine.DebugLogHandler:Internal_Log(LogType, String, Object)
    UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    UnityEngine.Logger:Log(LogType, Object)
    UnityEngine.Debug:LogError(Object)
    MeshCombineStudio.MeshCombineJobManager:ExecuteJobs() (at Z:\BeastQ
    st\Development\Assets\MeshCombineStudio\Scripts\Mesh\MeshCombineJobManager.cs:335)
    MeshCombineStudio.MeshCombineJobManager:MyUpdate() (at Z:\BeastQuest\Development\Assets\MeshCombineStudio\Scripts\Mesh\MeshCombineJobManager.cs:128)
    MeshCombineStudio.MeshCombineJobManager:Update() (at Z:\BeastQuest\Development\Assets\MeshCombineStudio\Scripts\Mesh\MeshCombineJobManager.cs:122)

    I am running with the MeshCombiner version 1.0 (ie asset store) with the 1.13c patch applied.

    thanks
     
  29. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
    Yes there's should be only one MeshCombineJobManager that handles all the jobs, this is probably because of the multi scene usage with multiple instances. I will look into this and fix it today.

    Nathaniel
     
    Last edited: Nov 24, 2017
    passionfruit and Lars-Steenhoff like this.
  30. C3P

    C3P

    Joined:
    Oct 26, 2014
    Posts:
    46
    Do i really need LOD groups on all the objects? or am i doing something wrong?

    No matching GameObjects with LOD 0 'Search Options' are found for combining.
    UnityEngine.Debug:Log(Object)
     
  31. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
    It looks like your still using the initial release, need to download the latest update from here:
    https://forum.unity.com/threads/mesh-combine-studio-boost-performance.501543/page-4#post-3293019

    No you don't need LOD groups at all, if you have them they will be automatically detected (with the update).

    Nathaniel
     
  32. C3P

    C3P

    Joined:
    Oct 26, 2014
    Posts:
    46
    wow, okej...

     
  33. C3P

    C3P

    Joined:
    Oct 26, 2014
    Posts:
    46
    any possibility to copy the original colliders?
     
  34. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
    MCS disables the MeshRenderers and LODGroups on the original GameObjects. If there's any scripts, colliders or other components attached to the original GameObjects they still keep working. So there's no need to copy anything.

    Nathaniel
     
    Last edited: Nov 25, 2017
  35. eaque

    eaque

    Joined:
    Aug 20, 2014
    Posts:
    755
    Hi all,
    Another great tool from Nathaniel! Just bought it tried a bit even with a few meshes to test and batching is reduced 1/7! great tool! When will you release a quick video to explain how to use it the right way?
    ;)
     
    blitzvb likes this.
  36. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
    Thanks :) I'm working on the videos atm. Also I almost have an update ready that removes geometry below any surface. It works with raycasting so surface can be anything like Unity terrain or meshes that are on certain GameObject Layers.

    Nathaniel
     
    eaque and blitzvb like this.
  37. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    1,419
    @eagle555
    Just bought this asset. Seems like it's got some awesome-looking technology behind it, but I've got no idea how to use it properly just yet, so I'm really looking forward to some in-depth videos showing its features and how to make this thing sing and dance.

    For now, I am wondering if it will work well for what I'm trying to make it do...


    Here's the gist:


    I am planning a (huge!) seamless world based around tiles (either large continuous mesh chunks or small individual tile parts (at or around the size of the player) -- not yet decided on this until I figure out how to best make this asset work for me).

    Right now I'm in the planning stages, but it seems like I might end up going with large swathes of land that just *look* tiled instead of legitimately making terrain with tiles, *but* I'm wondering if this is not the correct workflow with your tool...


    Additionally, I plan to display these tiles as LODs in the distance against the horizon in a seamless world, including larger towering tiled structures that can be seen from a distance. I must specify that I'm not using actual terrain -- the *tiles* themselves ARE the terrain and are just little modular meshes. Can this handle optimizing something like that? Does this asset do world streaming to some extent also?

    I'm wanting to display far away formations built out of these smaller tiles (or tile structures), so I'm really hoping this might be able to do something like this for me. Needless to say, I'm really hoping it is possible to use this for that purpose, and if it is, would you mind helping me to understand what I'd need to do to set the system up to work most efficiently this way? D:
     
  38. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,513
    I have one question, can this work with multiple unity scenes?
    like loading a few scenes with different elements? addidively

    so maybe a delayed combine is needed after the scenes are loaded
     
  39. yonson_chappers

    yonson_chappers

    Joined:
    Feb 6, 2017
    Posts:
    33
    Thanks for this update, I have a problem with the 'mesh colliders' options though:-

    I'm using it just to test a single 3Dforge asset. I generate the new combined mesh, and save this as a brand new preset.

    Firstly the good news is that the performance is extraordinary - I have a simple instantiatior that generates 1000s of the same prefabs in a row. For the original prefab, it falls over completely at around 1000 houses, and even then can only achieve around 1FPS.

    But with meshcombiner, I've tested with over 4000 prefabs, and its still running at 100FPS+. Amazing! Also I've done absolutely no LOD stuff at all so I assume this could be improved further.

    So, it performs really well. However, I am losing my mesh colliders with the new object (see screen shot). I've tried both selected and not selected 'Add Mesh Colliders', but on both settings there are no colliders in the LOD group.

    Could you please help and advise what I need to do? With the older version of MeshCombiner the mesh colliders were persisting.
    Thanks!


    upload_2017-11-26_11-49-15.png
     
  40. clagrens

    clagrens

    Joined:
    May 19, 2017
    Posts:
    96
    I want to ask that does mcs combine mesh dynamically? For example,I use world streamer to load meshes in hunderds of trunk
     
  41. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
    Well MCS is not really a terrain streamer, it's an all round mesh combine solution and as replacement for Unity's static batching. Terrains in mesh form (not Unity terrain) are usually big chunks of meshes (big cells) and they shouldn't be combined but they need independent culling.What MCS can be used for is all the stuff that is on the terrain non Unity terrain vegetation related, like rocks, props, buildings, etc. Streaming those with MCS around the camera will be possible and I'm still working on this feature.

    Doing a huge world in Unity is tricky as you have to deal with streaming and floating point precision issue. Kerbal Space Program has good information on this:



    So that would basically require to use multiple search parents? As you want to combine everything with one MCS instance?

    Yes I'm also testing with 3DForge and get such improvements :)

    Yes making LODs would help.

    MCS can be used on the original GameObjects at runtime/editor to combine on the fly. So then you don't need to make separate combined models, as they need to be combined cell based and there could be multiple buildings in one cell that can be combined, which optimizes it much more. But if you want to make LODs then combining everything into one building and having different LODs for each building is the best approach (what you are currently doing), then MCS needs to combine it again cell based like I explain.

    I will fix that mesh colliders are added and add the feature to copy the original colliders as primitive colliders are faster than mesh colliders.


    Yes MCS is designed to be able to stream around the camera, I made a multi-threaded combine job manager for this. Only I'm still working on this feature and it will be added later, I hope somewhere next month.

    Nathaniel
     
    Last edited: Nov 27, 2017
    tapawafo, blitzvb and Akshara like this.
  42. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    1,419
    Thanks for that -- I think it clarifies things just a little more... but... What if all the things around the camera *were* small tiles (say 1-2 meters/units each) and the terrain itself was nothing more than just a bunch of little small blocks (about the size of the player, who is 1-2 meters) all the way into the horizon? How would this system work with something like that?



    Could I use your system, say, twice in the same scene?

    For example, if I have a huge distant mountain with a relatively large triangle count up close that needs to remain visible from super-far away, can I do its mesh combining and culling on a different grid arrangement so that I can benefit from your fancy mesh combining on both small and large scales -- or is this not going to be possible?

    The way I was looking at it, assuming I would like to sculpt some interesting land formations and then slice that up into large mesh tiles, and then scatter tiny stuff about it, would I be able to use two differently-sized grids and camera culling settings to control streaming w/ your asset? One would control culling of the HUGE terrain tiles, and the other would control culling of the tiny assets (rocks, trees, etc.) -- does this seem feasible with your system?



    To be clear -- my concept of "huge" isn't *HUGE!!!* like GTA games or Xenoblade Chronicles X or anything, but it is an interesting problem to me that I'd like to approach during this project of mine.

    For example, how huge could something actually be (in Unity units/meters) before I'd start to run into floating point issues? -- and how painful would it be to move the world origin to accommodate for something like that? (i.e. how would you move **everything** in such a huge world (at the same time!!) without incurring some performance hit? -- wouldn't you also have to move the deactivated stuff too, and wouldn't this mess up culling and colliders? -- or is there some trick to this?)




    I'm not new to this "large map" space by any means. It's just that I'm attempting it in Unity for the first time. I do know most of the pitfalls -- i.e. I understand floating point issues, collider issues, etc., and I'm not out to make an MMORPG or anything either. I just want a reasonable idea of what I can get away with using your system, or if you feel that a better option would be some other system like World Streamer (or perhaps a combination of two or more systems) instead?





    Would I be better served to buy something like World Streamer instead of your system to deal with this stuff, including the same stuff your system already (or will eventually) do for me?

    How would your system work for scene streaming and LOD meshes in the distant horizon? -- Your description gave me the impression that it can do LOD for very distant things (regardless of their size), but maybe what I'm imagining is too large / distant / numerous for your system to handle -- even when potentially using it separately?



    I'm not trying to be critical -- I'm genuinely just trying to get a better idea of everything involved. Thanks for your time!
     
    Last edited: Nov 27, 2017
  43. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
    Yes is important to have understanding what each product does and what you require. Terrain is something on it's own. Combining small terrain tiles into cells of larger terrain tiles is the same as using larger terrain tiles to begin with ;). You need smaller terrain meshes in the center, like 2x2, lets say 50 x 50 meters, then you put 9 meshes around those with double size, which makes it 50 + 50 + 50 = 150 meters, then another 9 meshes with double size makes it 150 + 150 + 150 = 450 meters. That's the system which you need and something like this is build in Unity terrain system already. Unity's terrain system consists out of meshes, you can see this when going to wireframe mode in the Scene window, the meshes get more detailed if you come closer, etc and you can see how it works.

    Yes you can use World Streamer to load/unload objects and terrain tiles, but still World Streamer doesn't make anything render faster so that's where MCS comes into play. MCS combines detail objects like rocks, props, building, etc in cells which can make your Scene render a lot faster. So MCS is an fps booster for such objects.

    The GTA V map is only 9x9 km2, this is possible with Unity terrain system, can use 2x2 terrain tiles for this, you can use TerrainComposer2 to create the terrains. My 24 hour demo uses 30x30 km2 with 2x2 Unity terrains. I would use an inner map of such size and use Horizon[ON] around it to make the world look huge, as we do in D.R.O.N.E.

    Peter our lead designer is releasing a new mountain mega pack with very fast and great looking mountains with 8 lods each (We're going to use those in D.R.O.N.E. :D) and can be used as background decoration or even inside the inner map itself.
    https://forum.unity.com/threads/mega-mountain-pack.505516/

    Floating points issues of jittering objects can start at like 3-4km and they jitter more and more the further you move away from the Scene origin.

    Nathaniel
     
  44. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    1,419
    Right, but what if I want to sculpt arches and overhangs or caves, etc.? -- Unity's terrain does not support this, which is a huge reason why I'm unable to use it and must use a mesh representation. There is a huge limit to heightmaps, but you mention that Unity's terrain system is just a mesh -- that leads me to wonder -- Is there actually a way to hijack Unity's terrain system and make it do progressive LOD on a custom mesh sculpted in another 3D program? -- or is this not what you are implying? I'm *not* using heightmaps for terrain, since I need special geometry and overhangs, so this is why I'm asking about tiles or sculpted terrain methods that might work with your system.


    The reason I asked this is precisely because I am unable to use heightmaps for what I'm trying to do -- I am literally *sculpting* terrain (with caves, arches, and overhangs) in Zbrush -- not just painting in Unity's heightmap 'terrain' editor.



    This is why I asked this:

    I was thinking that I could use different camera distances for culling/combining and LOD displays between various scales. For example, the rocks/buildings scale for one MCS use, while in the same scene, the mountain-range scale with that tall peak with the castle at the very top you can see from anywhere in the world uses another grid-size and LOD model (i.e. when you get close enough to the mountain, your large-scale LOD fades into the small or medium-scale LOD, and perhaps that medium-scale LOD fades into the detailed LOD as you get within a reasonable distance from it.

    I was really hoping your system might be capable of doing something like this for me.




    I know this is beyond the scope of your asset, but I'm still curious -- is there some trick to this? Moving *all* assets in your entire world, simultaneously, (especially deactivated ones) to avoid the floating point issue seems like it might take a minute. D:
     
  45. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
    Ah ok, thanks for explaining. No progressive lod on non heightmap approach like cliffs and overhangs would be a clever solution on it's own and not easy to make. Issue is the colliders, they would need to be updated as well. Best way I think is to mix Unity terrain with meshes to get overhangs and caves, RTPv3 has the option to blend Unity terrain with cave meshes (as Unity terrain needs a hole and disabling of collision on the hole) and use RTPv3 on the meshes as well so blending is seemless.

    Again MCS is about combining objects in cells with cell sizes small enough to still do efficient camera frustum culling (and occlusion culling can be used as well). Mountains and terrain tiles are meshes with big bounds and in most cases combining them together will lead in too big cells and then a lot of triangles are rendered that are outside of the screen, which will make it slower instead of faster. So using MCS on the rocks/building, castle yes, on terrain and mountains they have too big bounds to be combined.

    Nathaniel
     
  46. CoolMambo

    CoolMambo

    Joined:
    May 21, 2013
    Posts:
    19
    Hi Nathaniel. I just purchased this asset and for the most part everything seems pretty great.

    I have a quick question. In my game I am generating dungeons when the player clicks on a button in the game. When that happens my dungeon gets added to the game object that I have set as the parent object in the mesh combiner prefab. I will also mention that I am using Dungeon Architect to generate these dungeons so none of the assets are actually built until the player clicks "build". I've noticed that if I run Search manually while the game is playing it will find and build the groups...however when I enable MCS it seems to make everything disappear at that point. I was hoping MCS would be able to find my dungeon when its created and build the LOD groups then, since I am creating procedural dungeons.

    Any suggestions?

    edit: my inspector:


     
    Last edited: Nov 28, 2017
  47. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
    Yes in this case you have to call the combine method manually after the dungeons are finished generating and disable 'Combine On Start' (as otherwise MCS will not see the dungeon GameObject as they are not there yet). The RegenerateDungeonLayout waits one frame before it starts generating the dungeons. You need to edit this script (or you use another one to create the dungeons?).

    If you use one instance of MCS you can call:
    MeshCombineStudion.MeshCombiner.instances[0].CombineAll();

    and put it after the '// Build Dungeon' code like this:

    Code (CSharp):
    1.   // Build the dungeon
    2.             var config = dungeon.Config;
    3.             if (config != null)
    4.             {
    5.                 config.Seed = (uint)(Random.value * uint.MaxValue);
    6.                 dungeon.Build();
    7.             }
    8.  
    9.             MeshCombineStudio.MeshCombiner.instances[0].CombineAll();
    Or you can do it with a reference to MeshCombiner like this, and need to drag and drop the MeshCombineStudio GameObject in the reference slot on the RegenerateDungeonLayout script.

    Code (CSharp):
    1. public MeshCombineStudio.MeshCombiner meshCombiner;
    2.  
    3.     IEnumerator RebuildDungeon()
    4.     {
    5.         if (dungeon != null)
    6.         {
    7.             if (performCleanRebuild)
    8.             {
    9.                 // We want to remove design time data with a clean destroy since editor would allow modification of optimized static game objects
    10.                 // We want to do this only for the first time
    11.                 dungeon.DestroyDungeon();
    12.                 performCleanRebuild = false;
    13.  
    14.                 // Wait for 1 frame to make sure our design time objects were destroyed
    15.                 yield return 0;
    16.             }
    17.  
    18.             // Build the dungeon
    19.             var config = dungeon.Config;
    20.             if (config != null)
    21.             {
    22.                 config.Seed = (uint)(Random.value * uint.MaxValue);
    23.                 dungeon.Build();
    24.             }
    25.  
    26.             meshCombiner.CombineAll();
    27.         }
    28.     }
    Let me know if you can get it to work.

    Nathaniel
     
  48. awesomedata

    awesomedata

    Joined:
    Oct 8, 2014
    Posts:
    1,419
    Alright then, so that must be what I'm having a hard time grasping -- what you're saying is that, technically, you *can* run your MeshCombineStudio with 2 separate grid sizes, but because the massive amount of triangles to render, it would be inefficient (without proper LOD of course)

    -- but, as I intended to ask before -- if I *had* a proper LOD (built manually unfortunately), would it still be inefficient to use 2 of the differently-sized grid systems?

    Let me explain what I mean:

    Okay, so I guess what I'm trying to figure out then is how would something like Zelda BotW or Xenoblade Chronicles X have such a huge draw distance? Apparently most (if not all) frustrum culling happens only on the characters -- but apparently not the terrains -- because there is generally little to nothing occluding the view. If not that, then what solution might they likely use to achieve something like this? I know this question is probably somewhat out of the scope of this asset, but I'm genuinely curious if there's a technique that could be used to do this sort of thing in Unity.

    The way I look at it, they must have a high number of LOD iterations for mountains to be seen from very far away, and frustrum/occlusion culling just takes into account this distance (as indicated before, perhaps this is done with a second distant-mesh combine/occlusion/frustrum system pass, which would likely have to be optimized for very large meshes that don't have a high number of verts). If it helps, I do know they freeze the physics system when the player/camera is very far away, and it's possible they don't usually spawn characters unless they're directly in your line of sight (which is probably why there are usually only just a small number of them in sight at once -- but I could be wrong on this for sure).

    Thoughts?
     
  49. eagle555

    eagle555

    Joined:
    Aug 28, 2011
    Posts:
    2,705
    I get what you mean, something like this terrain system is what I tried to explain before, you need many different levels of grid sizes to reach a decent drawing distance:
    https://virtulo.us/documentation/tutorials/working-with-terrain/

    So basically the size of tiles and resolution needs to move with the camera, here is where the challenge comes as everything needs to be re-combined in different cell sizes/lods each time based on camera position, the issue comes with updating mesh colliders, this is very slow, that's why Unity terrain uses a 2D heightmap collider solution for this. So basically it would need a custom physics solution, etc. It might be possible but that would take quite a bit of work, and currently this is beyond the scope of MCS.

    I've made this terrain system a few years ago:


    It's one of the fastest, or maybe the fastest terrain heightmap systems out there. 60 x 60 km2 terrain with 1.25 cm heightmap resolution, running at 1000 fps on my nvidia 980 GTX. Everything happens on the GPU, CPU doesn't do anything, but this is still a 2d heightmap system. For 3d heightmap probably a voxel solution is best to go with.

    Nathaniel
     
    malkere likes this.
  50. CoolMambo

    CoolMambo

    Joined:
    May 21, 2013
    Posts:
    19
    Hey Nathaniel thank you so much for the quick reply. Option 1 seems to work but only after I disable and re-enable MCS using the tab key. Seems MCS is disabled from removing the On Start checkbox. When I create the dungeon MSC is enabled but i will have to turn on and off again for MCS to combine things. Maybe I will move the call to MCS combineAll into the actual DungeonArchitect.Build() function and see if that helps (could be creating that dungeon in a coroutine or something).

    Otherwise here are my results so far. Maybe someone can give me some advice on improving things a bit more with the whole output selection box.

    Before:

    After


    Just a preview of what the sectioning is doing: