public TerrainChunk SpawnChunk(Vector2Int position, Transform parent, int lod) { var heightMap = heightMaps.GetOrCompute(position, _ => Perlin.GeneratePerlinArray(_settings.chunkSize, _settings.chunkSize, _settings.octaves, _settings.scale, _settings.persistence, _settings.lacunarity, _seed, position.x * (_settings.chunkSize - 1), position.y * (_settings.chunkSize - 1))); var terrainChunk = TerrainChunk.Create(position, _settings, parent, heightMap); terrainChunk.setLodMesh(lod); return(terrainChunk); }
public TileType[,] Generate(Grid grid) { var x = grid.grid.GetLength(0); var y = grid.grid.GetLength(1); var perlin = new Perlin(rand); var perlinGrid = perlin.GeneratePerlinArray(x, y, options); var tiles = new TileType[x, y]; //maps the float values to tiles for (int i = 0; i < tiles.GetLength(0); i++) { for (int j = 0; j < tiles.GetLength(1); j++) { tiles[i, j] = GetTile(perlinGrid[i, j], grid.tileMap); } } return(tiles); }