Search Unity

[V1.4.1 Released] Advanced Merger Toolkit - Boost Performance | Easy & Powerful Workflow

Discussion in 'Assets and Asset Store' started by eskovas, Nov 2, 2018.

  1. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,344
    Hello,
    I also saw that algorithm awhile back when searching for a better packing algorithm, but it wasn't a very high priority at the time and since i was able to improve Unity's a bit, i didn't implement a better one. I do have plans to implement a better one at some time in the future.

    I also had that idea about scaling each material for the atlas, but it didn't work well with Unity's packing algorithm for some reason, so i didn't pursue that much more. When i implement the better algorithm, i'll see if i can also add that.
     
  2. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,344
    New Tutorial video for Advanced Merger Toolkit!
    This time i show how to use the Material Merger to improve the performance of your games in a fast and easy way!

     
  3. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,344
    New tutorial Part 4 - how to use the Material Bake feature:


    New hotfix update is also available as of today that fixes an issue where the tool wasn't finding every Renderer in the GameObject list of the Bake feature.
     
  4. McDev02

    McDev02

    Joined:
    Nov 22, 2010
    Posts:
    636
    What I would need is that the merger preserves Scale in Lightmap and potentially also some other values of a mesh renderer. It could be done by using the average or min/max of all the meshes. Meanwhile I try to add it myself.
    Apart from that, nice tool :)
     
    Last edited: Aug 23, 2019
  5. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,344
    Thanks :)

    Well, the tool does preserve lightmaps for the merged meshes (UV2 UVs in merged meshes are translated to the original mesh lightmap positions). Maybe i'm not exactly sure what you're requesting, if you can give a bit more info.
     
  6. McDev02

    McDev02

    Joined:
    Nov 22, 2010
    Posts:
    636
    My plan was to rebake the scene with merged meshes. I rather want to make prefabs than scene objects, so merging happens only once. Also isn't there the risk that two objects that are merged have two different lightmaps?
    Also having only merged objects makes the scene more lightweight. Before I make a build for example I would have to remove all the raw folders because otherwise their content is built, but if these objects are never used in the game, they don't have to be.
     
  7. McDev02

    McDev02

    Joined:
    Nov 22, 2010
    Posts:
    636
    I just realized that the lightmaps are lost when the scene was closed and reopened. When I click merge the lightmaps are fine, but when saving and hitting play, they are lost. Are you not setting dirty flags properly? I just tried this:
    Clear combined meshes, save scene. Then hit merge, after that the scene is not marked as dirty.
    Anyway even when I make another change, the lightmap is still lost after reopneing the scene.
    Working with 2019.1.10f1

    Attached are my settings, I am using Shadowmask lightmaps
     

    Attached Files:

  8. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,344
    when merging and preserving lightmaps, the tool will separate the meshes per lightmap, so there won't be any issue.

    I'll have a look at that issue. Thanks for letting me know
     
  9. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,344
    Will be submitting an update tomorrow to address the lightmap issues. This is related to how Unity stores references to lightmaps for objects in the scene, and as far as i could gather, there isn't a way to force the object references to be saved.
    Only way i found that works is to have a custom component that contains the lightmap index/offset/scale data and applies it on OnAwake, which is what i will be adding.
    So you should only toggle the "PreserveLightmapUVs" if you really want to preserve and not bake again later. I include a button to clear these components in case you want to change this but don't want to re-merge the objects again.

    If anyone have better ideas on how to solve this issue, i'm all ears. But for now this is the best solution that i found.

    Maybe someone from Unity could sneak in and verify if this is the only real solution for this issue.
     
  10. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,344
    New update has been submitted to the asset store.

    Here's the change log:
    V1.4.3:
    - Fixed an issue with keeping lightmap references would disappear when entering play-mode or loading another scene.
    - Fixed some actions not marking the object as dirty.

    Check my last post for more details.
     
    McDev02 likes this.
  11. Dark-1-Games

    Dark-1-Games

    Joined:
    Mar 26, 2014
    Posts:
    29
    Hi @eskovas and thanks for the great plugin.
    We're having one use case where it doesn't work well though:
    If the meshes have nested colliders and the meshes have odd scales, the resulting colliders have an incorrect scale.
     
  12. Dark-1-Games

    Dark-1-Games

    Joined:
    Mar 26, 2014
    Posts:
    29
    I managed to fix it by making changes in the ColliderFunctions.cs script. What the changes do is, they regenerate the same GameObject structure as the starting raw objects, with their positions and rotations, and place the colliders inside.

    Here's a diff with my changes, hope someone finds it useful
     

    Attached Files:

  13. Dark-1-Games

    Dark-1-Games

    Joined:
    Mar 26, 2014
    Posts:
    29
    It's possible to only generate the structure that has scales that are not (1,1,1) and achieve the same result, so just replace the "else" on line 44 with
    Code (CSharp):
    1. else if(!parentsToPrebake[j].localScale.Equals(Vector3.one))
     
  14. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,344
    @Dark-1-Games Thanks for sharing. Yes, that's an issue that i didn't think about, and the solution would be to just replicate the hierarchy that had the colliders.
    I'll be sure to add support for nested colliders in the next release.
     
  15. noobynobody

    noobynobody

    Joined:
    May 9, 2019
    Posts:
    76
    Does this have/will have mesh decimation or texture atlasing?
     
    Last edited: Oct 9, 2019
  16. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    1,507
    This is a long shot, but can this asset rebake textures with uvs repacked from different objects? So if I have objects with wasted uv spaces, can this tool repack my uv, and bake out atlas instead of just making atlas out of existing maps?

    I am asking this because i have model baked out of voxel and they contains a large amounts of unused uv spaces per each model and would like to combine those objects into one atlas but with more efficiently packed uvs.
     
  17. PiAnkh

    PiAnkh

    Joined:
    Apr 20, 2013
    Posts:
    110
    Hello,

    Could you tell me if vertex colors are preserved when meshes are merged?
    Important for example if foliage meshes are being merged.

    Thanks
     
  18. eskovas

    eskovas

    Joined:
    Dec 2, 2009
    Posts:
    1,344
    Mesh decimation is not currently planned.
    This tool already allows to merge materials, where textures are merged together into an atlas.
    I'm planning to make an extra tool where you can bake various object materials together in the project, and generate cloned meshes of the original ones, but with UVs placed on the merged material, so that they can then be placed on the scenes using the same material.

    No, this tool doesn't support it at the moment.
    I've gotten a few requests for this exact feature, but it's a fairly tricky thing to make. I'll be sure to try it out as it can be very useful.

    Yes, vertex colors are preserved for both mesh and material merger.
     
  19. Jossgasm

    Jossgasm

    Joined:
    Mar 16, 2013
    Posts:
    2
    I'm not sure how you combine tiled textures. For example I have a plane tiled 5*5. Does it than use 25 times more space in the atlas? Sorry if this a noob question

    Thanks Joss
     
unityunity