void Rebuild() { noise.Compute(); for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { float xCoord = (i / (float)width); float yCoord = (j / (float)height); Vector2 r = /*Quaternion.AngleAxis(rotation, Vector3.forward) * */ new Vector2(xCoord, yCoord); if (noise.colored) { Color c = noise.ResolveAsColor(r.x, r.y); texture.SetPixel(i, j, c); } else { float n = noise.Resolve(r.x, r.y); texture.SetPixel(i, j, n * Color.white); } } } texture.Apply(); }
// Use this for initialization void Start() { terrain = GetComponent <Terrain>(); float[,] heights = new float[terrain.terrainData.heightmapWidth, terrain.terrainData.heightmapHeight]; noise.Compute(); for (int i = 0; i < terrain.terrainData.heightmapWidth; i++) { for (int j = 0; j < terrain.terrainData.heightmapHeight; j++) { float x = i / (float)terrain.terrainData.heightmapResolution; float y = j / (float)terrain.terrainData.heightmapResolution; float value = noise.Resolve(x, y); heights[i, j] = value * maxHeight; } } terrain.terrainData.SetHeights(0, 0, heights); }
void Rebuild() { for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { float xCoord = (i / (float)width) + offset.x; float yCoord = (j / (float)height) + offset.y; Vector2 r = Quaternion.AngleAxis(rotation, Vector3.forward) * new Vector2(xCoord, yCoord); if (noiseBox.colored) { Color c = noiseBox.ResolveAsColor(r.x, r.y); texture.SetPixel(i, j, c); } else { float n = noiseBox.Resolve(r.x, r.y); texture.SetPixel(i, j, n * fillColor + (1 - n) * secondary); } } } texture.Apply(); }