private void OnValidate() { ds = new DiamondSquare(size, roughness); testingTextures = new Texture2D(ds.GetSize(), ds.GetSize(), TextureFormat.ARGB32, false); for (int i = 0; i < ds.GetSize(); i++) { for (int j = 0; j < ds.GetSize(); j++) { testingTextures.SetPixel(j, i, new Color(ds.Get(j, i) * 255, ds.Get(j, i), ds.Get(j, i), 1)); } } }
public void Tests() { DiamondSquare ds = new DiamondSquare(9, 2); int pixelGapX = Mathf.RoundToInt(ds.GetSize() / Mathf.Sqrt(vertices.Length)); int pixelGapY = Mathf.RoundToInt(ds.GetSize() / Mathf.Sqrt(vertices.Length)); int y = 0; for (var i = 0; i < vertices.Length; i++) { vertices[i] *= ds.Get(Mathf.RoundToInt(i - (y * Mathf.Sqrt(vertices.Length))) * pixelGapX, y * pixelGapY); if (i - (y * Mathf.Sqrt(vertices.Length)) >= Mathf.Sqrt(vertices.Length)) { y += 1; } } }