public void Start()
    {
        // Create it:
        Filter = new SurfaceTexture();

        // Apply initial properties (inputs into the filter):
        Filter.Set("contours", Contours);
        Filter.Set("uniformity", Uniformity);
        Filter.Set("frequency", Frequency);

        // Start building our voronoi node.
        // Voronoi is, in short, a kind of cellular noise.
        Voronoi v = new Voronoi();

        // *All* are required:
        v.Frequency       = new Property(Filter, "frequency");
        v.Distance        = new Property((int)VoronoiDistance.Euclidean);
        v.DrawMode        = new Property((int)VoronoiDraw.Normal);
        v.MinkowskiNumber = new Property(0f);
        v.Function        = new Property((int)VoronoiMethod.F2minusF1);
        v.Jitter          = new Property(Filter, "uniformity");

        // If we just displayed 'v' as our root node, we'd just
        // get some voronoi noise which looks like a bunch of black and white balls.

        // So, next, we'll tonemap for interesting effects.

        // Create a sine wave with a variable frequency (to be used by the tonemapper):
        TextureNode graph = new ScaleInput(
            new SineWave(),
            new Property(Filter, "contours")
            );

        // Create the tonemapper node now.
        // -> We're mapping the black->white range of pixels from the voronoi noise via our sine graph.
        // That creates a kind of hypnotic black-and-white 'rippling' effect.
        ToneMap map = new ToneMap(v, graph);

        // Let's make it some more exciting colours.
        // Create a gradient from a background->foreground colour, and use lookup to map from our b+w to that gradient.
        Blaze.Gradient2D rawGradient = new Blaze.Gradient2D();
        rawGradient.Add(0f, Color.blue);
        rawGradient.Add(1f, Color.white);

        // Create that lookup now:
        Filter.Root = new Lookup(
            new Loonim.Gradient(rawGradient, null),
            map
            );

        // Create the draw information:
        // - GPU mode
        // - Size px square
        // - HDR (true)
        DrawInfo = new DrawInfo((int)Size);
    }
示例#2
0
        void InitializeBiomeSelection(int Seed)
        {
            //Set Selector noise parameters
            noise_selectCanyon.Seed        = Seed;
            noise_selectCanyon.OctaveCount = 3;
            noise_selectDesertType.Seed    = Seed + 1;
            noise_selectIsland.Seed        = Seed + 2;
            noise_selectOceanType.Seed     = Seed + 3;
            noise_selectPlainDesert.Seed   = Seed - 1;
            noise_selectHills.Seed         = Seed - 2;
            noise_selectMountains.Seed     = Seed - 3;

            //Setup selector functions
            noise_selectCanyonScaled = new ScaleInput(noise_selectCanyon, 16, 16, 16);
            noise_selectCanyonScaled.SourceModule     = noise_selectCanyon;
            noise_selectDesertTypeScaled              = new ScaleInput(noise_selectDesertType, 1, 1, 1);
            noise_selectDesertTypeScaled.SourceModule = noise_selectDesertType;
            noise_selectIslandScaled = new ScaleInput(noise_selectIsland, 8, 8, 8);
            noise_selectIslandScaled.SourceModule      = noise_selectIsland;
            noise_selectOceanTypeScaled                = new ScaleInput(noise_selectOceanType, 1, 1, 1);
            noise_selectOceanTypeScaled.SourceModule   = noise_selectOceanType;
            noise_selectPlainDesertScaled              = new ScaleInput(noise_selectPlainDesert, 2, 2, 2);
            noise_selectPlainDesertScaled.SourceModule = noise_selectPlainDesert;
            noise_selectHillsScaled = new ScaleInput(noise_selectHills, 2, 2, 2);
            noise_selectHillsScaled.SourceModule     = noise_selectHills;
            noise_selectMountainsScaled              = new ScaleInput(noise_selectMountains, 2, 2, 2);
            noise_selectMountainsScaled.SourceModule = noise_selectMountains;

            //Biome generation definitions
            select_canyon = new Select(noise_selectCanyonScaled, id_desert, id_canyon);
            select_canyon.SetBounds(0.7, 1);                    //ca. 15%
            select_desert_type = new Select(noise_selectDesertTypeScaled, id_desert, select_canyon);
            select_desert_type.SetBounds(0, 2);                 //ca. 50%
            select_island = new Select(noise_selectIslandScaled, id_ocean, id_island);
            select_island.SetBounds(0.8, 2);                    //ca. 10%
            select_ocean_type = new Select(noise_selectOceanTypeScaled, id_ocean, select_island);
            select_ocean_type.SetBounds(-2, -0.5);              //ca. 25%
            select_plain_desert = new Select(noise_selectPlainDesertScaled, select_desert_type, id_plains);
            select_plain_desert.SetBounds(-0.2, 2);             //ca. 60%
            select_hills = new Select(noise_selectHillsScaled, select_plain_desert, id_hills);
            select_hills.SetBounds(0.4, 2);                     //ca. 30%
            select_mountains = new Select(noise_selectMountainsScaled, select_hills, id_mountains);
            select_mountains.SetBounds(0.4, 2);                 //ca. 30%
            select_ocean_land = new Select(noise_selectOceanTypeScaled, select_ocean_type, select_mountains);
            select_ocean_land.SetBounds(0.2, 2);                //ca. 40% - last step in combination

            //Terrain generation definitions
            terrainselect_canyon = new Select(noise_selectCanyonScaled, desertOutput, canyonScaled);
            terrainselect_canyon.SetBounds(0.7, 1);
            terrainselect_canyon.EdgeFalloff = 0.01;
            terrainselect_desert_type        = new Select(noise_selectDesertTypeScaled, desertOutput, terrainselect_canyon);
            terrainselect_desert_type.SetBounds(0, 2);
            terrainselect_desert_type.EdgeFalloff = 0.1;
            terrainselect_island = new Select(noise_selectIslandScaled, oceanOutput, islandOutput);
            terrainselect_island.SetBounds(0.8, 2);
            terrainselect_island.EdgeFalloff = 0.2;
            terrainselect_ocean_type         = new Select(noise_selectOceanTypeScaled, oceanOutput, terrainselect_island);
            terrainselect_ocean_type.SetBounds(-2, -0.5);
            terrainselect_ocean_type.EdgeFalloff = 0.05;
            terrainselect_plain_desert           = new Select(noise_selectPlainDesertScaled, terrainselect_desert_type, plainsOutput);
            terrainselect_plain_desert.SetBounds(-0.2, 2);
            terrainselect_plain_desert.EdgeFalloff = 0.1;
            terrainselect_hills = new Select(noise_selectHillsScaled, terrainselect_plain_desert, hillsOutput);
            terrainselect_hills.SetBounds(0.4, 2);
            terrainselect_hills.EdgeFalloff = 0.05;
            terrainselect_mountains         = new Select(noise_selectMountainsScaled, terrainselect_hills, mountainsOutput);
            terrainselect_mountains.SetBounds(0.4, 2);
            terrainselect_mountains.EdgeFalloff = 0.02;
            terrainselect_ocean_land            = new Select(noise_selectOceanTypeScaled, terrainselect_ocean_type, terrainselect_mountains);
            terrainselect_ocean_land.SetBounds(0.2, 2);
            terrainselect_ocean_land.EdgeFalloff = 0.05;
        }
