Search Unity

Question What could make some meshes turn invisible after baking ?

Discussion in 'General Graphics' started by Aeskyphaz, May 19, 2023.

  1. Aeskyphaz

    Aeskyphaz

    Joined:
    Jun 2, 2017
    Posts:
    52
    I started to experiment a little bit with baking meshes for a character customisation system (starting from a single mesh with several blendshapes, then baking it and passing it to another skinned mesh renderer)

    My first attempt below worked when tested on the blender default cube, passing the new mesh perfectly; but for some reason when I try it with my custom character mesh, the game object is invisible, and I can't figure out why

    I tried copying every parameter I could think of (uvs, tangents, bounds, bone weights... etc) but nothing seems to work, but the mesh itself seems to exist (the newmesh in the code below has the right amount of vertices)

    If anyone ever encountered such a case or has an idea, i'd be grateful !

    Thanks in advance

    Code (CSharp):
    1.  
    2.         public SkinnedMeshRenderer sourceSMR;
    3.         public SkinnedMeshRenderer targetSMR;
    4.  
    5.         public void Bake()
    6.         {
    7.             Mesh newMesh = new Mesh();
    8.             newMesh.name = "newMesh";
    9.  
    10.             sourceSMR.BakeMesh(newMesh);
    11.             targetSMR.sharedMesh = newMesh;
    12.         }
    13.