Outline Shader Problem with generated mesh

Hello,

I try to generate a wall structure from vertices. After putting the generated mesh into a meshfilter and meshrenderer, the wall is displayed correctly. However, when I try to apply an outline shader (i.e. this one: [GitHub - Shrimpey/Outlined-Diffuse-Shader-Fixed: This is a fixed version of diffused outline shader from http://wiki.unity3d.com/index.php/Outlined_Diffuse_3][1]), it got some strange behaviour although it works with default meshes.
[119272-shader-problem.png*_|119272]

The mesh generation method works like this:

Vector3[] meshVertices = new Vector3[entity.Triangles.Count * 3];
int[] indices = new int[entity.Triangles.Count * 3];
int j = 0;
int k = 0;
for (int i = 0; i < entity.Triangles.Count; i++)
{
	indices[j] = j;
	meshVertices[j++] = entity.Triangles*.A;*
  • indices[j] = j;*
    _ meshVertices[j++] = entity.Triangles*.C;_
    _
    indices[j] = j;_
    _ meshVertices[j++] = entity.Triangles.B;
    }*
    mesh.vertices = meshVertices;
    mesh.triangles = indices;_

mesh.RecalculateBounds();
mesh.RecalculateNormals();
mesh.RecalculateTangents();
The Triangle class contains just 3 Vector3 Objects for each edge of the triangle.
I cant figure out why the shader behaves like shown on the picture instead of just laying an outline around the object. So help would be appreciated.
*[1]: https://github.com/Shrimpey/Outlined-Diffuse-Shader-Fixed*_
*

I’m guessing your outline shader duplicates the mesh, pushes its vertices out and turns black. Your problem is that your vertices, or edges, are “hard”. The vertices are not shared in the edges, so they go their seperate ways.

One way to solve this is by smoothing the meshes edges in your 3D program or inside unity, although I’m not sure how to do it in unity.

Same problem explained here: https://answers.unity.com/questions/625968/unitys-outline-shader-sharp-edges.html

Ok so the main problem stated on the other question seems to be, that multiple vertices on the same position have different normal vectors?
Guess this will be a tough one, since the positions are coming from another system.
I’ll see what I can do to get the vertice structure of the base model, so that I can examine whether the normals are correct or not.

If there would be a simpler way to do this using unity, I’d appreciate a suggestion on how to do it.

But thanks in Advance @callebo_FK for this hint.