Search Unity

Mesh Baker by Digital Opus [RELEASED]

Discussion in 'Assets and Asset Store' started by Phong, Nov 20, 2012.

  1. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,531
    Thanks for letting me know. Will take a look.
     
  2. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,531
    Looked into this. The problem is that the example scene is mis-configured. The "Texture Bake Results" has no materials. If click bake on the TextureBaker, this will bake the materials on the source objects. After this has been done the scene will run correctly.

    Will fix this in the next release.
     
  3. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,329
    Thanks, that fixed the problem.
     
  4. Pourya-MDP

    Pourya-MDP

    Joined:
    May 18, 2017
    Posts:
    48
    Hello and gongrats for
    One of the best assets in assetstore
    Im using it for a while now and sholud tell its awsome!
    I only have one question and that is what about baking terrain stuffs?i mean tree,grass,stone or whatever that painted on terrain
    Doese mash baker capable of baking its textures and meshes?
    Any help will appreciated
     
  5. unity_RMiJ7SENDRQxhQ

    unity_RMiJ7SENDRQxhQ

    Joined:
    Oct 5, 2018
    Posts:
    1
  6. bbvrdev

    bbvrdev

    Joined:
    Aug 11, 2009
    Posts:
    221
    Hey Phong, quick question for you. I am trying to apply Texture/Mesh Baker in a prefab in Unity 2019, but as soon as I drag objects into the "Objects to be combined" array the Mesh Baker game asset disappears from the hierarchy. Any idea why this is happening? Does it not work in a prefab?
     
  7. Elecman

    Elecman

    Joined:
    May 5, 2011
    Posts:
    1,329
  8. CD-ECEU

    CD-ECEU

    Joined:
    May 21, 2019
    Posts:
    1
    Is there any reason why a lightmap generated by meshbaker would get cannibalized during runtime? When I hit the play button, our baked lightmap vanishes. Poof! It is clearly visible in the editor, and when I rebake it returns.


     
  9. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,531
    Sorry for the slow reply. For some reason the email alerts from the forums don't seem to work.

    Re: Baking terrain stuff.

    It is always a good idea to reduce the number of materials as much as possible. The Batch Prefab Baker is great for this. If many terrain props share a material then Unity has a much easier time batching them.

    Regarding Mesh Baking. For vegetation and grass I would recommend letting the Unity Terrain system manage things for you. The terrain LOD system handles this fairly efficiently and uses billboards for distant trees. For mesh props it is also a good idea to use Unity's mesh system if possible too however you can often help it by baking a few clusters of pebbles and such together. Then Unity needs to manage far fewer instances of detail meshes.

    Try to make sure that the details all use "instancing" materials. Unity can be much more efficient if the props use instancing.
     
  10. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,531
    Sorry for the slow response. Sometimes the forum email notifications don't arrive.

    You need to use scene object instances in the list of objects to combine. The reason is that many of the things that effect how things are baked (lightmap indexes, negative scaling on one axis) are only available in the context of a scene.
     
  11. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,531
    Try setting the lightmapping UVs settings to "generate new UV2 layout" or "copy UV2 to separate rects". The preserve_current_lightmapping is only reliable in certain versions of Unity. I should remove that option.
     
  12. Pourya-MDP

    Pourya-MDP

    Joined:
    May 18, 2017
    Posts:
    48
    Hi there no problem at all
    And thank you for the tips!
    Wish luck for you and your project
     
  13. RakNet

    RakNet

    Joined:
    Oct 9, 2013
    Posts:
    117
    How do I combine materials without combining meshes?

    Edit - I found "Preparing Models For Static/Dynamic Batching (Batch Prefab Baker) AKA Combining Textures Without Combining Meshes" but it doesn't work. While it swaps the mesh, the material remains the original. If I manually assign the new material that mesh baker created, certain meshes have a bad appearance

    Edit 2 - After manually assigning the new materials, I also had to change the Mesh Renderer number of materials to 1.

    Edit 3 - So I got it working, but there are a lot of unnecessary manual steps, such as dragging the prefab in the scene and duplicating the prefab because "Batch Bake Prefabs" can't take the source and destination the same. There's no reason you can't have a one-click solution "Combine Materials" that finds all materials on the objects, creates a new material that combines them, then replaces all materials with the new material on the same prefab.
     

    Attached Files:

    Last edited: Aug 23, 2019 at 4:49 PM
  14. nehvaleem

    nehvaleem

    Joined:
    Dec 13, 2012
    Posts:
    18
    Hi. I am considering buying mesh baker but I am wondering if it's compatible with HDRP or scriptable rendering pipeline in general?
     
  15. Sound_Priest

    Sound_Priest

    Joined:
    Nov 7, 2013
    Posts:
    8
    Hi! MeshBaker bake all geometry with LODs into single mesh or it bake only LOD 0 without other LODs ?
     
  16. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,531
    Yes, Mesh Baker works with Unity Materials and the assigned textures. It does not care what rendering pipeline is being used.
    Thanks for the feedback. Are you using the full version of Mesh Baker?
     
  17. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,531
    There should be no problem with the HDRP pipeline. Mesh Baker works with Unity Materials and the textures used by those materials. It doesn't care what is happening within the shaders themselves.
     
  18. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,531
    You can set up a baker for each LOD level so that all geometry in several LOD0s will be baked together into a combined LOD0 mesh and all geometry for the LOD1 meshes will be baked together into a combined LOD1 mesh etc...
     
  19. alanmthomas

    alanmthomas

    Joined:
    Sep 7, 2015
    Posts:
    136
    I have a question regarding combining skinned mesh renderers at runtime. I have a MeshBaker object in my scene. I can combine the meshes without an issue. This is the code I'm using to do so:

    Code (CSharp):
    1. SkinnedMeshRenderer[] skinnedMeshRenderers = playerHolder.GetComponentsInChildren<SkinnedMeshRenderer>(true);
    2.         GameObject[] objectsToCombine = new GameObject[skinnedMeshRenderers.Length];
    3.  
    4.         for (int i = 0; i < skinnedMeshRenderers.Length; i++)
    5.         {
    6.             objectsToCombine[i] = skinnedMeshRenderers[i].gameObject;
    7.         }
    8.         Debug.Log("smrCount = " + skinnedMeshRenderers.Length);
    9.  
    10.         playerBaker.AddDeleteGameObjects(objectsToCombine, null, true);
    11.         playerBaker.Apply();
    The problem I am running into is when I try to remove meshes. It'll often give me an error, but never seems to actually remove the meshes. In fact, the meshes that I'm attempting to remove stop animating and move to the local origin of the mesh baker object. This is the code I'm using.

    Code (CSharp):
    1. playerBaker.AddDeleteGameObjects(null, skins, true);
    2.         playerBaker.Apply();
    where skins is an array of game objects with skinned mesh renders that I'd like to remove.

    The errors I get are:

    Could not get bounds. Not updating skinned mesh bounds
    UnityEngine.Debug:LogError(Object)
    DigitalOpus.MB.Core.MB3_MeshCombiner:UpdateSkinnedMeshApproximateBoundsFromBoundsStatic(List`1, SkinnedMeshRenderer) (at Assets/MeshBaker/scripts/core/MB3_MeshCombiner.cs:414)

    and

    go paramater was null

    UnityEngine.Debug:LogError(Object)
    DigitalOpus.MB.Core.MB_Utility:GetBounds(GameObject, Bounds&) (at Assets/MeshBaker/scripts/core/MB_Utility.cs:375)
    DigitalOpus.MB.Core.MB3_MeshCombiner:UpdateSkinnedMeshApproximateBoundsFromBoundsStatic(List`1, SkinnedMeshRenderer) (at Assets/MeshBaker/scripts/core/MB3_MeshCombiner.cs:411)

    Any ideas what I could be doing wrong here?
     
  20. alanmthomas

    alanmthomas

    Joined:
    Sep 7, 2015
    Posts:
    136
    I was able to resolve this. I'm using a mesh baker on a bunch of skinned meshes in my scene. I instantiate them and add them at the start of the scene. As they are killed in the game, I flag them for removal and add them to a list. I was handling the removal in LateUpdate. Instead, I now copy that flagged list to a new one, clear that initial list, and then remove all of the objects in a coroutine. This does the trick in a not too convoluted manner.
     
    Phong likes this.
  21. alanmthomas

    alanmthomas

    Joined:
    Sep 7, 2015
    Posts:
    136
    Hi again. Now that I've managed to resolve the previous issues, I'm running across a new problem. When I remove skinned meshes and apply the changes, I get a whole flood of errors along the lines of:
    Assertion failed on expression: 'IsFinite(distanceForSort)'
    Invalid AABB inAABB
    Invalid AABB in a
    Assertion failed on expression: 'IsFinite(distanceAlongView)'

    I've done some googling and saw the previous mention in this thread but nothing there seems to help with the issue. Any ideas?
     
  22. alanmthomas

    alanmthomas

    Joined:
    Sep 7, 2015
    Posts:
    136
    And... never mind on this as well. I managed to fix it. Thanks!