Provides a noise module that applies a scaling factor and a bias to the output value from a source module. [OPERATOR]
Наследование: ModuleBase
Пример #1
0
    public void GenerateHeightMap()
    {
        var perlin = new LibNoise.Unity.Generator.Perlin(Frequency, Lacunarity, Persistence, Octaves, Seed, LibNoise.Unity.QualityMode.High);
        //var ridged = new LibNoise.Unity.Generator.RidgedMultifractal(Frequency, Lacunarity, Octaves, Seed, LibNoise.Unity.QualityMode.Medium);
        //var turb = new LibNoise.Unity.Operator.Turbulence(0.25, perlin);
        //var layered = new LibNoise.Unity.Operator.Multiply(perlin, ridged);
        //var
        var scaled = new LibNoise.Unity.Operator.ScaleBias(Scaling, ScaleBias, perlin);
        var final = new LibNoise.Unity.Operator.Terrace(false, scaled);

        //for (float  i = 0; i < 50; i += 10)
        final.Add(0f);
        final.Add(10f);
        final.Add(100f);

        var noise = new LibNoise.Unity.Noise2D(TotalSize, final);
        noise.GeneratePlanar(ClipX, ClipX + (ClipSize * ChunksPerSide), ClipY, ClipY + (ClipSize * ChunksPerSide));

        GameObject.Destroy(HeightMap);
        HeightMap = noise.GetTexture(LibNoise.Unity.Gradient.Grayscale);
        HeightMap.Apply();

        GameObject.Destroy(NormalMap);
        NormalMap = noise.GetNormalMap(1f);
        NormalMap.Apply();

        floatMap = new float[TotalSize * TotalSize];
        for (int y = 0; y < TotalSize; y++)
            for (int x = 0; x < TotalSize; x++)
                floatMap[y * TotalSize + x] = noise[x, y];
    }
Пример #2
0
    void GenerateNoise()
    {
        mountainTerrain.OctaveCount = Octaves;
        mountainTerrain.Frequency = 2f;
        baseFlatTerrain.OctaveCount = Octaves;
        terrainType.OctaveCount = Octaves;
        Voronoi vnoise = new Voronoi();
        vnoise.Frequency = 5f;
        Perlin pnoise = new Perlin();
        pnoise.Frequency = 2f;

        Scale scaledvnoise = new Scale(Scalarv, Scalarv, Scalarv, vnoise);
        Scale scaledpnoise = new Scale(Scalarv, Scalarv, Scalarv, pnoise);

        baseFlatTerrain.Frequency = 2.0f;
        ScaleBias flatTerrain = new ScaleBias(0.125, -0.75, baseFlatTerrain);
        terrainType.Frequency = 0.5f;
        terrainType.Persistence = 0.25;
        Select noiseSelect = new Select(scaledpnoise, scaledvnoise, terrainType);

        Select terrainSelector = new Select(flatTerrain, mountainTerrain, terrainType);
        terrainSelector.SetBounds(0.0, 1000.0);
        terrainSelector.FallOff = 0.125;
        Turbulence finalTerrain = new Turbulence(0.25, terrainSelector);
        finalTerrain.Frequency = 4.0f;

        noise = new Scale(Scalarv, Scalarv, Scalarv, finalTerrain);
        //noise = new Add(new Scale(Scalarv, Scalarv, Scalarv, finalTerrain), noiseSelect);
        //noise = new Add(noise, scaledvnoise);
    }
Пример #3
0
    void GenerateNoise()
    {
        mountainTerrain.OctaveCount = Octaves;
        mountainTerrain.Frequency = 2f;
        baseFlatTerrain.OctaveCount = Octaves;
        terrainType.OctaveCount = Octaves;

        baseFlatTerrain.Frequency = 2.0f;
        ScaleBias flatTerrain = new ScaleBias(0.125, -0.75, baseFlatTerrain);
        terrainType.Frequency = 0.5f;
        terrainType.Persistence = 0.25;

        Select terrainSelector = new Select(flatTerrain, mountainTerrain, terrainType);
        terrainSelector.SetBounds(0.0, 1000.0);
        terrainSelector.FallOff = 0.125;
        Turbulence finalTerrain = new Turbulence(0.25, terrainSelector);
        finalTerrain.Frequency = 2.0f;

        noise = new Scale(Scalarv, Scalarv, Scalarv, finalTerrain);
    }
Пример #4
0
				public bool StartGame (double max, double min, int seed, int numberOfSites, 
		                       double ParsedContinentFrequency, double ParsedBiomeFrequency, int ParsedOctaves, double ParsedLacunarity, double ParsedPersistence)
				{
						Debug.Log ("Starting the game, Max is:" + max);
						Max = max;
						Min = min;
						Seed = seed;
						NumberOfSites = numberOfSites;
						baseContinentNoise = new Perlin (ParsedContinentFrequency, ParsedLacunarity, ParsedPersistence, ParsedOctaves, seed, LibNoise.Unity.QualityMode.Medium);
						baseContinentSubtractNoise = new Scale (3, 1, 3, baseContinentNoise);
						Subtract sub = new Subtract (baseContinentNoise, baseContinentSubtractNoise);
						perturbedContinentNoise = new Turbulence (1, sub);			


						mountainNoise = new RiggedMultifractal (ParsedBiomeFrequency, ParsedLacunarity, ParsedOctaves, seed, LibNoise.Unity.QualityMode.Medium);
						baseFlatTerrainNoise = new Billow (ParsedBiomeFrequency, ParsedLacunarity, ParsedPersistence, ParsedOctaves, seed, LibNoise.Unity.QualityMode.Medium);
						flatTerrainNoise = new ScaleBias (0.25, -0.75, baseFlatTerrainNoise);
						terrainTypeNoise = new Perlin (ParsedBiomeFrequency, ParsedLacunarity, ParsedPersistence, ParsedOctaves, seed, LibNoise.Unity.QualityMode.Low);
						finalTerrainNoise = new Select (flatTerrainNoise, mountainNoise, terrainTypeNoise);
						finalTerrainNoise.SetBounds (0, 1000);
						finalTerrainNoise.FallOff = .5;

						finalTerrainNoiseMinusContinentNoise = new Subtract(finalTerrainNoise,perturbedContinentNoise);

						heatNoise = new Perlin (ParsedBiomeFrequency, ParsedLacunarity, ParsedPersistence, ParsedOctaves, seed, LibNoise.Unity.QualityMode.Medium);
						moistureNoise = new Perlin (ParsedBiomeFrequency, ParsedLacunarity, ParsedPersistence, ParsedOctaves, -seed, LibNoise.Unity.QualityMode.Medium);

						return BuildGraph ();
				}