Search Unity

Mesh Baker LOD [RELEASED]

Discussion in 'Assets and Asset Store' started by Phong, Nov 1, 2013.

  1. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Hi LeveAnts, I would take a careful look at the LOD setup. For some reason the same MeshRenderer in the scene is being added twice to a combined mesh. You should be able to use previously baked mesh assets. There is nothing magic about the baked meshes. A mesh is a mesh is a mesh.
     
  2. LeveAnts

    LeveAnts

    Joined:
    Jan 13, 2016
    Posts:
    2
    Hey again, I didn't quite figure out what was causing the mesh to be added twice, didn't have to really I ended up using own meshes combined in blender, the vertex count rising issue was something weird with unity's Game view statistics, started working today on my project again, and somehow magically after opening unity the verts count went back down matching those of the meshes in the project view.

    Thank you for replying so soon Phong, really good support there from your side definitely a worthy asset with such dedication.
     
  3. Rod-Galvao

    Rod-Galvao

    Joined:
    Dec 12, 2008
    Posts:
    210
    Hi,

    Does Mesh Baker LOD decimates a model at runtime?
    If not, could it be integrated with solutions like Automatic LOD?

    Regards,
    R
     
  4. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Hi Rod,

    Mesh Baker LOD does not do any decimation. It is similar to an LOD group.
     
  5. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    I will be on vacation from July 8th to July 17th. Support will not be available during this time. Sorry for the inconvenience.
     
  6. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    1,642
    Shouldn't you update the original post removing the unity free references?
     
  7. Rod-Galvao

    Rod-Galvao

    Joined:
    Dec 12, 2008
    Posts:
    210
    We have a bunch procedural generated content so there isn't LOD at editing time to attach to Mesh Baker LOD.

    Could you integrate it with Automatic LOD or provide us a way to attach a dynamic mesh at runtime?
     
  8. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Hi Rod, the LOD prefabs need to be built in the editor. It is not really possible to build them at runtime.
     
  9. Ramulos

    Ramulos

    Joined:
    Feb 19, 2017
    Posts:
    57
    Hello,

    I implemented mesh baker and lod for my trees(alot of them) in my project. I was hoping you could help me with two things.

    There's an issue of popping when it transitions from one lod to another. I know in the unity lod system there's a crossfade feature to make the transition smoother. Is there any way to put something like that in place here?

    Also my project is for VR so id appreciate any tips you have on maximizing performance and squeezing every ms i can get. i.e. best max vertices in combined mesh for performance, cluster type simple vs grid (doc doesn't mention performance), garbage collector optimization for the meshes, anything else you think might help would very much be appreciated.

    Sorry if I'm asking a bunch. Thank you for your time.
     
  10. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Hi Ramulos,

    Sadly there is no easy way to avoid the popping. The Unity crossfade system is deeply integrated with Unity with no way to hook into it. One thing that helps is to try to make sure the LODs have the same silhouette.

    Regarding performance, is your game on Mobile or PC? Tuning can be a bit of an artform. I would recommend sizing the clusters to be about 1/3 the distance from the near to the far fustrum using the grid cluster. The max verts in combined can very a lot depending on hardware you are running on for mobile I would suggest 15k but this is something I would experiment with.
     
  11. Ramulos

    Ramulos

    Joined:
    Feb 19, 2017
    Posts:
    57

    Thank you for the reply :). Im using pc vr, the HTC-Vive. Ill try out the cluster size reccomendation and play around with the max verts a bit.
     
  12. Ramulos

    Ramulos

    Joined:
    Feb 19, 2017
    Posts:
    57
    Hello again,

    Sorry to be asking questions every other week. Everything seems to be working great so far, managed to to mitigate the popping effects with some "creative" use of lod models and fog.

    I have another problem regarding the startup of the Lod manager. How can I delay the lod manger from searching for the lod camera script till after I've initialized the camera?
    Currently to support vr multi platform my scene is initialized with a vr sdk manager to detect which headset is connected and then creates the relevant camera prefab and settings from that since each has a unique camera. The problem is that the lod manager meanwhile is constantly throwing hundreds of errors and slowing up the startup massively saying it cant find a lod camera script. Where can I make this delay happen?
     
  13. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Hello, this will be tricky as the setup for each LOD would need to be delayed as well. This is something I hadn't considered when designing this. I will try to fix it so that things work without a camera.

    As a workaround I would suggest:

    Have an extra camera in scene with a LODCamera script on it. When you camera is ready. Add the new camera to the manager using LODManager.AddCamera. Then remove the initial camera from the LOD manager and delete it. It is a bit of a hack but it should work.

    [Update] adding the line to MB2_LODManager.cs line 512 (line 7 in the code below) should fix the errors when there is no LOD camera in the scene. You will still need to call "AddCamera" when your camera is ready.

    lodCameras = new MB2_LODCamera[0];

    Code (CSharp):
    1.      
    2.  
    3. public MB2_LODCamera[] GetCameras(){
    4.             if (lodCameras == null){
    5.                 MB2_LODCamera[] lcs = (MB2_LODCamera[]) MB2_Version.FindSceneObjectsOfType(typeof(MB2_LODCamera));
    6.                 if (lcs.Length == 0){
    7.                    lodCameras = new MB2_LODCamera[0];
    8.                     MB2_Log.Log(MB2_LogLevel.error,"There was no cameras in the scene with an MB2_LOD camera script attached",LOG_LEVEL);
    9.                 } else {
    10.                     lodCameras = lcs;
    11.                 }        
    12.             }
    13.             return lodCameras;
    14.         }
     
    Last edited: Aug 24, 2017
    syscrusher likes this.
  14. Ramulos

    Ramulos

    Joined:
    Feb 19, 2017
    Posts:
    57
    Thank you so much! :D:D:D
    This fixed my problem. I'm able to startup now with no errors from the LOD manager. Thank you for all your help and awesome work on these assets!
     
  15. LootlabGames

    LootlabGames

    Joined:
    Nov 21, 2014
    Posts:
    343
    "Combine many skinned meshes into a mob that renders in one drawcall."
    Does/can that happen at runtime?

    I am created an ARPG that will contain many skinned meshes on the screen at one time.
    I am looking to buy or create a tool that bakes skinned meshes with matching materals/shaders at runtime.
    So if a character enters the cameras frustum it will be baked into an existing(or new) skinned mesh, and removed from it when it leaves the cameras frustum.

    Can MB LOD do this?
     
  16. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    It does something very similar. It bakes the skinned meshes based on proximity to the camera. It does all the mesh combining at runtime.

    I would encourage you to create the atlases ahead of time. This process takes time and there are limitations like all textures must be readable.
     
  17. JBR-games

    JBR-games

    Joined:
    Sep 26, 2012
    Posts:
    708
    Hi, i currently own the paid version of mesh baker , and felt mesh baker LOD might be a nice add-on to use as well. I was wondering if there was any added support for billboards as a final lod level. I noticed in the reviews someone posted some code that may have made it possible ? thanks
     
    Last edited: Aug 14, 2018
  18. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Hi JBR-games,

    It is not possible to include BillboardRenderers in a combined mesh. I tried to do this but the meshes used by BillboardRenderers are not simple meshes like those used by SkinnedMeshes and MeshRenderer meshes so I doubt that it will ever be possible to do this.

    BillboardRenderers can still be used by the LOD, by setting the "dont include in combined mesh" flag, but there will not be a performance benefit. That is what the code did in the review. It sets this flag.
     
    JBR-games likes this.
  19. syscrusher

    syscrusher

    Joined:
    Jul 4, 2015
    Posts:
    1,104
    @Phong, I have the paid version of Mesh Baker and am just learning to use it. I watched your tutorial video last night (nice job on that ... very clear and easy to follow).

    Is the LOD tool still an add-on with the paid Mesh Baker, or is it included with the paid MM but an add-on for the free version? I ask this because when I imported Mesh Baker, I saw some references to LOD things in the import list. I'm not unwilling to buy the add-on, but wanted to make sure I don't already have it included. :) Thanks!
     
  20. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Sorry for the slow reply. Mesh Baker LOD is not included in Mesh Baker. It is an independent asset. It requires Mesh Baker.
     
  21. syscrusher

    syscrusher

    Joined:
    Jul 4, 2015
    Posts:
    1,104
    No worries on the response time, and thanks for the info. No objection that it's not included, just wanted to make sure I wasn't double-buying. :)
     
  22. attaway

    attaway

    Joined:
    Nov 12, 2014
    Posts:
    45
    Hey I'm interested in getting something setup like Unreal's HLOD with Impostors described in https://shaderbits.com/blog/octahedral-impostors/ and https://docs.unrealengine.com/en-us/Engine/HLOD/Overview.

    I'm using Amplify Impostors to generate impostors but then I'm wondering if its possible to integrate them with Mesh Baker & MB LOD in the same way. The system described works by selecting "Use MaxLOD as Impostor".
    I'm generating my own LODs so I dont mean to include their Auto LOD system, just the way in which they work with clusters and impostors.
     
    taydevr and JBR-games like this.
  23. unity_Zf3d_qzQMfmU3Q

    unity_Zf3d_qzQMfmU3Q

    Joined:
    Jan 30, 2020
    Posts:
    27
    Hi,

    This is in the documentation:
    "Requires Mesh Baker 2 - available in the Asset Store"

    And I already have latest Mesh Baker, then this is the error
    The type or namespace name 'MB2_MeshBaker' could not be found (are you missing a using directive or an assembly reference?)

    What should I do, mate?
     
  24. unity_Zf3d_qzQMfmU3Q

    unity_Zf3d_qzQMfmU3Q

    Joined:
    Jan 30, 2020
    Posts:
    27
    I tried but it's still getting these errors
     
  25. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Hmmm, what version of Unity are you using. I have tested in 2019.4 and 2018.4 and it works for me.

    It looks like MeshBakerLOD cannot see the Mesh Baker scripts. Are you using "Assembly Definition Files" in your project? Or did you put the Mesh Baker LOD scripts in the Plugins folder? If the Mesh Baker LOD folder has been imported into an different assembly than the Mesh Baker scripts then you will need to add a reference to the Mesh Baker assembly from the Mesh Baker LOD assembly.

    You can see what assembly a script is in by selecting it in the project and looking in the inspector:

    upload_2020-7-2_16-32-13.png

    If the Mesh Baker LOD files are in a different assembly then you will need to add references to the Mesh Baker assembly by assigning a reference to it in whatever assembly the Mesh Baker LOD is in. Let me know if that is the case.
     

    Attached Files:

    unity_Zf3d_qzQMfmU3Q likes this.
  26. unity_Zf3d_qzQMfmU3Q

    unity_Zf3d_qzQMfmU3Q

    Joined:
    Jan 30, 2020
    Posts:
    27

    Thanks, i have solved the issue by deleting the folders and re-import the package. It was a mistake from my colleague
     
    Phong likes this.
  27. DeadHandInteractive

    DeadHandInteractive

    Joined:
    Dec 11, 2015
    Posts:
    1
    Hello,

    Has anyone tried implementing dithering or crossfading between LODs? I'm not sure how Unity's default LOD system handles it, but we would like that functionality for the game we're making.

    Cheers,


    Greg
     
  28. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    1,642
    @DeadHandInteractive as far as I understood the option works only with the built in pipeline and it's not their fault.
     
  29. Rensoburro_Taki

    Rensoburro_Taki

    Joined:
    Sep 2, 2011
    Posts:
    274
    I've tried to follow the videos, but they make everything more confusing! So much repetitive moves, unnecessary lists to compare etc. Looks to complicated for so much money.
     
  30. Rensoburro_Taki

    Rensoburro_Taki

    Joined:
    Sep 2, 2011
    Posts:
    274
    Video 3 on the official site, for example. He does this and that, but you simply don't see how the LOD's will be baked, before he drops them into the LOD manager.

    Following processes I understand:

    Add > Component > Mesh Baker LOD (which is NOT a baker, just to setup the LOD's, but it's called "mesh baker LOD" (1st confusion)
    • Ok, > define the LOD's in this "LOD" (which sets up as BAKER, no bake button there!)
    • -MISSING- bake that into one proper file for the LOD manager <--- how the hell with LOD's
    • setup in LOD manager

    Then this, in that case, you need Mb2, and then mb3, but mb3 needs mb2... come one, man!
    Make it USER FRIENDLY! Sorry, but the Videos are like from the beginning of the internet. And I don't see any automatic features for this price!

    At least if I could understand how the LOD's are baked before they get dropped into the LOD-manager. But if you watch the video, you get the crisis.

    And sorry, I usually don't complain. However, somehow this documentation makes me CRAZY! Because I want to understand it, but I feel somehow ripped off, when watching them. And so much "uhh",, "ahh"... it feels like it's complicated to handle the plugin for the dev too. Really! :/ These videos feel like a laptop montage that only makes the whole thing less serious. Maybe I'm too spoiled. idk....

    UPDATE: Ok, I bought both packages. Will try to dig in.
     
    Last edited: Oct 24, 2020
  31. WaqasGameDev

    WaqasGameDev

    Joined:
    Apr 17, 2020
    Posts:
    118
    Hi Phong, I already own your Mesh Baker Paid version and using since last many months. It is very good but ofcourse is not suitable to use with LODs if I want to keep verts count low as well along with drawcalls. I consider using Mesh Baker LOD will achieve both. Reduced Draw calls and Reduced verts count. So I am interested to buy this tool but I would like to ask you before this, does this tool still updated and worthy to buy? I am asking because I see the last review years old and also most of the posts of this forum. Let me know. Thanks.
     
  32. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085

    I would say it is less useful than it once was. When I first created it, the free version of Unity did not have LOD or static batching and there was no StaticBatchingUtility class.

    Note that you can use LODs with Mesh Baker if you use Batch Prefab Baker and set the instances of your prefabs to be static. Unity's static batching still works with LODs and culling. This is a very powerful workflow.

    That being said. Mesh Baker LOD is still useful because it does things in a different way than Unity's LOD and batching. Mesh Baker LOD can be used with dynamic objects that are created and destroyed at runtime (eg. a large open world). It is also useful for managing huge mobs of skinned meshes (eg. a large crowd). A few meshes close to the camera will be LOD0 and most of the crowd in the background can be very, very low poly.
     
  33. WaqasGameDev

    WaqasGameDev

    Joined:
    Apr 17, 2020
    Posts:
    118
    Hi, thanks for the honest opinion. As far as your below approach is concerned, you are saying for this approach it is MUST to use "Static Batching". But the problem I get by static batching is that the size of build is increased because static batching saves a copy of combined mesh at build time.
    If I am getting it all right, I can not use Static Batching because for me build size is very important as it is android targeted game.

    Here I am attaching an image to explain my understanding and at end are my few questions. Thanks for your patience to read so long.

    My car is moving in city and below are two cases. Note that colored buildings are the buildings near the player car and can be rendered and black buildings are in scene but are not in the view. The most left building is referd as building number 1 and most right building is refered as number 9. Numbering is with respect to most left and not with respect to car.

    Case 1. Car is between building number 1 and 6 and building number 7 to 9 are not rendered. For visible buildings, 3rd and 4th building will show LOD0, 2nd and 5th will show LOD1, 1st and 6th will show LOD2. Then for that frame after enabling LODs, your tool will bake the Mesh. This baked mesh will have far low verts count because it does include LOD0, LOD1, LOD2 depending on distance from player car.

    Case 2. Car moves ahead and now is in between building number 4 and building 9. Now building 1 to 3 are out of view. Now building number 4 shows LOD2 (previously it was showing LOD0). Building 5 shows LOD1 same as previous. Building 6 now shows LOD0 previously it was showing LOD2. Building 7 to 9 are also being rendered now and they also showing their respective LODs. Once these LODs are set, your tool will discard previous mesh and will bake this new mesh. Previously building 4 to 6 were combined with building 1 to 3 but now building 4 to 6 are combined with building 7 to 9. But the batch count is still 1 as before and verts counts are still low because instead of baking LOD0 from all buildings, LODs are being changed at run time and them result is combined. This will keep draw calls low as well as verts count. This all is achieved even WITHOUT turning static batching ON hence no increase in build size.

    Am I all getting it right? Thanks.

    1) No need to use static batching when using your this tool. Am I right?

    2) Can the scenarios explained above be achieved using Regular Mesh Baker?

    3) Does run time mesh baker baking takes less time than rending more draw calls and more verts? Because if run time baking overhead is lesser than original rendering time only then this tool is useful. Also can I go like this, bake combined materials before hand and only bake LODs during run time?

    4) Does this tool also works with Texture Arrays? I mean instead of baking combined materials before hand, I can prepare a texture array before hand and then Mesh baker LOD can do its mesh baking work at run time. Is it possible?
     

    Attached Files:

    Last edited: Mar 6, 2021
  34. WaqasGameDev

    WaqasGameDev

    Joined:
    Apr 17, 2020
    Posts:
    118
    Hi, kindly respond before the sale on Mesh Baker LOD ends. :) Thanks.
     
  35. WaqasGameDev

    WaqasGameDev

    Joined:
    Apr 17, 2020
    Posts:
    118
    I just bought the Mesh Baker LOD. But still I would be happy if you can respond to my email and my above comment. Thanks. :)
     
  36. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Sorry for not responding earlier. I was away from the office yesterday.

    Regarding your questions:

    1) You are correct, you do not need to use static batching.
    2) The scenario you describe could not be achieved with regular Mesh Baker. You do a lot of scripting (essentially writing a system similar to Mesh Baker LOD).
    3) Mesh Baker LOD time can be an issue. Typically the render time is significantly lower, but the bake time can cause lag spikes. Typically the LODs do not get baked every frame. Often (if the player is in one location) many frames can go by without a bake. if the combined meshes are large then the bake time can be enough for a frame drop. I would suggest keeping the combined meshes less than 20k to avoid lag spikes.
    4) Yes the tool will work with Texture Arrays. The texture arrays must be created in the editor. It is not possible to create them at runtime.

    Regarding static batching:

    Unity includes a StaticBatchingUtility in the API. You can ship your game level without static batching and create the batches when your level loads.
     
  37. Hobodi

    Hobodi

    Joined:
    Dec 30, 2017
    Posts:
    101

    Hi Ian! I am thinking of purchasing this asset in addition to the baker, but I doubt the performance on mobile phones.
    Could you compile the apk with some city scene where I can turn off and turn on mb_lod to test it please ?
     
  38. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,085
    Hi Hobodi,

    I am very busy at the moment and don't have time to set this up. If you try it and it does not work for you, I will issue you a refund.