- Home /
Answered myself right after posting. Sorry
Seing through triangles in runtime edited mesh
Hi, I'm currently working on an algorithm that "digs" a hole into a mesh, typically the ground.
I place random vertices on the top layer on my ground, triangulate them, duplicate them lower to form a hole, and link the borders of the hole together.
Here is the result :
As you see, my problem is that I can see the lower surface of my hole through the remaining top faces of the ground, even though those top faces are visible everywhere else
Here is the chunk of code I use to make the final rendering :
//rendering mesh
newMesh.vertices = newVertices.ToArray();
newMesh.triangles = newTriangles.ToArray();
newMesh.Optimize();
newMesh.RecalculateTangents();
newMesh.RecalculateBounds();
newMesh.RecalculateNormals();
ground.GetComponent<MeshFilter>().mesh = newMesh;
Do you have any idea to fix that ? Maybe it has to do with normals but I find that strange that we can see the top layer face AND through the top layer face.
My ground object uses the standard default shader and i'm using Unity2019.1.7f1
All right, I found the problem right after posting this. Sorry about that. I had my mesh rendered as transparent. I changed the shader's rendering mode to opaque and that did it.
Yay :)
Follow this Question
Related Questions
How to snap a Prefab to the normal of an irregular mesh 1 Answer
Modify a mesh at runtime 0 Answers
Alternative to Mesh.RecalculateNormals 0 Answers
How to flatten 3d image STL to 2d 0 Answers
How to identify mesh faces 2 Answers