Search Unity

  1. New Unity Live Help updates. Check them out here!

    Dismiss Notice

Poly Few | Mesh Simplifier and Automatic LOD Generator

Discussion in 'Assets and Asset Store' started by Xy-aaBLa, Jan 18, 2020.

  1. Xy-aaBLa

    Xy-aaBLa

    Joined:
    Jan 21, 2017
    Posts:
    14
    Hello everyone!

    I am happy to announce my new asset "PolyFew" for mesh simplification and automatic LOD generation.

    Added Runtime API in version 1.3 with support for various runtime operations. A demo scene is included to demonstrate most of the features of the API. See the docs linked below.

    Try out the demo

    Read the API Docs


    Supported features:

    Mesh simplification and automatic LOD generation in one package.

    Supports mesh simplification on the fly with a powerful runtime API.

    ▓ No coding knowledge is required. Use the full features of the tool in editor mode without writing even a single line of code.

    Supports simplifying both skinned and static meshes as well as meshes with 16 bit and 32 bit index formats.

    Supports simplifying complex nested object hierarchies as well as objects with sub-meshes and multiple materials.

    Combine both Static and Skinned meshes during LOD generation.

    Preserves texture mappings.

    Preserves animations on meshes. Even supports blend shapes.

    Options to preserve UV Seams, UV Foldovers and Border Edges.

    Allows excluding certain areas of the mesh while simplifying the rest.

    Supports animated meshes.

    Packs everything in a convenient inspector window that pops up right under the components hierarchy.

    Visualize the changes before actually applying them.

    Undo / Redo the applied changes per object.

    All the source code is included without encapsulation using dll files or any other means.

    Includes editor tooltips for every control to ease understanding and usage of the tool.

    Check out the video:



    Screenshots:











    Check out some of my other assets:

    - Pivot Modder : Freely move or rotate pivot point of an object by a few clicks.
    - Android Ultimate TTS: A full featured Text To Speech solution for you android apps.
    - Easy Snap : Place objects with accuracy and speed. With this tool you can snap objects to other objects.
     
    Last edited: Mar 19, 2020
    Teila and Peter77 like this.
  2. Teila

    Teila

    Joined:
    Jan 13, 2013
    Posts:
    6,816
    This looks great!! I put it on my list for later. Thank you!
     
    Xy-aaBLa likes this.
  3. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    5,960
    nice!
    - does this support 32bit index meshes?
    - batch processing multiple meshes (or whole folder)?
    - runtime version?
     
  4. Xy-aaBLa

    Xy-aaBLa

    Joined:
    Jan 21, 2017
    Posts:
    14
    - Yes, PolyFew supports both 16-bit mesh index buffers as well as 32 bit buffers (32-bit mesh indexing format).
    - I am not sure if I quite get this but if you meant simplifying nested object hierarchies (Objects with a lot of child meshes) as a whole, then yes it does support that. The reduce deep option is meant for that.
    - Currently PolyFew cannot be used at runtime. Why would you need it anyways?. If a runtime version be made then what operations would you require be ported:

    a) Just mesh simplification with complete options.
    b) Mesh simplification and LOD generation.

    EDIT: Runtime API has been added in version 1.3 (Read the API docs linked at the start of the article) with support for various runtime operations including but not limited to:

    ►Simplify 3d models.
    ►Simplify mesh arrays.
    ►Importing OBJ files on the fly(Both locally and from a server with textures and materials).
    ►Exporting OBJ files on the fly to local file system with textures and materials support.

    ►Optimal heuristic based simplification.
     
    Last edited: Feb 25, 2020
  5. Xy-aaBLa

    Xy-aaBLa

    Joined:
    Jan 21, 2017
    Posts:
    14
    Thank you for checking it out. If you have any queries feel free to write them here or email me @kbawar555@gmail.com
     
  6. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    5,960
    1) If i have folder with 100 meshes, so i could do optimize all of them, either selecting that folder (or those files) in Project window, or drop them all into scene (separate gameobjects, not one hierarchy) and optimize all selected?

    2) For example at runtime the application allows OBJ import at runtime, then could optimize that mesh, from script as in PolyFew.Optimize(targetTransform);
     
  7. Xy-aaBLa

    Xy-aaBLa

    Joined:
    Jan 21, 2017
    Posts:
    14
    Well that's not supported. The process of mesh simplification is such that there are no common settings that work best for every single mesh, for example if I have 100 different meshes and I choose to reduce all of them by 70% and also select to preserve UV Seams, UV borders etc, then it might happen to be the case that out of 100 meshes only 30 got the settings suited to them and are optimized nicely without distortion and major changes in the look, this effort wasted processing on the 70 other meshes that look awful now. You can't find a global optimum for every single mesh. Even if you find some good settings to work for them all, it might not be the best for every single mesh, so for example you could've optimized some meshes more.

    Runtime operations are not supported as of now.

    Thank you for all the suggestions, I'll definitely plan them for a near future release. :)

    EDIT: Runtime API has been added in version 1.3 (Read the API docs linked at the start of the article) with support for various runtime operations including but not limited to:

    ►Simplify 3d models.

    ►Simplify mesh arrays.
    ►Importing OBJ files on the fly(Both locally and from a server with textures and materials).
    ►Exporting OBJ files on the fly to local file system with textures and materials support.

    ►Optimal heuristic based simplification.
     
    Last edited: Feb 25, 2020
    mgear likes this.
  8. ina

    ina

    Joined:
    Nov 15, 2010
    Posts:
    852
    Does this also generate low poly faceted meshes?
     
  9. Xy-aaBLa

    Xy-aaBLa

    Joined:
    Jan 21, 2017
    Posts:
    14
    Hi Ina!. Unfortunately that won't be possible with Poly Few at least not accurately. When it simplifies a model it doesn't care about whether simplification would result in a low poly stylized version of the model or not
     
    Last edited: Mar 19, 2020
  10. jcbhmmn

    jcbhmmn

    Joined:
    Oct 4, 2014
    Posts:
    18
    Hi, Is there a way to simplify a mesh and then bake the result? (As opposed to maintaining the original mesh in the file). My scene file becomes huge when I reduce all of the meshes in my project.
     
  11. Xy-aaBLa

    Xy-aaBLa

    Joined:
    Jan 21, 2017
    Posts:
    14
    Hi, Unfortunately that won't be possible. I know that it sucks to keep extra meshes but there is no other way. The original mesh(es) come with the imported model file (obj, fbx, c4d, cad etc). Because Unity doesn't allow you to modify the imported model files, we can't modify the properties(vertices, triangles, UVs etc) of mesh(es) represented in the model file as well.
     
    jcbhmmn likes this.
  12. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    4,642
    There should be no reason to store simplified meshes in the scene. You can save the simplified mesh as asset in the project:
    Code (CSharp):
    1. AssetDatabase.CreateAsset(simplifiedMesh, "Assets/SimplifiedMesh.asset");
    https://docs.unity3d.com/ScriptReference/AssetDatabase.CreateAsset.html

    This will not overwrite the .fbx file, but it stores the mesh in the project as an asset file. If you create a prefab of the .fbx file, you can then replace the mesh reference with the simplified mesh asset.
     
  13. Xy-aaBLa

    Xy-aaBLa

    Joined:
    Jan 21, 2017
    Posts:
    14
    The OP was actually referring to not saving the modified mesh at all and somehow get it to bake in the model file itself. Poly Few doesn't save the modified meshes just for a single scene. It actually saves it in the project as you mentioned using
    Code (CSharp):
    1.  AssetDatabase.CreateAsset(simplifiedMesh, "Assets/SimplifiedMesh.asset");
    Then these simplified meshes can be reused in any scene by just changing the mesh references in the prefabs (Mesh filters or Skinned Mesh Renderers)
     
    Peter77 likes this.
  14. ge01f

    ge01f

    Joined:
    Nov 28, 2014
    Posts:
    56
    Are you planning on adding Asset Database V2? I converted to V1 for now, but it would be good to not be on a deprecated ADB going forward.
     
  15. Xy-aaBLa

    Xy-aaBLa

    Joined:
    Jan 21, 2017
    Posts:
    14
    I have plans on adding ADB V2 support in the next update, however the ADB V2 is still not stable and there lacks a good amount of documentation for it. I can confirm that there is nothing that Poly Few does with ADB V1 that ADB V2 can do in a better way, but moving forward it is of utmost importance to me to add support for ADB V2 or any other changes that Unity makes in their core engine APIs
     
    Last edited: Mar 26, 2020
  16. ge01f

    ge01f

    Joined:
    Nov 28, 2014
    Posts:
    56
    Cool, thanks. I got it working in 2019.3 with ADB v1.

    One more question, I think this tool can also "Combine Mesh", but I dont see how to do that explicitly.

    I'd like to take a bunch of sub-items, make them 1 item, then apply LOD to that. Is there instructions to do that? I thought watching the video it said you could, but rewatching I cant see how, and dont see them in the doc sheet.

    Also, is there a way to save the values? Each time I edit another item, I have to go set all the same Reduction Options and the additional layer. Doing this over and over again takes a long time, especially waiting for all the LOD gen in between.

    Also, as a feature request, it would be good to be able to process a bunch of Prefabs in the Project dirs too. I basically want to make all my prefabs have LODs on them, but I have to go and drag them into a scene, set up each one, then update the prefab. Having some automation workflow would be great. Looking at the C# API its not immediately apparent how I would do that.

    I see SimplifyObjectDeep, which takes the parameters, but not where to add the levels for LOD. So Im thinking thats not LOD. Not sure which methods do the LOD.
     
    Last edited: Mar 26, 2020
  17. Xy-aaBLa

    Xy-aaBLa

    Joined:
    Jan 21, 2017
    Posts:
    14
    Unfortunately for now you can't combine meshes explicitly. But you can achieve your use case easily i-e combine meshes and generate LODs. Follow these simple steps:
    1> Create an empty GameObject just to act as a root of the objects whose meshes you want to combine.
    2> Now parent the newly created empty GameObject to the objects you want to combine. For example if you want to combine the meshes of object a, b and c then make all of these three objects children of the created empty GameObject.
    3> Now click the empty GameObject and generate LOD's for that object, mark the combine meshes option against each LOD level and change other settings as required.
    4> Finally press the generate LODS button. Now the meshes of the objects will be combined into one as well as have LODs setup (or more depending on if the meshes had blendshapes). You can verify this by checking out the hierarchy of the Empty parent GameObject you created.

    About saving settings for GameObject (Like reduction options, strength etc). There is currently no way to do this. But why would you want to save the settings anyways?. The way the tool was designed is that it assumes you would select an object, tweak some reduction options and either reduce the object or generate LODS for it and then you would move on to other objects individually and doing the same thing. Anyways i'll keep this is mind and will queue this to a future release.

    Plese do let me know if you face any problems while following the steps above, i'll be more than happy to help you out, and btw some good news is that iI'll be releasing a new update within this week that will add compatibility of Asset Database V2 and might as well add the feature you need (Remembering the reduction settings for individual objects)
     
  18. ge01f

    ge01f

    Joined:
    Nov 28, 2014
    Posts:
    56
    On #3 I dont see a "Combien Meshes" option.

    Where would it be? Screenshot attached.

    This will make a single mesh? I want to make it 1 draw call, which is why I want to combine them.

    Another future nice option would be texture atlasing as part of the combine.

    About saving the items, I have 1000s of items I need LODs for. Im not going to individually tweak them all, especially in the beginning. A standard setup is way better than not having any LODs. Im happy I can adjust them as needed, but I have a project with like 50,000 assets in it. I cant do that by hand, I need a way to mass run them. Then I can tweak by hand if needed.

    Thanks for the quick replies!

    BTW, do you have a way to use the C# to create LODs? I can make the auto-do-all-my-assets-how-I-want as long as I know which method to call, but I dont see the one for LOD, only simplify and combine.
     

    Attached Files:

    • lod.png
      lod.png
      File size:
      22.8 KB
      Views:
      10
  19. Xy-aaBLa

    Xy-aaBLa

    Joined:
    Jan 21, 2017
    Posts:
    14
    It seems like you have an older version of the product, please update it. Go to the asset store and download the newer version.

    And yes the combine meshes will combine all StaticMeshRenderers (MeshFilters) into one mesh and then it will take all meshes using SkinnedMeshRenderers(Without blend shapes) and combine them into one. Meshes with blend shapes are not combined at all, this is a limitation. However, blendshapes are not commonly so you might not encounter such a case.

    Also you can generate LODs for multiple objects but that would require some coding skills. The reason why this wasn't included as an out of the box feature was that because it's almost possible that common reduction settings do not work out for every different kind of model thus ruining everything. LOD generation should be carried out individually for your objects
     
    Last edited: Mar 26, 2020
  20. ge01f

    ge01f

    Joined:
    Nov 28, 2014
    Posts:
    56
    Yeah, I definitely need to do them all with the same parameters. For better or worse, I just need less tris in scene, and there are too many objects.

    Every object takes like 18 interactions (selecting options, adding option), and then waiting a few minutes, and like I said I have like 50,000 of them. I cant do all that by hand, or tweak them individually to start. But I need them to have LOD for perf.

    Im fine with doing the coding, what are the basic steps to add LOD?
     
  21. Xy-aaBLa

    Xy-aaBLa

    Joined:
    Jan 21, 2017
    Posts:
    14
    Can you please give me some time, I'll write an editor script for you to serve your purpose. You'll just need to attach that script to an empty gameobject and specify the common LOD generation settings in the script through the inspector and then make sure that only the objects that you want the LODs for are present in the scene. You will then just need to check a toggle or press a button on the script and it will iterate over all your objects and generate LODs for them with the same settings. I'll send you the script by today and if you don't mind me saying can you please get in touch through email?, I don't want to clutter the thread with a lot of posts.

    Thank you
     
    Last edited: Mar 26, 2020
  22. ge01f

    ge01f

    Joined:
    Nov 28, 2014
    Posts:
    56
    My Asset importer says I am on the latest version. Is there an incompatibility/feature-flag with the "Combine Meshes" option and 2019.3? Because Im not seeing the option, but there isnt an update to download.

    Sending an email for the script stuff.

    EDIT: I got all my questions answered. Everything works great, and Bawar implemented Asset Database V2 and added a new feature to mass-select and operate. Really happy with the support!
     
    Last edited: Mar 27, 2020
  23. Xy-aaBLa

    Xy-aaBLa

    Joined:
    Jan 21, 2017
    Posts:
    14
    I've pushed out a new update that adds the following new options:

    Support for Asset Database V2 and the newer Asset PipeLine V2
    Support for multi selecting objects and generating LODs for multiple selected objects at once.
     
    Last edited: Mar 27, 2020
unityunity