0
\$\begingroup\$

I have a procedurally-generated mesh that I am generating to use as a terrain. It looks something like this (from above, and it changes slightly every time):picture of mesh

It also looks fine when I view from the z-axis side.picture of side of mesh

The issue is that when I view it facing the x-axis, it has a black part kind of going through it.side of mesh along the x-axis

I wouldn't really care about that, but when the player goes into the valley, it seems as if they fall under the black part. They can only see the ground and above them it is all black.mesh from player's view after falling in

The mesh does have a mesh collider attached, and so the player doesn't fall the way through the mesh - just the "black line". The height of the mesh (on the y-axis) is generated using perlin noise that I multiply by 800 (to increase the waviness), and that is set when I set the vertices. I suspect that this issue has to do with the normals or the uvs not adjusting to the y-axis, but I've messed around with it a lot and nothing seems to help. I currently generate the normals with RecalculateNormals() after I generate the vertices, triangles, and uvs, and calculate the uvs in a for-loop where I take each vertex's x and z axis and divide it by the number of vertices on that axis time the distance between them (to make it between 0 and 1).

\$\endgroup\$
0
\$\begingroup\$

I figured it out, and it had nothing to do with UVs or normals like I had thought. Actually, there was a problem with how the triangles were generating - most of the last row's triangles were put at the wrong positions and at the wrong angle, leading to the black line crossing the mesh. Fixing the triangles fixed the problem.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.