public static void CreateMesh(GameObject gameObject, Mesh m, PbrMaterial material, string name, ITextureProvider texProvider, IMaterialProvider matProvider) { if (m == null) { return; } var mesh = m.ToUnityMesh($"{name} Mesh ({gameObject.name})"); // apply mesh to game object var mf = gameObject.GetComponent <MeshFilter>(); mf.sharedMesh = mesh; // apply renderer and material if (m.AnimationFrames.Count > 0) // if number of animations frames are 1, the blend vertices are in the uvs are handle by the lerp shader. { var smr = gameObject.AddComponent <SkinnedMeshRenderer>(); smr.sharedMaterial = material.ToUnityMaterial(matProvider, texProvider); smr.sharedMesh = mesh; smr.SetBlendShapeWeight(0, m.AnimationDefaultPosition); } else { var mr = gameObject.AddComponent <MeshRenderer>(); mr.sharedMaterial = material.ToUnityMaterial(matProvider, texProvider); } }
public Material MergeMaterials(string vpxMaterial, Material textureMaterial) { var pbrMaterial = new PbrMaterial(_sourceTable.GetMaterial(vpxMaterial), id: $"{vpxMaterial.ToNormalizedName()} __textured"); return(pbrMaterial.ToUnityMaterial(this, textureMaterial)); }