- Home /
method for merging meshes
Hi, i would be grateful if someone knows and could tell me the proper name for the method use for merging meshes, so i would like the clouds there to be a single mesh, but not just smashing them all together, making the edges blend in so that its a single shape rather than obviously a bunch of spheres, is this a unity thing or would i be better off exploring some ray/cube marching type shaders?
Thanks
You can calculate an 3d SDF (it's easy to do for spheres) and then generate a mesh based on that data with marching cubes.
Answer by Llama_w_2Ls · Jun 15, 2021 at 09:14 AM
As long as they share one material, you might want to have a look at Mesh.CombineMeshes. The meshes are treated as one object, but it looks exactly the same. No changes to the vertices, but just batching the objects together as one, to reduce draw calls. Here's an example:
// Parent all your similar meshes under one object
public void CombineMeshes(GameObject parent)
{
var meshFilters = parent.GetComponentsInChildren<MeshFilter>();
var combines = new CombineInstance[meshFilters.Length];
for (int i = 0; i < combines.Length; i++)
{
var combine = new CombineInstance()
{
mesh = meshFilters[i].sharedMesh,
transform = meshFilters[i].transform.localToWorldMatrix
};
combines[i] = combine;
}
var combinedMesh = new Mesh();
combinedMesh.CombineMeshes(combines);
parent.GetComponent<meshFilter>().Mesh = combinedMesh;
// Now you can delete all the separate cloud meshes as
// they are all combined into one mesh, above
}
cheer, yeah this is close and i use it for other functions, but I wanted to merge the meshes more like if there's say 2 spheres next to each other that they would end up looking like a capsule with no dip
that's closer than anything i've found, ill investigate further, thanks for the clue
Your answer
Follow this Question
Related Questions
After displacing through shader, mesh is same when accessed through script. 2 Answers
Render vertices in OpenGL ES with gl_PointSize 0 Answers
Unity 3D fragment shader - distance from pixel to vertex? 0 Answers
Dynamically animating mesh according to heightmap image sequence 1 Answer
How to force the compilation of a shader in Unity? 5 Answers