Beginner question: I'm trying to draw a "neat" triangle in a unity mesh- ie the edges look relatively even, if I make it large enough. Given a programmatically created mesh (https://catlikecoding.com/unity/tutorials/rounded-cube/), with a simple material with just a color change, I choose a few vertices on the top face and change their height:
private void DrawStuff()
{
int width = xSize - 2;
int height = zSize - 2;
int margin = 5;
int vStart = topStartVertex + (width * margin) + margin + margin;
DrawTriangle(vStart, 10, 10, 10);
}
private void DrawTriangle(int v, int height, int width, int depth)
{
int offset = 0;
for (int i = 0; i < height; i++)
{
for (int j = 0 + offset; j < width - offset; j++)
{
vertices[v + i * (xSize - 1) + j][1] = ySize - depth;
}
offset += 1;
}
}
However, the triangle edges don't all look the same- some are smooth, others are zig-zaggy. I would expect one or the other, but not both. I noticed the same behavior when drawing a rectangle, or even a simple line.
Is this a rendering artifact, or lighting, or something else? Is there an easy way to fix it- ie make the edges consistent, whether smooth or jagged (preferably smooth)?
I read a few other similar questions on mesh smoothing, but I think they are not the same as what I'm asking: