BiomeData Generate2DBiomeData() { BiomeData biomeData = new BiomeData(); BiomeSwitchGraph switchGraph = new BiomeSwitchGraph(); Sampler2D terrainHeight = new Sampler2D(size, step); PerlinNoise2D perlin = new PerlinNoise2D(seed); perlin.UpdateParams(seed, step, octaves, persistance, lacunarity); perlin.ComputeSampler2D(terrainHeight); terrainHeight = NoiseFunctions.Map(terrainHeight, 0, maxTerrainHeight); biomeData.waterLevel = waterLevel; biomeData.isWaterless = isWaterless; biomeData.UpdateSamplerValue(BiomeSamplerName.terrainHeight, terrainHeight); if (!isWaterless) { biomeData.UpdateSamplerValue(BiomeSamplerName.waterHeight, GenerateWaterHeight(terrainHeight)); } switchGraph.BuildTestGraph(0); biomeData.biomeMap = Generate2DBiomeMap(0); biomeData.biomeSwitchGraph = switchGraph; return(biomeData); }
public void UpdateWaterMap() { outputBiome.UpdateSamplerValue(BiomeSamplerName.terrainHeight, terrainNoise); outputBiome.waterLevel = waterLevel; if (terrainNoise.type == SamplerType.Sampler2D) { //terrain mapping var mappedTerrain = NoiseFunctions.Map(terrainNoise as Sampler2D, mapMin, mapMax, true); outputBiome.UpdateSamplerValue(BiomeSamplerName.terrainHeight, mappedTerrain); //waterHeight evaluation Sampler2D waterHeight = new Sampler2D(terrainNoise.size, terrainNoise.step); waterHeight.min = waterLevel - mappedTerrain.max; waterHeight.max = waterLevel; mappedTerrain.Foreach((x, y, val) => { waterHeight[x, y] = waterLevel - val; }); outputBiome.UpdateSamplerValue(BiomeSamplerName.waterHeight, waterHeight); } else { //TODO 3D terrain water level } }
public override void OnNodeProcess() { outputBiome.Reset(); if (terrain != null && terrain.type == SamplerType.Sampler2D) { //terrain mapping outputBiome.UpdateSamplerValue(BiomeSamplerName.terrainHeight, NoiseFunctions.Map(terrain as Sampler2D, mapMin, mapMax, true)); } }