示例#3
0
        void InitializeNoise(int Seed)
        {
            //Ocean Noise Generator
            oceanNoise.Seed          = Seed;
            oceanScaled              = new ScaleInput(oceanNoise, 8, 8, 8);
            oceanScaled.SourceModule = oceanNoise;
            oceanOutput              = new ScaleBiasOutput(oceanScaled);
            oceanOutput.Scale        = 0.25;
            oceanOutput.Bias         = 0.5;

            //Mountain Noise Generator
            mountainsNoise.Seed          = Seed;
            mountainsScaled              = new ScaleInput(mountainsNoise, 4, 4, 4);
            mountainsScaled.SourceModule = mountainsNoise;
            mountainsOutput              = new ScaleBiasOutput(mountainsScaled);
            mountainsOutput.Scale        = 1;
            mountainsOutput.Bias         = 2.2;

            //Hills Noise Generator
            hillsNoise.Seed          = Seed + 5;
            hillsNoise.Persistence   = 0.25;
            hillsScaled              = new ScaleInput(hillsNoise, 16, 16, 16);
            hillsScaled.SourceModule = hillsNoise;
            hillsOutput              = new ScaleBiasOutput(hillsScaled);
            hillsOutput.Scale        = 0.25;
            hillsOutput.Bias         = 1.25;

            //Plains Noise Generator
            plainsNoise.Persistence   = 0.5;
            plainsNoise.Seed          = Seed;
            plainsScaled              = new ScaleInput(plainsNoise, 2, 2, 2);
            plainsScaled.SourceModule = plainsNoise;
            plainsOutput              = new ScaleBiasOutput(plainsScaled);
            plainsOutput.Scale        = 0.17;
            plainsOutput.Bias         = 1.2;

            //Desert Noise Generator
            desertNoise.Persistence = 0.5;
            desertNoise.Seed        = Seed + 10;
            desertOutput            = new ScaleBiasOutput(desertNoise);
            desertOutput.Scale      = 0.3;
            desertOutput.Bias       = 1.3;

            //Canyon Noise Generator
            canyonNoise.Seed   = Seed + 20;
            canyonScaled       = new ScaleBiasOutput(canyonNoise);
            canyonScaled.Scale = 0.4;
            canyonScaled.Bias  = 1.75;

            //Island Noise Generator
            islandNoise.Persistence   = 0.5;
            islandNoise.Seed          = Seed - 10;
            islandScaled              = new ScaleInput(islandNoise, 8, 8, 8);
            islandScaled.SourceModule = islandNoise;
            islandOutput              = new ScaleBiasOutput(islandScaled);
            islandOutput.Scale        = 0.2;
            islandOutput.Bias         = 1.1;

            //Vegetation
            vegetationNoise.Seed = Seed;

            //Overhangs generator
            overhangs.Seed        = Seed;
            overhangs.OctaveCount = 1;
            overhangs.Persistence = 0.3;
        }