Search Unity

  1. All Pro and Enterprise subscribers: find helpful & inspiring creative, tech, and business know-how in the new Unity Success Hub. Sign in to stay up to date.
    Dismiss Notice
  2. Dismiss Notice

Mesh Baker by Digital Opus [RELEASED]

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

  1. reggie_sgs

    reggie_sgs

    Joined:
    Jun 29, 2014
    Posts:
    246
    I've got some prefabs that have multiple submeshes with each using a different material. I'm trying to bake them into a single mesh with a single material. I've followed the steps under "Preparing Models For Static/Dynamic Batching" but I keep having issues with the UVs not being mapped correctly. The combined material looks good but the combined mesh is not correctly mapped to it. I've tried this with numerous models and they all suffer from the same issue. Here's a pic of one model along with the combined material version. Any ideas why this is failing?

     
  2. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,862
    It looks like some of the submeshes use UVs outside the range 0..1 for the tiling. You need to enable "consider UVs" on the TextureBaker. If the submeshes have significantly different materials you may also need to use the "multiple materials feature".

    Here is an old video that talks more about these features. We will be releasing an updated version of this video in the next 2-3 days.

     
  3. LaCorbiere

    LaCorbiere

    Joined:
    Nov 11, 2018
    Posts:
    29
    Hi Phong - thank you for the info. Makes perfect sense. It sorted the keyboard issues.
     
    Last edited: May 7, 2021
    Phong likes this.
  4. Arkade

    Arkade

    Joined:
    Oct 11, 2012
    Posts:
    639
    Hi,

    Getting error: Assertion failed: Adding texture null to atlas _BumpMap for texSet 2 srcMat Egypt_torch

    Assertion failed: Adding texture null to atlas _BumpMap for texSet 2 srcMat Egypt_torch
    UnityEngine.Debug:Assert(Boolean, String)
    DigitalOpus.MB.Core.<CreateAtlases>c__Iterator0:MoveNext() (at Assets/MeshBaker/scripts/core/TextureCombiner/MB3_TextureCombinerPackerMeshBaker.cs:72)
    DigitalOpus.MB.Core.MB3_TextureCombiner:RunCorutineWithoutPause(IEnumerator, Int32) (at Assets/MeshBaker/scripts/core/TextureCombiner/MB3_TextureCombiner.cs:292)
    DigitalOpus.MB.Core.MB3_TextureCombiner:RunCorutineWithoutPause(IEnumerator, Int32) (at Assets/MeshBaker/scripts/core/TextureCombiner/MB3_TextureCombiner.cs:305)
    DigitalOpus.MB.Core.MB3_TextureCombiner:RunCorutineWithoutPause(IEnumerator, Int32) (at Assets/MeshBaker/scripts/core/TextureCombiner/MB3_TextureCombiner.cs:305)
    DigitalOpus.MB.Core.MB3_TextureCombiner:RunCorutineWithoutPause(IEnumerator, Int32) (at Assets/MeshBaker/scripts/core/TextureCombiner/MB3_TextureCombiner.cs:305)
    DigitalOpus.MB.Core.MB3_TextureCombiner:RunCorutineWithoutPause(IEnumerator, Int32) (at Assets/MeshBaker/scripts/core/TextureCombiner/MB3_TextureCombiner.cs:305)
    DigitalOpus.MB.Core.MB3_TextureCombiner:RunCorutineWithoutPause(IEnumerator, Int32) (at Assets/MeshBaker/scripts/core/TextureCombiner/MB3_TextureCombiner.cs:305)
    DigitalOpus.MB.Core.MB3_TextureCombiner:RunCorutineWithoutPause(IEnumerator, Int32) (at Assets/MeshBaker/scripts/core/TextureCombiner/MB3_TextureCombiner.cs:305)
    DigitalOpus.MB.Core.MB3_TextureCombiner:RunCorutineWithoutPause(IEnumerator, Int32) (at Assets/MeshBaker/scripts/core/TextureCombiner/MB3_TextureCombiner.cs:305)
    MB3_TextureBaker:CreateAtlases(ProgressUpdateDelegate, Boolean, MB2_EditorMethodsInterface) (at Assets/MeshBaker/scripts/MB3_TextureBaker.cs:535)
    DigitalOpus.MB.MBEditor.MB3_TextureBakerEditorInternal:DrawGUI(SerializedObject, MB3_TextureBaker, Object[], Type) (at Assets/MeshBaker/Editor/MB3_TextureBakerEditorInternal.cs:430)
    DigitalOpus.MB.MBEditor.MB3_TextureBakerEditor:OnInspectorGUI() (at Assets/MeshBaker/Editor/MB3_TextureBakerEditor.cs:37)
    UnityEngine.GUIUtility:processEvent(Int32, IntPtr)

    Unity 2017.2 (porting an old project to a new platform).
    All meshes use Standard shader.
    Some use various texture slots. Problem material uses only 1 -- Albedo.
    I think they may have used more in the past and Standard Shader keeps those old data. You can see this in the 2 attached images (normal and debug view of the material inspector).
    I suspect MB is enumerating properties and attempting operation on the null _BumpMap.

    Any chance for a fix please :)
     

    Attached Files:

  5. Arkade

    Arkade

    Joined:
    Oct 11, 2012
    Posts:
    639
    Update:
    I tried editing the material's YAML to remove the suspect properties but same problem.
    I tried restarting Unity afterwards too. Nope.

    I've attached a (7z'd) log of a fresh attempt.

    Out of interest, I checked the Torch's UV and can confirm none are outside bounds. I guess this message was also caused by trying to process something that isn't set?
     

    Attached Files:

  6. Arkade

    Arkade

    Joined:
    Oct 11, 2012
    Posts:
    639
    UPDATE 2:
    I've kludged in a check before the assertion for now:
    Code (CSharp):
    1. if (texSet.ts[propIdx].isNull)
    2.     continue;
    Atlasing completed but obviously I don't know what terrible repercussions might have been obscured!
    Thx

    EDIT: Could you let me know if this _might_ cause problems -- I'm proceeding with the kludge-produced assets for now so will need to come back and redo if you say yes :-\
     
    Last edited: May 10, 2021
  7. reggie_sgs

    reggie_sgs

    Joined:
    Jun 29, 2014
    Posts:
    246
    Just wanted to thank you for the quick reply. I watched the video and have been working with it and finally have everything fixed. Using the "consider mesh uvs" option fixed about half of the models. I had to use the "Multiple combined materials" option to fix the others as one of the materials used a different shader and wasn't compatible. MB recognized this and created a 2nd material which then fixed the remaining models. Thanks again!
     
    Phong likes this.
  8. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,862
    Hi Arkade,

    I am having trouble reproducing the problem. I tried creating two Standard shader materials. I gave one of them a bumpMap and left the other blank. Mesh Baker succeeded in generating a bump atlas. It generated a small blank bump texture for the null bumpMap slot. I also tried with both materials (bumpMap blank) and it also worked.

    Mesh Baker should either not create an atlas if there is no bumpMap for all materials or it should create a texture if one is missing.

    Is it possible to create a simple repro scene and send it to me (email or PM)? I will definitely fix the issue.

    I am not sure if your fix will work. By this point in the code, all textures should exist for copying to the atlas. I am not sure what will happen if there is a null texture.

    Another temporary workaround would be to create a small bumpmap texture that is solid neutral normal map purple color and assign it to the bumpMap field of the material. That should get it working without error. I would be very interested in discovering how this is happening for you however.
     
  9. LaCorbiere

    LaCorbiere

    Joined:
    Nov 11, 2018
    Posts:
    29
    Hi Phong. I have a scene with about 4 materials that use different tiling images (base, normal and roughness). Been following tutorials but having mixed results so far. So looking forward to this video. Thanks.
     
  10. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,862
    We just put up the new video a few minutes ago:



    We will also are planning to create another video which focuses on tiling specifically. It should be ready in 2-3 weeks.
     
    LaCorbiere likes this.
  11. Arkade

    Arkade

    Joined:
    Oct 11, 2012
    Posts:
    639
    Had a go at a reproduction. Alas, pulling the problem bits into a standalone project didn't reproduce.
    I can send it to you anyway but obviously it's a bit pointless.

     
  12. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,862
    That is frustrating. I wonder if there is something strange about how the materials are serialized. If you can reproduce it in your main project and you have a moment could you capture a log for me?
    • Set the TextureBaker.LogLevel = trace
    • Clear the log
    • Bake the textures
    • Send me the log file
     
  13. mattycocoa

    mattycocoa

    Joined:
    Feb 5, 2021
    Posts:
    2
    upload_2021-5-14_20-31-26.png
    Hello, im having an issue. maybe it is something simple i am over looking. the grass and a few plants you can see in he scene should be green. the use the same material as the buildings and flowers you see in the scene. upload_2021-5-14_20-35-5.png
    here is what it looks like before baking. thanks!
    upload_2021-5-14_20-41-1.png
     
  14. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,862
    How big are the blocks of color in your source textures? If they are only a few pixels or one pixel, I would recommend making the source textures bigger so that each block of source color is four or nine pixels. This is likely a precision problem where the source textures are trying to sample an individual pixel and anything that causes the sampling to be off even by a tiny amount can get a wildly different color.

    Other suggestions: if you are baking solid color pallet source textures like this then make the following changes to the atlas after baking:
    • Filter mode = point
    • Generate Mip-maps = off
    Let me know if this fixes the issue.

    Another possibility is color tint. What shader are you using? Do those materials use a color tint?
    If so then "blend non-texture properties" might help.
     
    mattycocoa likes this.
  15. mirzamujeeb64

    mirzamujeeb64

    Joined:
    Apr 20, 2020
    Posts:
    4
    Hi, help me, I imported the map from GTA V. I tried to get MeshBaker to work, but the textures are not of the same quality as the low ones. How high quality? But if I tried it separately and small, the quality was worked. It doesn't work big time, also after tried changed 8192mb they don't work, 16XXXmb are while crash? sorry, i'm not good english
     
    Last edited: Jun 10, 2021
  16. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,862
    It is difficult to know what the problem is without more information.

    How big are the source textures and how many are you trying to combine? If the source textures are 4k and you are trying to combine them into a 4k atlas then this is not possible without loosing resolution.

    You may need to combine fewer textures per atlas and create more than one atlas.

    Are the textures tiled? If so then I would suggest watching our videos on Multiple Materials and Tiling.



     
    mirzamujeeb64 likes this.
  17. mirzamujeeb64

    mirzamujeeb64

    Joined:
    Apr 20, 2020
    Posts:
    4
    thanks it worked, the tutorial you uploaded last time, I looked at the old tutorial uf!! But Thankyou good
     
    Last edited: Jun 14, 2021
  18. yeagob

    yeagob

    Joined:
    Jan 27, 2014
    Posts:
    16
    Hi guys!

    Im looking for a mesh siimplification to eliminate mesh superposition. I have a runtime generated mesh with some penetration between objects. When unify objects i need to eliminate inside vertex. Your asset do that?
     
  19. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    1,862
    No, Mesh Baker will not eliminate the inside verts. I don't know of an asset that does that.
     
unityunity