public static void ApplyBiomeTerrainModifiers(BlendedBiomeTerrain b)
        {
            if (b.terrain == null)
            {
                return;
            }

            if (b.terrain.type == SamplerType.Sampler2D)
            {
                PWUtils.ResizeSamplerIfNeeded(b.terrain, ref b.biomeTerrain);
                Sampler2D terrain      = b.terrain as Sampler2D;
                Sampler2D biomeTerrain = b.biomeTerrain as Sampler2D;
                //Fill biomeTerrain instead of terrain to keep an original version of the terrain
                biomeTerrain.Foreach((x, y) => {
                    float val   = terrain[x, y];
                    int biomeId = b.biomeMap.GetBiomeBlendInfo(x, y).firstBiomeId;
                    if (biomeId == -1)
                    {
                        return(val);
                    }
                    //TODO: biome blending
                    return(b.biomeTree.GetBiome(biomeId).biomeTerrain.ComputeValue(x, y, val));
                });
            }
            //else: TODO
            //TODO: apply biome terrain modifiers to terrain

            //TODO: apply biome terrain detail (caves / oth)
        }
Exemple #2
0
 public override void OnNodeProcess()
 {
     if (updateEachProcess)
     {
         CreateNoiseMask();
         samp.Foreach((x, y, val) => { return(val * (mask[x, y])); });
     }
     output = samp;
 }
Exemple #3
0
        Sampler2D GenerateWaterHeight(Sampler2D terrainHeight)
        {
            Sampler2D waterHeight = new Sampler2D(terrainHeight.size, terrainHeight.step);

            terrainHeight.Foreach((x, y, val) => {
                waterHeight[x, y] = waterLevel - val;
            });

            return(waterHeight);
        }
Exemple #4
0
        public override void ComputeSampler2D(Sampler2D samp)
        {
            if (samp == null)
            {
                Debug.LogError("Null sampler sent to Flat noise");
                return;
            }

            samp.Foreach((x, y) => {
                return(flatValue);
            });
        }
Exemple #5
0
        void    CreateNoiseMask()
        {
            Vector2 center  = new Vector2(samp.size / 2, samp.size / 2);
            float   maxDist = samp.size * radius;                     //simplified max dist to get better noiseMask.

            mask.Resize(samp.size);
            maskTexture = new Texture2D(chunkSize, chunkSize, TextureFormat.RGBA32, false, false);
            mask.Foreach((x, y) => {
                float val = 1 - (Vector2.Distance(new Vector2(x, y), center) / maxDist);
                maskTexture.SetPixel(x, y, new Color(val, val, val));
                return(val);
            });
            maskTexture.Apply();
        }
Exemple #6
0
        public void     CreateNoiseMask()
        {
            if (samp == null)
            {
                return;
            }

            Vector2 center  = new Vector2(samp.size / 2, samp.size / 2);
            float   maxDist = samp.size * radius;                     //simplified max dist to get better noiseMask.

            mask.Resize(samp.size);
            mask.Foreach((x, y) => {
                float val = 1 - (Vector2.Distance(new Vector2(x, y), center) / maxDist);
                return(val);
            });
        }
        public override void ComputeSampler2D(Sampler2D samp)
        {
            if (samp == null)
            {
                Debug.LogError("null sampler send to Noise ComputeSampler !");
            }

            if (false)            //(hasGraphicAcceleration)
            {
                //compute shader here
            }
            else
            {
                samp.Foreach((x, y) => {
                    return(GenerateNoise(x, y, octaves, samp.step * scale, lacunarity, persistence, seed));
                });
            }
        }
Exemple #8
0
		public override void OnNodeProcess()
		{
			if (chunkSizeHasChanged)
				output.Resize(chunkSize);

			//recalcul perlin noise values with new seed / position.
			if (needUpdate)
			{
				float scale = 40f;
				output.Foreach((x, y) => {
					float nx = (float)x * step + chunkPosition.x;
					float ny = (float)y * step + chunkPosition.z;
					float val = PerlinNoise2D.GenerateNoise(nx / scale, ny / scale, 2, 2, 1, 1, seed);
					for (int i = 0; i < octaves; i++)
						val *= 1.2f;
					return val;
				});
			}
		}