- Home /
Question by
noobgamemake · May 26, 2020 at 08:02 AM ·
terrainmaterial
My terrain look bad
So i follow a tutorial on how to generate terrain (https://www.youtube.com/watch?v=64NblGkAabk) .And i apply a material on it and it look really bad so i make one in blender then apply the same material on it (the one i didt select). and it look way better.How to fix it?
code:`
{
Mesh Mesh;
public Vector3[] vertices;
int[] triangles;
public int xsize = 20, ysize = 20;
public float X, Y, Z;
public float TileSize;
public float Detail;
void Start()
{
Mesh = new Mesh();
GetComponent<MeshFilter>().mesh = Mesh;
}
void Update()
{
SetUp();
SetUpMesh();
}
void SetUp()
{
vertices = new Vector3[ (xsize + 1) * (ysize + 1) ];
int i = 0;
for (int y = 0; y <= ysize; y++)
{
for (int x = 0; x <= xsize; x++)
{
Z = Mathf.PerlinNoise(X * Mathf.Sin(x),Y * Mathf.Sin(y)) * Detail;
vertices[i] = new Vector3(x,Z,y);
i++;
}
}
int vert = 0;
int tris = 0;
triangles = new int[xsize * ysize *6];
for (int y = 0; y < ysize; y++)
{
for (int x = 0; x < xsize; x++)
{
triangles[tris] = vert + 0;
triangles[tris + 1] = vert + xsize + 1;
triangles[tris + 2] = vert + 1;
triangles[tris + 3] = vert + 1;
triangles[tris + 4] = vert + xsize + 1;
triangles[tris + 5] = vert + xsize + 2;
vert++;
tris += 6;
}
vert++;
}
}
void SetUpMesh()
{
Mesh.vertices = vertices;
Mesh.triangles = triangles;
}
} `
bandicam-2020-05-26-15-48-19-357.jpg
(33.4 kB)
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612235259im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Need help generating structures according to texture 1 Answer
Terrain material breaking when adding holes 0 Answers
Can i apply terrain materials to specific textures only? 0 Answers
Unity 5 Bumped terrain ignores normal maps on WP8 build target 0 Answers
Importing custom tree into terrain editor - how do I do it? 1 Answer