Search Unity

Mantis LOD Editor Support

Discussion in 'Formats & External Tools' started by meshonline, Feb 10, 2014.

  1. amynox

    amynox

    Joined:
    Oct 23, 2016
    Posts:
    178
    Sure. My question was related to the progressive LOD generation on runtime and if that can work with GPUI ?
     
  2. meshonline

    meshonline

    Joined:
    Feb 7, 2014
    Posts:
    121
    I am not sure how GPUI works, the progressive LOD generation will generate static LODs on the fly since v6.0, in my test, they can benefit from GPU instances.
     
  3. Bolax

    Bolax

    Joined:
    Apr 30, 2015
    Posts:
    5
    Being unhappy with the LOD models I have, I decided to utilize this plugin in the hopes of a smoother transition from distance to close rendering. I'm working on a VR project. Now I haven't messed with this plugin too much yet, I bought it a bit ago, but looking through the reviews someone posted that it doesn't work with VR projects. Is that true? I can't imagine how, unless it just has to do with the render pipeline and if that's the case, can you list which pipelines are supported? Universal would be great, or standard... But... Anyway just wanted to ask this before I invest too much time.
     
  4. meshonline

    meshonline

    Joined:
    Feb 7, 2014
    Posts:
    121
    Sorry, I have not tested the plugin with VR before, this reminds me to buy a VR device to see what the issue is, but if you only use the standard feature of this add-on, make LOD manually and save as assets, and use the LODs in the built-in LOD system, I guess that it should work.
    https://forum.unity.com/threads/lodgroup-in-vr.455394/
     
    Last edited: May 15, 2021
  5. meshonline

    meshonline

    Joined:
    Feb 7, 2014
    Posts:
    121
    It seems no problem with a simple VR test, I open the demo scene of 'Mantis LOD Editor - Professional Edition', then from GameObject->XR->Convert Main Camera to XR Rig, because XRRig becomes the parent of the main camera, I delete the 'moveme.cs' from the main camera, and add the 'moveme.cs' to the XRRig, the script will move the XRRig back and forth repleatly, then I hit the play button, the progressive mesh works as expected.
    aaa.jpg
     
  6. JauntyBearGames

    JauntyBearGames

    Joined:
    Mar 26, 2018
    Posts:
    57
    i've added a mantis pro script to a mesh game object, when sliding the quality nothing happens, I would expect the number of vertices to reduce according to the doc. what should I check?
    I'm using 2020.3 LTS
    Thanks
     
  7. meshonline

    meshonline

    Joined:
    Feb 7, 2014
    Posts:
    121
    Please add a built-in sphere to the scene, then add a mantis for script to the sphere, drag the quality slider to see if the plugin works properly. If it works, try your mesh game object, see if there are any error messages.
     
  8. JauntyBearGames

    JauntyBearGames

    Joined:
    Mar 26, 2018
    Posts:
    57
    Thanks, actually I've just re-installed the module and works fine now
     
  9. Zuuunk

    Zuuunk

    Joined:
    Jul 28, 2021
    Posts:
    11
    I'm using the command line utility which is working great. Do you have a suggestion for finding the starting number of triangles in my input model? I'm building a pipeline for custom UGC so I don't know this number upfront. I need it in order to know whether generating an LOD at a particular triangle count is necessary at all - and I'd rather use the absolute triangle counts rather than a percentage.

    Thanks!
     
  10. meshonline

    meshonline

    Joined:
    Feb 7, 2014
    Posts:
    121
    If you run the command-line utility without any parameters, it will show the usage.
    For example:
    ./mle -t 1500 -i abc.fbx -o abc2.fbx
    Which 1500 is the desired triangles count.
     
  11. Zuuunk

    Zuuunk

    Joined:
    Jul 28, 2021
    Posts:
    11
    Thanks, I understand how to set the desired count. I'm wondering if there is a recommended way to find the original count before reduction.

    Since setting the triangle count via a percentage parameter is possible, I know the capability is there, but there is no command for it.
     
  12. moltke

    moltke

    Joined:
    Apr 28, 2019
    Posts:
    109
    Hi I am having this error with the progressive mesh, it works the first time, but when i back away from the monster and then move back it stops working correctly

     
  13. tomobiki

    tomobiki

    Joined:
    Sep 27, 2020
    Posts:
    65
    Hi, I'm applying the LOD editor to a human character I imported from a vrm model. It works fine, but I have a problem attaching an object to one of its legs. So my doubt is if when I create the different LODs with the editor it affects also the bones quantity or the properties of the bones.
    Thanks.
     
  14. meshonline

    meshonline

    Joined:
    Feb 7, 2014
    Posts:
    121
    If you apply the LOD editor at the top level, it will apply to all hierarchies, including the object attached to the leg.
    To use different LODs, you need to apply the LOD editor to the proper levels for meshes, for example, the character, and the attachment, which you can adjust the runtime parameters independently.
     
  15. Saiko468

    Saiko468

    Joined:
    Nov 12, 2021
    Posts:
    3
    Does anyone else have an issue uploading mesh data? Whenever I try to do so, either with the free version or with the paid version, I get the error - Error with network: HTTP/1.1 404 Not Found. Is the server that handles the data down as of right now? 11/11/2021.
     
  16. meshonline

    meshonline

    Joined:
    Feb 7, 2014
    Posts:
    121
    Yes, the free online version had retired, the server is down.
     
  17. Saiko468

    Saiko468

    Joined:
    Nov 12, 2021
    Posts:
    3
    Does that also apply to the paid version as well? I get the HTTP error when trying to upload data using the professional version and cannot use the editor at all due to the HTTP 404 error.
     
  18. meshonline

    meshonline

    Joined:
    Feb 7, 2014
    Posts:
    121
    The paid version does not upload any data to Internet, it always works natively. Maybe you forget to remove the old online version? Please delete the MantisLODEditor directory in Assets, then install the professional version again.
     
  19. Taratus

    Taratus

    Joined:
    Sep 8, 2020
    Posts:
    8
    Hi, I want to use the progressive mesh runtime, but the polygon reduction is not starting at the right distance to the camera. The reductions take place too late for my purposes. How can I specify at which distance reduction is starting? There is only the option to set the cull distance and the other distances depend on this.

    Would there be a more detailed progressive mesh runtime version where to set these options?
     
  20. meshonline

    meshonline

    Joined:
    Feb 7, 2014
    Posts:
    121
    Please adjust the 'Disappear Distance' value, try setting it to a smaller value, it should work.
     
  21. KingfisherWyvernStudio

    KingfisherWyvernStudio

    Joined:
    Oct 5, 2011
    Posts:
    324
    Hi,

    Does Mantis LOD work with all pipelines? I noticed there are LOD tools that only work with the built-in pipeline, hence the question :)

    Thanks for the help!
     
  22. meshonline

    meshonline

    Joined:
    Feb 7, 2014
    Posts:
    121
    Mantis LOD works in two modes: Built-in Unity LOD mode and the own runtime mode, if you use the first mode, it can work with many pipelines, for example, work together with Amp Impostor. Both modes can work in URP and HDRP mode.
     
  23. KingfisherWyvernStudio

    KingfisherWyvernStudio

    Joined:
    Oct 5, 2011
    Posts:
    324
    If I understand you correctly, with the Built-in Unity LOD mode, I can use Mantis LOD with the Built-in Render pipeline, URP and HDRP.
    And Mantis LOD works with many tools.
    The own runtime mode, is that the mode in-game where it automatically adjusts? And that is also available in all three render pipelines?

    Thanks again!
     
  24. meshonline

    meshonline

    Joined:
    Feb 7, 2014
    Posts:
    121
    Yes, you are right.
     
  25. KingfisherWyvernStudio

    KingfisherWyvernStudio

    Joined:
    Oct 5, 2011
    Posts:
    324
    Perfect! Thanks :)
     
  26. KingfisherWyvernStudio

    KingfisherWyvernStudio

    Joined:
    Oct 5, 2011
    Posts:
    324
    Are we allowed to gift/sell assets with the runtime option included?
     
  27. Saiko468

    Saiko468

    Joined:
    Nov 12, 2021
    Posts:
    3
    Thanks, that seems to have fixed the issue. I must have forgotten to remove the old before importing the new one lol
     
  28. Michal_Stangel

    Michal_Stangel

    Joined:
    Apr 17, 2017
    Posts:
    151
    Hello,
    I try to solve the same problem with Mantis LOD as discribed below. I want to use my editor script to add Mantis component on prefab(s) and generate meshes from code. Because I need to create LODS for like 1000 prefabs and doing it manually would take ages.

    First I add MantisLODEditorProfessional component on prefab:
    Code (CSharp):
    1. MantisLODEditorProfessional mantisLODcomponent = instantiatedGameObject.AddComponent(typeof(MantisLODEditorProfessional)) as MantisLODEditorProfessional;
    In InnerMantisLODEditorProfessional I moved code from "Save Current Mesh" button to the new public method SaveCurrentMesh().
    But I really struggle to find out how to access InnerMantisLODEditorProfessional to call this SaveCurrentMesh() as I only have reference to MantisLODEditorProfessional after adding the component.


     
  29. Strogman

    Strogman

    Joined:
    May 6, 2020
    Posts:
    5
    I just happen to have the exact same problem as Michal_Stangel. I'll be writing a custom piece of code based on Inner...cs. I would hope that you release a more modular public-facing c# code with CreateMantisMesh() and SaveMantisMesh() functions, to make it easier to script Mantis in the editor. I sent you an email about it.
     
  30. wholebitmedia7

    wholebitmedia7

    Joined:
    Mar 8, 2018
    Posts:
    8
    When batching how do you set the quality?
     
  31. mkhbmg

    mkhbmg

    Joined:
    May 10, 2021
    Posts:
    5
    Did anyone find a solution to set quality from script?
     
  32. grofie

    grofie

    Joined:
    Dec 9, 2013
    Posts:
    30
    You can set the quality with MantisLODEditorUtility.SetQuality.
    I am using this piece of code to reduce a mesh at runtime. Maybe it is of help for your.

    Code (CSharp):
    1.  
    2. private Mesh ReduceMesh(Mesh original)
    3. {
    4.    Mantis_Mesh[] Mantis_Meshes = new Mantis_Mesh[1];
    5.  
    6.    Mantis_Meshes[0] = new Mantis_Mesh();
    7.    Mantis_Meshes[0].mesh = original;
    8.  
    9.    MantisLODEditorUtility.PrepareSimplify(Mantis_Meshes, false);
    10.  
    11.    MantisLODEditorUtility.Simplify(Mantis_Meshes, _protectBoundary, _protectDetail, _protectSymmetry, _protectNormal, _protectShape, _useDetailMap, _detailBoost);
    12.  
    13.    MantisLODEditorUtility.SetQuality(Mantis_Meshes, SettingsManager.PropsQuality * 100f);
    14.  
    15.    Mesh mesh = Mantis_Meshes[0].mesh;
    16.  
    17.    MantisLODEditorUtility.FinishSimplify(Mantis_Meshes, false, false);
    18.  
    19.    return mesh;
    20. }
    21.  
     
    schmosef likes this.
  33. CWatsonT2

    CWatsonT2

    Joined:
    Jan 9, 2019
    Posts:
    114
    I am using the "Progressive Mesh Runtime" on a prefab. I have several of that prefab in my scene. If I deactivate one of the prefabs it causes the remaining prefabs to go to LOD 0. Is there a way to fix this? I really need to have multiple of them in one scene.
     
  34. meshonline

    meshonline

    Joined:
    Feb 7, 2014
    Posts:
    121
    You can try adding an independent runtime script to each prefab to see if it works.
     
  35. CWatsonT2

    CWatsonT2

    Joined:
    Jan 9, 2019
    Posts:
    114
    That didn't help. But I found out it happens because both prefabs are using the same progressive mesh you create using the "Mantis LOD Editor Professional" script. If I duplicate the progressive mesh and assign it to one of the prefabs this issue doesn't happen anymore. However that isn't a solution for me. There are going to be so many duplicates it would be really hard to ensure they are all using different progressive meshes. And each time I duplicate a progressive mesh it adds 1.6MB. Any more thoughts on how else to fix this?
     
  36. meshonline

    meshonline

    Joined:
    Feb 7, 2014
    Posts:
    121
    I'll look into it and see if I can fix the issue quickly.
     
  37. meshonline

    meshonline

    Joined:
    Feb 7, 2014
    Posts:
    121
    I tested multiple instances of the same prefab, if I only disabled the renderers of the game object, not the game object itself, it works.
    Like this:
    Code (CSharp):
    1. allBasicRenderers = (Component[])(gameObject.GetComponentsInChildren(typeof(Renderer)));
    2. foreach (Component child in allBasicRenderers)
    3. {
    4.     ((Renderer)child).enabled = false;
    5. }
    6.  
     
  38. Michal_Stangel

    Michal_Stangel

    Joined:
    Apr 17, 2017
    Posts:
    151
    If anybody struggles how to automate workflow in editor, here is how:

    Code (CSharp):
    1.  
    2.  
    3.         /// <summary>
    4.         /// CREATE ALL LOD MESHES
    5.         /// </summary>
    6.         /// <param name="instantiatedGameObject"></param>
    7.         private static void CreateAllLODMeshes(GameObject instantiatedGameObject, ACore_PrefabRecipe prefabRecipe)
    8.         {
    9.             // Remove Mantis LOD component if there is still one
    10.             Component[] mantisLODcomponents = instantiatedGameObject.GetComponentsInChildren<MantisLODEditorProfessional>();
    11.             foreach (Component mantisLODcomponent_Current in mantisLODcomponents)
    12.             {
    13.                 DestroyImmediate(mantisLODcomponent_Current, true);
    14.             }
    15.             // Add Mantis LOD component
    16.             MantisLODEditorProfessional mantisLODcomponent = instantiatedGameObject.AddComponent(typeof(MantisLODEditorProfessional)) as MantisLODEditorProfessional;
    17.             InnerMantisLODEditorProfessional innerEditor = (InnerMantisLODEditorProfessional)Editor.CreateEditor(mantisLODcomponent);
    18.             int quality_LOD1 = 70;
    19.             int quality_LOD2 = 40;
    20.             int quality_LOD3 = 10;
    21.             bool protectBoundaries_LOD1 = true;
    22.             bool protectBoundaries_LOD2 = true;
    23.             bool protectBoundaries_LOD3 = true;
    24.             // Mesh 100 quality
    25.             innerEditor.SaveCurrentMesh();
    26.             innerEditor.SaveCurrentMesh(qualityToSet: quality_LOD1, protectBoundaries: protectBoundaries_LOD1);
    27.             innerEditor.SaveCurrentMesh(qualityToSet: quality_LOD2, protectBoundaries: protectBoundaries_LOD2);
    28.             innerEditor.SaveCurrentMesh(qualityToSet: quality_LOD3, protectBoundaries: protectBoundaries_LOD3);
    29.             innerEditor.ResetFBXMesh();
    30.         }
    31.      
    32.  
    To get a reference to instance of InnerMantisLODEditorProfessional script is the part I was unable to do. But lengthy discussion with ChatGPT helped a "little" :)

    It's also important to modify InnerMantisLODEditorProfessional script and create there some public method(s) you can call. Just remove code from this condition to standalone method:

    Code (CSharp):
    1.  
    2.  
    3.                         // save current mesh as a lod asset file
    4.                         if (GUILayout.Button("Save Current Mesh", GUILayout.ExpandWidth(true), GUILayout.ExpandWidth(true)))
    5.                         {
    6.                             SaveCurrentMesh(calledManually: true);
    7.                         }
    8.  
    9.  
    If somebody is interested, this is what I added into InnerMantisLODEditorProfessional. So CreateAllLODMeshes method creates all LODs and store them in LODS folder in active folde (visible in Project window). Folder is created if not there yet:

    Code (CSharp):
    1.  
    2.  
    3.         /// <summary>
    4.         /// CREATES NEW FOLDER
    5.         /// </summary>
    6.         /// <returns></returns>
    7.         public string CreateFolder(string parentFolder, string newFolder)
    8.         {
    9.             string existingFolder = parentFolder + "/" + newFolder;
    10.             if (AssetDatabase.IsValidFolder(existingFolder))
    11.                 return existingFolder; // Already exists
    12.             string guid = AssetDatabase.CreateFolder(parentFolder, newFolder);
    13.             string newFolderPath = AssetDatabase.GUIDToAssetPath(guid);
    14.             return newFolderPath;
    15.         }
    16.         /// <summary>
    17.         /// RETURNS FOLDER WHICH IS ACTIVE IN PROJECT WINDOW
    18.         /// </summary>
    19.         /// <returns></returns>
    20.         public string GetActiveFolderInProjectWindow()
    21.         {
    22.             Type projectWindowUtilType = typeof(ProjectWindowUtil);
    23.             MethodInfo getActiveFolderPath = projectWindowUtilType.GetMethod("GetActiveFolderPath", BindingFlags.Static | BindingFlags.NonPublic);
    24.             object obj = getActiveFolderPath.Invoke(null, new object[0]);
    25.             string pathToCurrentFolder = obj.ToString();
    26.             return pathToCurrentFolder;
    27.         }
    28.         /// <summary>
    29.         /// SAVE CURRENT MESH
    30.         /// </summary>
    31.         public void SaveCurrentMesh(bool calledManually = false, int qualityToSet = 100, bool protectBoundaries = true)
    32.         {
    33.             if (calledManually == true)
    34.             {
    35.                 if (!optimized)
    36.                 {
    37.                     optimize();
    38.                     optimized = true;
    39.                 }
    40.             }
    41.             else
    42.             {
    43.                 quality = 100.0f;
    44.                 // delete old progressive mesh
    45.                 clean_all();
    46.                 init_all();
    47.                 // create new progressive mesh
    48.                 optimize();
    49.                 optimized = true;
    50.                 save_protect_boundary = protectBoundaries;
    51.                 protect_boundary = protectBoundaries;
    52.                 face_number = MantisLODEditorUtility.SetQuality(Mantis_Meshes, qualityToSet);
    53.                 EditorUtility.SetDirty(target);
    54.                 save_quality = qualityToSet;
    55.                 quality = qualityToSet;
    56.             }
    57.             foreach (Mantis_Mesh child in Mantis_Meshes)
    58.             {
    59.                 // clone the mesh
    60.                 Mesh new_mesh = (Mesh)Instantiate(child.mesh);
    61.                 MeshUtility.Optimize(new_mesh);
    62.                 string filePath = GetActiveFolderInProjectWindow(); // Get path active in Project window
    63.                 filePath = CreateFolder(filePath, "LODS"); // Create subfolder for LODS
    64.                 string fileName = new_mesh.name + "_Quality_" + quality.ToString() + ".asset"; // File name      
    65.                 Regex illegalInFileName = new Regex(@"[\\/:*?""<>|]"); // Characters not allowed in Windows in file name
    66.                 fileName = illegalInFileName.Replace(fileName, "");
    67.                 filePath += "/" + fileName;
    68.                 Log.L("filePath: " + filePath + ", quality: " + quality + ", protect_boundary: " + protect_boundary, Log.Type.Color_Yellow);
    69.                 if (filePath != "")
    70.                 {
    71.                     AssetDatabase.CreateAsset(new_mesh, filePath);
    72.                     AssetDatabase.SaveAssets();
    73.                     AssetDatabase.Refresh();
    74.                 }
    75.             }
    76.         }
    77.         /// <summary>
    78.         /// RESET QUALITY
    79.         /// </summary>
    80.         public void ResetFBXMesh()
    81.         {
    82.             quality = 100.0f;
    83.             save_quality = 100.0f;
    84.             // delete old progressive mesh
    85.             clean_all();
    86.             init_all();
    87.             // create new progressive mesh
    88.             optimize();
    89.             optimized = true;
    90.             save_protect_boundary = true;
    91.             protect_boundary = true;
    92.             face_number = MantisLODEditorUtility.SetQuality(Mantis_Meshes, quality);
    93.             EditorUtility.SetDirty(target);
    94.         }
    95.  
    96.  
     
    Last edited: Feb 4, 2023
    hopeful likes this.
  39. MadHawaiian

    MadHawaiian

    Joined:
    Feb 28, 2023
    Posts:
    1
    when I try to upload mesh, I get this message,"HTTP/1.1 404 Not Found" can anybody help?
     
  40. Justcloud

    Justcloud

    Joined:
    Oct 8, 2012
    Posts:
    3
    having the same issue but can't find that "Disappear Distance" to adjust, any suggest about that?