public void GenerateNormal(Biome _Biome, INoiseMaker _NoiseMaker, int octave) { int i, j; for (i = 0; i < Width; ++i) { for (j = 0; j < Depth; ++j) { //Calculate Height m_MapData[i, j].Height = _Biome.GetHeight(new Vector2Int(i + PivotLB.x, j + PivotLB.y), _NoiseMaker, octave); //Height //Assign layer Data m_MapData[i, j].Layer = _Biome.Layer; Debug.Assert(m_MapData[i, j].Layer != null); //Save Max and Min Altitude of This Chunk MaxAltitude = Math.Max(MaxAltitude, m_MapData[i, j].Height); MinAltitude = Math.Min(MinAltitude, m_MapData[i, j].Height); } } }
public void Execute(int index) { int localX = index % width; int localZ = index / width % height; // X and Z offsets are just the chunk's world position int worldX = localX + xOffset; int worldZ = localZ + zOffset; int solidGroundHeight = 42; // Range 0-1 for all of these float precipitation = GetPrecipitation(worldX, worldZ); float temperature = GetTemperature(worldX, worldZ); float master = GetMaster(worldX, worldZ); Biome biome = DetermineBiome(precipitation, temperature, master, seaLevel); float terrainHeight = biome.GetHeight(worldX, worldZ) + solidGroundHeight; float heightSum = 0; if (!(biome is OceanBiome)) { // Perform blending for (int offsetX = -blending; offsetX <= blending; offsetX++) { for (int offsetY = -blending; offsetY <= blending; offsetY++) { float offsetPrecipitation = GetPrecipitation(worldX + offsetX, worldZ + offsetY); float offsetTemperature = GetTemperature(worldX + offsetX, worldZ + offsetY); float offsetMaster = GetMaster(worldX + offsetX, worldZ + offsetY); Biome offsetBiome = DetermineBiome(offsetPrecipitation, offsetTemperature, offsetMaster, seaLevel); float offsetTerrainHeight = offsetBiome.GetHeight(worldX + offsetX, worldZ + offsetY) + solidGroundHeight; heightSum += offsetTerrainHeight; } } int sampleCount = (blending * 2 + 1) * (blending * 2 + 1); terrainHeight = heightSum / sampleCount; } vertices[index] = new Vector3(localX, terrainHeight, localZ); Color color; switch (terrainDisplayMode) { case TerrainDisplayMode.Normal: color = biome.GetColor(); break; case TerrainDisplayMode.Precipitation: color = GetMapColor(precipitation); break; case TerrainDisplayMode.Temperature: color = GetMapColor(temperature); break; case TerrainDisplayMode.MasterNoise: color = Color.white * master; break; default: color = Color.magenta; break; } ; colors[index] = color; }