Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

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:
    2,083
    Yes, three things to look at when optimizing rendering are:
    • drawcalls
    • batches
    • setpass calls
    Of these, the setpass calls are usually the most expensive. Setpass requires that the GPU cores wait until all cores finish processing all vertices and pixels, then the GPU is reconfigured with new shader code. Setpass is slow. If many meshes use the same material, even if they are not combined, they can be pushed through the graphics pipeline one after the other very efficiently (these extra drawcalls are almost as fast as a single combined mesh).

    Sometimes it is worth putting a material on its own render queue just so unity will process all meshes that use that material at the same time.
     
  2. SpaceRay

    SpaceRay

    Joined:
    Feb 26, 2014
    Posts:
    455
    Hello, I have bought your awesome and great asset and after buying and trying other 3 assets, this I think is surely the best one, and think is very well done, and I like very much the video tutorials that explain how to use it very well and easy to understand and follow

    I have seen the 3 first videos and have read the manual and I have been able to combine correctly the meshes and combined correctly the textures into an atlas and it works well

    HOW TO COMBINE MESHES WITH COLLIDERS?

    BUT the problem I have is that the colliders are missing after the combine, so please, I want to ask how do you combine the objects that have colliders?

    Sorry that I could not read all the 33 pages of this thread to find if you may have answered it before

    In this quote below from your first page I think that there may be something missing on point 5, I mean that is told to add objects to combine, but what happens if these objects have colliders? how the colliders are kept on the combined mesh?

    Thanks very much for your help and thanks very much for creating this and for all the videos and manual as they are very useful

     
  3. b3nni

    b3nni

    Joined:
    Jun 7, 2016
    Posts:
    8
    Ok so i just have to use the "Batch Prefab Baker" (although i´m over the dynamic batch verts limit?) to combine the materials and adjust the uvs?
     
  4. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    Hi SpaceRay,

    The easiest solution is to disable or delete the Renderers on the source objects but leave the colliders enabled. If you are using Mesh Colliders on the source objects you could put a MeshCollider on the combined mesh and use the combine mesh, however I would not recommend doing this. Optimizing physics is different from optimizing rendering. For Physics it is significantly better to have a large number of separate MeshColliders than one big MeshCollider.
     
    hopeful likes this.
  5. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    Yes, I would recommend the batch prefab baker. Another option would be to combine everything into a skinned mesh but I think with 10k meshes, the overhead of the skinning would be a lot slower than the overhead of the extra drawcalls.
     
  6. henriqueam

    henriqueam

    Joined:
    Mar 30, 2017
    Posts:
    13
    Hi, I have successfully baked the materials into combined materials for 1588 objects. Then to bake the meshes with the same texture after the previous step, I had to use the multi mesh baker since the max vertex limited was exceeded.
    The thing is, after I click on BAKE I get the following error:

    Code (CSharp):
    1. Could not compute tangents. All UVs need to form a valid triangles in UV space. If any UV triangles are collapsed, tangents cannot be generated.
    2. UnityEngine.Debug:LogError(Object)
    3. DigitalOpus.MB.Core.MeshChannelsCache:_generateTangents(Int32[], Vector3[], Vector2[], Vector3[], Vector4[]) (at Assets/MeshBaker/scripts/core/MB3_MeshCombinerSimple.cs:518)
    4. DigitalOpus.MB.Core.MeshChannelsCache:_getMeshTangents(Mesh) (at Assets/MeshBaker/scripts/core/MB3_MeshCombinerSimple.cs:406)
    5. DigitalOpus.MB.Core.MeshChannelsCache:GetTangents(Mesh) (at Assets/MeshBaker/scripts/core/MB3_MeshCombinerSimple.cs:177)
    6. DigitalOpus.MB.Core.MB3_MeshCombinerSingle:_addToCombined(GameObject[], Int32[], Boolean) (at Assets/MeshBaker/scripts/core/MB3_MeshCombinerSimple.cs:1423)
    7. DigitalOpus.MB.Core.MB3_MeshCombinerSingle:AddDeleteGameObjectsByID(GameObject[], Int32[], Boolean) (at Assets/MeshBaker/scripts/core/MB3_MeshCombinerSimple.cs:2304)
    8. DigitalOpus.MB.Core.MB3_MultiMeshCombiner:_bakeStep1(GameObject[], Int32[], Boolean) (at Assets/MeshBaker/scripts/core/MB3_MultiMeshCombiner.cs:408)
    9. DigitalOpus.MB.Core.MB3_MultiMeshCombiner:AddDeleteGameObjectsByID(GameObject[], Int32[], Boolean) (at Assets/MeshBaker/scripts/core/MB3_MultiMeshCombiner.cs:289)
    10. DigitalOpus.MB.Core.MB3_MultiMeshCombiner:AddDeleteGameObjects(GameObject[], GameObject[], Boolean) (at Assets/MeshBaker/scripts/core/MB3_MultiMeshCombiner.cs:265)
    11. MB3_MultiMeshBaker:AddDeleteGameObjects(GameObject[], GameObject[], Boolean) (at Assets/MeshBaker/scripts/MB3_MultiMeshBaker.cs:37)
    12. MB3_MeshBakerEditorFunctions:BakeIntoCombined(MB3_MeshBakerCommon) (at Assets/MeshBaker/scripts/Editor/core/MB3_MeshBakerEditorFunctions.cs:56)
    13. DigitalOpus.MB.Core.MB3_MeshBakerEditorInternal:bake(MB3_MeshBakerCommon) (at Assets/MeshBaker/scripts/Editor/MB3_MeshBakerEditorInternal.cs:302)
    14. DigitalOpus.MB.Core.MB3_MeshBakerEditorInternal:DrawGUI(SerializedObject, MB3_MeshBakerCommon, Type) (at Assets/MeshBaker/scripts/Editor/MB3_MeshBakerEditorInternal.cs:263)
    15. DigitalOpus.MB.Core.MB3_MeshBakerEditorInternal:OnInspectorGUI(SerializedObject, MB3_MeshBakerCommon, Type) (at Assets/MeshBaker/scripts/Editor/MB3_MeshBakerEditorInternal.cs:115)
    16. MB3_MultiMeshBakerEditor:OnInspectorGUI() (at Assets/MeshBaker/scripts/Editor/MB3_MultiMeshBakerEditor.cs:58)
    17. UnityEditor.DockArea:OnGUI()
    Any thoughts on why this is happening?

    As a side note the combined mesh gets generated but I don't know what this error is and how it is affecting the end result.


    Let me add another question here: I am currently using the colliders in my buildings for the character and the baked mesh that I get as a result does not have any colliders (on top of being just 1 mesh). Is there a way around this so I can still have the colliders on the mesh?
    Thank you
     
    Last edited: Mar 31, 2017
  7. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    Hi henriqueam, this error is generated because the Mesh Baker component is configured to copy tangents from the source meshes to the combined mesh. One or more of your source meshes do not have tangents. It is possible for Mesh Baker to generate tangents from the UVs and the Normals, but only if the UVs form valid polygons. If some of the UV coordinates are stacked on top of each other then it is not possible to compute a tangent at that point.

    Do your source meshes have tangents? If not I would turn off the tangents channel for the combined mesh. Otherwise you could fix the UV channel or leave this mesh out of the bake.
     
  8. SiloniGhora

    SiloniGhora

    Joined:
    Jul 24, 2015
    Posts:
    4
    Hi,
    Can we bake sprite renderer objects with Mesh renderer objects? I have bought this asset, but I have a need to bake these kinds of objects together but I have not been able to do so.

    Regards,
     
  9. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    Hi Pandeyji,

    This is not supported by Mesh Baker. I am not sure how it would work. The SpriteRenderer uses a MaterialBlock to switch the texture that is being rendered in the Material used by the sprite. If all the sprites were combined into a combined mesh, the material wouldn't know which sprite to use a very different material would be needed.

    I would suggest swtiching the SpriteRenders to MeshRenderers using a quad. These can be combined using Mesh Baker.
     
  10. SpikeP

    SpikeP

    Joined:
    Jan 10, 2017
    Posts:
    3
    Hi Phong,
    Is there a way to bake tga or bmp textures instead of png ?
    Thank you
     
  11. Dionysos1111

    Dionysos1111

    Joined:
    Feb 14, 2016
    Posts:
    39
    Hi,

    Im trying to bake lots of buildings in a huge city to reduce draw calls.

    I tried alot using the open tools for adding objects generate baker for the buildings and then bake every mesh in scene.

    Then i get an error of using more then64k vertices so i tried multimesh but that also gives other errors something like unknows material, Unitymaterial, and it sais try baking textures, but i can't do that because of the 64k limit.

    I really don't want to bake the meshes, just the materials to reduce draw calls.

    How would you bake an entire city?
     
  12. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    Not at this time. I am using the Unity API to save the textures. The API supports PNG, JPG and .EXR textures. It would be easy to modify Mesh Baker to use .JPG or .EXR. Getting it to do .bmp or .tga would be harder.
     
  13. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    I presume you are using Prefabs for the buildings. I would suggest using the Batch Prefab Baker. This will create prefabs that share materials. Buildings can be tricky because there is often a lot of tiling. Heavy tiling usually needs to be mapped to a separate submesh.

     
  14. SpikeP

    SpikeP

    Joined:
    Jan 10, 2017
    Posts:
    3
    Hi Phong,
    Thank you for the quick answer.
    Indeed, a jpg export may be useful. We have some trouble with png alpha channel and our texture compressor.

    Thanks for your time and your awesome asset.
     
  15. creat327

    creat327

    Joined:
    Mar 19, 2009
    Posts:
    1,756
    hi there, i'm using Unity 5.6 and it seems the mesh UVs are not updated.
    As an example, I have a building with 6 materials but it's only a single mesh.
    So I bake the texture, it seems the texture atlas is created fine on a single material. But when I bake the mesh it doesn't seem to update the UVs in any way. I attach a picture
    textuatlas.JPG

    (IMPORTANT: I found the solution:
     
    Last edited: Apr 7, 2017
  16. eco_bach

    eco_bach

    Joined:
    Jul 8, 2013
    Posts:
    1,601
    Please see attached
    I think there must be something I need to do after creating my combined mesh.
    You can see the Mesh Filter for the combined mesh object has brackets around it.
    Because after exporting my scene with dependencies, and then importing the resulting custom package, I end up with a missing mesh!
     

    Attached Files:

  17. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    Hi Eco_bach,

    If you are using "Output = bake into scene object" then the created mesh is part of the scene. If the scene is saved, then the mesh will be exported with the scene. However if you make a prefab of the combined mesh, the prefab object will have an empty mesh. This is because the mesh is not an asset in the project, it only exists in the scene. To make the mesh an asset you need to use "Output = bake into prefab". Then an asset will be generated.
     
  18. Deleted User

    Deleted User

    Guest

    Hello Phong! I'm making a couple of videos about random vegetation placement on my channel. The next video I'm going to make is about Mesh Baker and how it can optimise things -even for dynamic games.

    The code I've written combines grass objects with the multi mesh script in Start(), and then allows the player to left click and remove the grass. It works well when there isn't too much grass, but when I had over 4000 grass objects in the meshbaker meshes, removing one grass object made the frame rate drop to around 5 for a few seconds.

    Could you look at my project file and let me know if this issue can be remedied or improved? https://www.mediafire.com/?pwmh77ksu1v8bk5

    The multi mesh script needs to go on the gameObject called A*. You can adjust the amount of grass in the random forest script which is also on the A* GO. Just move all the sliders to 0, then change the slider for grass from 0 (0% of available vector3s) to 1 (100% of available vector3s).
     
    Last edited by a moderator: Apr 25, 2017
  19. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    Hi, Devstudent,

    I had a look. Nice work. I think the main issue is that "Optimize After Bake" is enabled. Although this works at runtime in the editor it won't work in a build because it uses UnityEditor. It is also very, very slow when applied to large meshes. This is responsible for 95% of the slow down.

    Even with this turned off there is still about a 1 second pause when baking a dozen or more 64k meshes. You could spread this load out across many frames using a coroutine and multiple bakers although it would make the scripting more complicated. You could cap the max size of the combined mesh to make each bake faster, perhaps use 32k meshes instead of 64. You can also put AddDeleteGameObjects and Apply in separate frames to spread the load and achieve a smoother framerate.
     
    Deleted User likes this.
  20. Deleted User

    Deleted User

    Guest

    Thanks a lot for the suggestions! Turning off the optimize after bake option makes a massive difference both to the time it takes to load the scene and to the delay when deleting baked objects.

    Could I put the AddDeleteGameObjects and Apply in a separate thread? If not, I'll just try and spread them out across a few frames with coroutines.

    **Edit: I used Invoke() so the AddDelete and Apply happen in different frames. It works without a noticeable hitch now which is totally insane. Fantastic asset! Here's the updated code:

    private void GrassDeath()
    {
    if(health <= 0)
    {
    grassObj[0] = this.gameObject;

    if(multiMeshBaker.CombinedMeshContains(this.gameObject))
    multiMeshBaker.AddDeleteGameObjects(null, grassObj, true);
    else if(!multiMeshBaker.CombinedMeshContains(this.gameObject))
    Invoke("ApplyMeshBake", .1f);

    }
    }

    private void ApplyMeshBake()
    {
    multiMeshBaker.Apply();
    Destroy(this.gameObject);
    }

    p.s. sorry about the formatting, Unity wouldn't let me upload this as code for some reason.
     
    Last edited by a moderator: Apr 25, 2017
  21. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    Using a separate thread won't work with anything in the Unity API that is a wrapper for a managed objected (Mesh, Texture, Sound, Transform) so no you can't use threads. Coroutines will work though.
     
    Deleted User likes this.
  22. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083

    One more thought. For what you are doing you may want to use the MB3_MultiMeshCombiner class directly. It is not a MonoBehaviour, just a regular C# class. This makes it a little easier to work with in scripts. The MB3_MultiMeshBaker component is just a wrapper for one of these. The component provides a drag and drop interface and a way to serialize the settings in a scene.
     
    Deleted User likes this.
  23. RPowers

    RPowers

    Joined:
    May 14, 2015
    Posts:
    122
    Hi. I'm working on a VR game where I'm GPU bound and I'm trying to understand how Mesh Baker will improve performance exactly. By combining meshes the number of drawcalls sent from CPU to GPU is reduced, which reduces CPU usage or GPU or both? Also by atlasing textures the number of batches is reduced which reduces GPU consumption?

    What I really want to find out is if and how I can use Mesh Baker can reduce my CPU and more importantly GPU consumption. Any explanation of how this stuff works would be greatly appreciated. I'm a novice so please excuse my lack of knowledge in this area. I'm trying to learn but with so many different online sources saying different things I'm having a difficult time grasping this. Thanks.
     
  24. RPowers

    RPowers

    Joined:
    May 14, 2015
    Posts:
    122
    For anyone else learning, this link really helped me: https://unity3d.com/learn/tutorials...ion/optimizing-graphics-rendering-unity-games

    I understand the gist of it now, although I'm still unclear how much of an impact combining meshes and textures has on the GPU. When the GPU receives a SetPass call and has to update the render state, am I correct in saying that the less SetPass calls there are the less updating the GPU has to do? Does the time the GPU takes to update the render state even have any sort of impact?
     
    Last edited: Apr 25, 2017
  25. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    Yes this does affect the GPU performance. The GPU is a pipeline and its many cores can process Vertex and Pixels at the same time. When the render state needs to change, then the GPU cores need to wait until all pixels have finished their work. Some cores sit idle waiting for other cores to finish their work. Then the state changes and the pipeline starts again but no pixel work can happen until some vertices have been processed so again some cores sit idle until the whole pipeline is full of data that can be worked on. The less this happens the better. Meshes that use the same material can be pushed through back to back very efficiently.

    I found this presentation to be the best material I have seen on optimizing. https://www.slideshare.net/AlexanderDolbilov/google-i-o-2014

    For GPU optimizing usually you are looking at trying to speed up the shaders.

    Another trick is to render opaque geometry front to back and cheap to expensive. This works because many GPUs can do an early-z-cull. The fragment part of the shader can be culled if the pixel is behind something opaque that has already been drawn to the depth buffer. It is hard to do a manual sort, but there may be things that are always in the foreground of your game (Player in 3rd person, Gun in 1st person, UI, Minimap). You can set the Material.renderQueue to force these to drawn first. Also draw cheap shaders (diffuse, unlit, lightmapped) before expensive.
     
  26. RPowers

    RPowers

    Joined:
    May 14, 2015
    Posts:
    122
    Thanks a ton for the quick reply. That was very helpful :)
     
  27. Deleted User

    Deleted User

    Guest

    Hello,

    I'm trying to see how much I can do with the free version and I've run into a problem: I can't bake different objects at Start(); I can only bake one type of object with one type of material. I have a material for the grass and a material for the flowers. When I bake them alone it's fine, but when I try and bake them at the same time in Start() I get this error:

    Material Bake Result is null and game object 1225 in list of objects to add did not have a subset of the materials in on the first object. You need to bake textures or all objects must have a subset of materials on the first object.

    I changed the materials to diffuse. I plan on switching them back to their normal shader once the bake is done.
     
  28. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    If the objects have different materials you will need to create an atlas and Material Bake Result with the MB3_TextureBaker. This step is usually done in the editor not at runtime.

    At runtime you can assign the Material Bake Result to the MeshBaker or MeshCombiner and it can combine anything that uses the materials that were baked by the TextureBaker.
     
    Deleted User likes this.
  29. Deleted User

    Deleted User

    Guest

    cool I'm guessing that means the paid version is doing all that behind the scenes. Nice work!

    Got another question:

    How can you have more control over the baked meshes? For example, I have an object in the game which is rock stockpile; rocks are removed and added from the pile as the units use and acquire that resource. How could I have a baked mesh just for those gameObjects in that particular pile?

    If there is a way to do that, could I also bake separate meshes for each type of object? For example, have a baked mesh for all the grass objects, tree objects etc. In the free version, could this avoid the issue associated with baking meshes at runtime, as each baked mesh would only have one material?
     
  30. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    You could create a MeshBaker for each group of rocks. You can update the rock pile each time a rock is added or removed with addDelete.

    You can do the same thing to have separate baker for grass, tree etc...



    Mesh Baker has some tools for helping to group objects in the scene by different criteria for baking.
     
    Deleted User likes this.
  31. lzardo2012

    lzardo2012

    Joined:
    Apr 11, 2013
    Posts:
    80
    Hello, Ian

    I have your asset for quite some time, but just a couple months ago I really decided to try and use it, I also had a few other similar apps such as draw call optimizer but it didn´t do something your asset do.

    I got yours to work, but, to be sincere, even that I successfully reduced drawcalls I could not get any improvement and, actually, my game always got slower, every single time.

    About my game: It´s a top down shooter (think sky force, but since I´m an old timer I´d really loved if I could mentin Ikaruga or Raiden instead...), the background objects are built in a third part software and imported to Cinema4D, all the objects have multiple textures in them, but all of them use the exact same shader and currently I´m using the mobile shaders for performance reasons.

    The objects are already created and grouped into screen sized parts and I wanted them to continue like this.

    The only option I found that did that was "bake meshes in place", but it´s a tedious process, I have to reinsert them into the scene and reapply some scripts to the new meshes, also, the new meshes did not mesh the old meshes positions and, if I made them to rotate in place they rotate around some imaginary axis instead...


    What I really needed was that meshbaker simply created the atlas and the new meshes and replace them in the original objects, keeping all the other properties as they are

    Is it possible to be done?

    and, if so, how should be the approach?

    Thanks in advance
     
  32. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    I think you want the Batch Prefab Baker.



    You can replace the objects in your scene with the modified ones that use the atlas by doing the following:
    • duplicating the prefabs
    • put the duplicates in as the source prefab
    • put the prefabs you are using in the scene as your target prefabs
    • bake the textures into an atlas
    • bake the prefabs
    Regarding the game getting slower. It is important to know if your game is GPU bound or CPU bound. If it is GPU bound, then combining meshes will do very little to improve things and can actually make the game slower (by making fustrum culling less effective). Combining materials will always make the game faster for both the CPU and the GPU.

    I would suggest focusing on setpass calls and batches rather than drawcalls. My general approach to optimizing is:
    • Use as few shaders as possible
    • Use the batch prefab baker to make prefabs share an atlas as much as possible
    • Use the MeshBakerGrouper to group meshes that are close together. The agglomaterive clustering is very good for this.
    This usually yields good results.
     
  33. lzardo2012

    lzardo2012

    Joined:
    Apr 11, 2013
    Posts:
    80
    Wow, that was a quick reply!

    thanks, I´ll try it right now, I´ll let you know...

    But I´m also inclined to think that my problem is GPU bound...

    anyway, I´ll test your suggestion
     
  34. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    If you are GPU bound you should see a speedup if you reduce setpass calls (which the Batch Baker should do).

    There are a few tests to see if your game is GPU bound. Try reducing the resolution. If this speeds up your game then you are GPU bound. Also, in the profiler, look for GFX.WaitForPresent before the rendering calls in CPU Usage with 'timeline' selected (sometimes it is a different call depending on player settings). If you see these, that is the CPU waiting for the GPU to finish rendering the previous frame before it starts sending fresh drawcalls to the GPU.
     
    Last edited: May 9, 2017
  35. lzardo2012

    lzardo2012

    Joined:
    Apr 11, 2013
    Posts:
    80

    Hi, just finished testing the bake prefab

    I just baked the background, because that´s what I thought to be the problem, it´s not, I even tried playing the game with no BG at all and almost no difference in frame rate.

    I haven´t tried skinned meshes yet, for the player, enemies and other stuff, still figuring out how to do that

    I tried reducing the resolution and it also have no impact, so, you are probably right, it has nothing to do with GPU, not in a high end device at least, it´ll probably have a impact on lower end devices but I don´t have any at my disposal atm...

    Thanks a lot for your help!
     
  36. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    Optimization is tricky. The bottlenecks are usually never where you expect. In EVA Infinity I discovered a single 100 particle particle system was taking about 50% of total CPU time. Also it is difficult to tell how well some of Unity's optimization systems (batching, culling) are working. The visibility into these systems isn't great.
     
  37. Crossway

    Crossway

    Joined:
    May 24, 2016
    Posts:
    507
    How should we combine speed tree models that use LOD group?
     
  38. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    Unfortunately I don't have a good solution for SpeedTree. The problem is the BillboardRenderer. Unity does not provide a good API for these so they are difficult to combine.

    That being said, if it is possible to make the trees share a material that will help Unity's internal systems (particularly static batching) work more efficiently. Be sure to set the static batching flag.
     
    Crossway likes this.
  39. Emericanized

    Emericanized

    Joined:
    Apr 30, 2010
    Posts:
    23
    Hello!
    When using Batch Prefab Baker to update in-scene (previously baked) prefabs, is it expected behaviour for their Mesh Filters to become Missing Meshes? The meshes and prefabs in the project seem to be updated, but I seem to have to reassign all of the missing meshes manually. This will not be feasible for updates later in production.

    Thanks for your time.
     
    Last edited: May 24, 2017
  40. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    No this is not expected. You should be able to re-bake the prefabs. Are you using the latest version of Mesh Baker? Also which version of Unity?
     
  41. Emericanized

    Emericanized

    Joined:
    Apr 30, 2010
    Posts:
    23
    • MeshBaker Version: 3.19.4
      • I updated after encountering the issue, in case it was a bug, but the issue persists.
    • Unity Version: 5.5.1p3
      • Unable to upgrade any further at the moment due to project restrictions.
    Troubleshooting steps so far:
    • Create OUT prefabs from scratch (as seen in video)
      • Originally I had duplicated the IN prefabs to create the OUT ones.
    • Reproduced in clean Unity Project (5.5.1p3)
    • Reproduced on different assets in original project

    Thanks for the prompt reply. I've reached out to you via email (contact.dig...) with some log printouts and snapshots of component/asset settings, in case they will help.

    EDIT:
    If i make a change in the scene and undo it, or reopen the scene, the in-scene prefabs populate their missing mesh fields.. If no one else has noticed this... maybe it's a problem with my unity environment. Can you think of any step in the prefab baker process that would be susceptible to this sort of gui update behaviour?
     
    Last edited: May 25, 2017
  42. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    Hi Everyone,

    I just discovered there is an import error with Unity 5.5+. In script: MB_SwapShirts.cs line 21. The error can be fixed by switching the line from:

    meshBaker.AddDeleteGameObjects (objs,null);

    To:

    meshBaker.AddDeleteGameObjects (objs,null,true);

    I will submit a new version tomorrow.
     
  43. lzardo2012

    lzardo2012

    Joined:
    Apr 11, 2013
    Posts:
    80
    Hi!

    I did some more tests, the Batch Prefab Baker works wonderfully, it keeps all of the components and settings working and drastically reduce my SetPass Calls, unfortunatelly it does not have a lot of effect on the frame rate, but, I only atlased the background objects, not the other objects or sprites, I´ll try that later.

    But, what I wanted to do is to report a problem I´m having, and, since I haven´t read this entire thread, perhaps it was already reported.

    I´m having problem with the Legacy shaders, it does make the atlas perfectly, but the baked objects or prefabs or whatever I use does not work, it´s probably losing the UV Mapping or soemthing like this.

    The reason I´m using legacy shaders is because the actual shader I created for the game background objects have three textures, diffuse, normal and emissive, and, the legacy emissive shader utilizes this same maps.

    Using my custom shader also have issues, the atlas did not work, and, for some reason, using the standard shader causes to only the normal map to be baked.

    The workaround I found was to use mobile diffuse shader and then create the missing emissive map on Photoshop.

    But, aside of that, everything working very well.
     
  44. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    Hi lzardo,

    Are there any warnings in the console? The symtoms you describe, "the baked objects or prefabs does not work" are likely due to the objects using out of bounds UVs. Have you tried the "consider UVs feature". Also sometimes objects that use multiple materials cause issues and it is necessary to use the multiple-materials feature.

    Regarding the baker only creating a texture for the normal map: The baker uses the shader in the result material when deciding which atlases to create. Make sure that the result material's shader is set to something that has all the textures you want atlases created for. Also there needs to be at least one texture on the source materials for each atlas you want created. If all source textures are empty then the result material slot will be left empty.

    I am concerned about your reporting that you need to use legacy shaders to bake. I tested the standard shader recently with no problems. What version of Unity are you using?

    [Edit]

    I just tested the standard shader with diffuse, bump and emission and it worked for me. Can you describe your setup in more detail?
     
    Last edited: May 28, 2017
  45. Ninlilizi

    Ninlilizi

    Joined:
    Sep 19, 2016
    Posts:
    294
    Hi, I receive the following error part way through baking textures on Unity 5.5.3

    System.IndexOutOfRangeException: Array index is out of range.
    at DigitalOpus.MB.Core.MB3_TextureCombiner+<__Step3_BuildAndSaveAtlasesAndStoreResults>c__Iterator5.MoveNext () [0x00707] in C:\NKLI\Z-Fragment\Z-Fragment_UnityPRJ\Assets\MeshBaker\scripts\core\MB3_TextureCombiner.cs:1195
    at DigitalOpus.MB.Core.MB3_TextureCombiner.RunCorutineWithoutPause (IEnumerator cor, Int32 recursionDepth) [0x00075] in C:\NKLI\Z-Fragment\Z-Fragment_UnityPRJ\Assets\MeshBaker\scripts\core\MB3_TextureCombiner.cs:492
    at DigitalOpus.MB.Core.MB3_TextureCombiner.RunCorutineWithoutPause (IEnumerator cor, Int32 recursionDepth) [0x0006d] in C:\NKLI\Z-Fragment\Z-Fragment_UnityPRJ\Assets\MeshBaker\scripts\core\MB3_TextureCombiner.cs:505
    at DigitalOpus.MB.Core.MB3_TextureCombiner.RunCorutineWithoutPause (IEnumerator cor, Int32 recursionDepth) [0x0006d] in C:\NKLI\Z-Fragment\Z-Fragment_UnityPRJ\Assets\MeshBaker\scripts\core\MB3_TextureCombiner.cs:505
    at DigitalOpus.MB.Core.MB3_TextureCombiner.RunCorutineWithoutPause (IEnumerator cor, Int32 recursionDepth) [0x0006d] in C:\NKLI\Z-Fragment\Z-Fragment_UnityPRJ\Assets\MeshBaker\scripts\core\MB3_TextureCombiner.cs:505
    at DigitalOpus.MB.Core.MB3_TextureCombiner.RunCorutineWithoutPause (IEnumerator cor, Int32 recursionDepth) [0x0006d] in C:\NKLI\Z-Fragment\Z-Fragment_UnityPRJ\Assets\MeshBaker\scripts\core\MB3_TextureCombiner.cs:505
    at MB3_TextureBaker.CreateAtlases (DigitalOpus.MB.Core.ProgressUpdateDelegate progressInfo, Boolean saveAtlasesAsAssets, MB2_EditorMethodsInterface editorMethods) [0x0001a] in C:\NKLI\Z-Fragment\Z-Fragment_UnityPRJ\Assets\MeshBaker\scripts\MB3_TextureBaker.cs:352
    UnityEngine.Debug:LogError(Object)
    MB3_TextureBaker:CreateAtlases(ProgressUpdateDelegate, Boolean, MB2_EditorMethodsInterface) (at Assets/MeshBaker/scripts/MB3_TextureBaker.cs:359)
    DigitalOpus.MB.Core.MB3_TextureBakerEditorInternal:DrawGUI(SerializedObject, MB3_TextureBaker, Type) (at Assets/MeshBaker/scripts/Editor/MB3_TextureBakerEditorInternal.cs:320)
    MB3_TextureBakerEditor:OnInspectorGUI() (at Assets/MeshBaker/scripts/Editor/MB3_TextureBakerEditor.cs:33)
    UnityEditor.DockArea:OnGUI()​
     
  46. Ninlilizi

    Ninlilizi

    Joined:
    Sep 19, 2016
    Posts:
    294
    Oh, worked around it my excluding the troublesome shaders. Prob needs to handle that condition more gracefully.
     
  47. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    Looking into the problem
     
  48. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    Hmmm, were you using a material that had no textures? In the code I see that there is a rectangle in the atlas that has no textures. I am trying to think of the conditions that could make that happen.
     
  49. projectonemotion

    projectonemotion

    Joined:
    Jan 20, 2017
    Posts:
    16
    Hi
    As i see in mesh baker manual all texture packing algorithms seems that scaling down textures to fit max atlas size, this works fine for small scenes with a few textures but for lots of textures it leads to every single texture become smaller and smaller, so there is no control over quality of final atlas. so is there any chance to putting some options for splitting atlas (to more atlases) in some cases that textures are not fitting into one atlas? mesh baker would be great with this option.
     
  50. Phong

    Phong

    Joined:
    Apr 12, 2010
    Posts:
    2,083
    Thanks for this suggestion. I have been working on this feature over the past week. You can expect something over the next 1-3 weeks.
     
    projectonemotion and hopeful like this.