Description:
I am seeking assistance with a challenge I’m facing in Unity regarding CombineMeshes and Shader Graph. My objective is to combine water meshes to reduce draw calls, considering that each mesh is unique in its own way, and everything is procedural generated at runtime.
m_CombineInstance = new CombineInstance[filters.Length];
for (var i = 0; i < m_CombineInstance.Length; i++)
{
m_CombineInstance[i].mesh = filters[i].sharedMesh;
m_CombineInstance[i].transform = filters[i].transform.localToWorldMatrix;
filters[i].gameObject.SetActive(false);
}
Problem Overview:
- When testing individual meshes independently, everything behaves as anticipated with no discernible gaps; the meshes maintain their integrity even when combined.
- Upon combining meshes using CombineMeshes, the world space position becomes slightly misaligned.
- While all water features are correctly placed in the world space, a gap appears specifically at the four outer edges of the mesh when combined.
- I can confirm that the issue is not related to the parent, as transforms are reset to defaults (zero).
- The combined meshes represent the water features nearest to the island, and upon closer inspection, it’s evident that the edges are not animating as expected.
- In this current example, there are a total of 64 meshes combined.
Mesh Details:
The meshes represent SubMeshes and share the same material, utilizing Matrix transforms of the CombineMeshes function.
mesh.CombineMeshes(m_CombineInstance, true);
Troubleshooting Steps:
Attempted to use the filters Matrix without success.
meshFilters[i].transform.localToWorldMatrix
Tried setting the vertices Matrix to world space, without success.
newVerts[i] = m.MultiplyPoint3x4(origVerts[i])
Observations:
- Noticed that the vertex displacement doesn’t extend beyond the rendering bounds of the parent GameObject of the CombineMeshes.
- Considering that the meshes are now SubMeshes, there is a suspicion that they might not be returning the correct world space position, despite attempting to set the vertices to world space positions (as shown in the snippet above).
Additional Details:
Unity Version: 2022.2
OS: SteamDeck
Request for Assistance:
Seeking insights, suggestions, or solutions from the community regarding the misalignment issue when combining meshes and its impact on Shader Graph rendering. Any help or guidance would be greatly appreciated!