Exemple #1
0
    //Edit this.
    float Noise(int xx, int yy)
    {
        float x = (float)xx / width * scale;
        float y = (float)yy / width * scale;

        float noise = 0;

        noise += (float)simplex.Evaluate(x, y);
        //noise = Mathf.PerlinNoise(x, y);
        ///Noise may only range from 0 to 1.
        ///Todo: limit it :P
        ///for now just divide back and stuff
        return(noise);
    }
Exemple #2
0
    //Experiment with this Koko! :P
    public float HeightMap2(Tile tile)
    {
        int x = (int)tile.coords.x;
        int y = (int)tile.coords.y;

        double noise = 0;

        noise += simplex.Evaluate(x / 5f, y / 5f) / 20;
        noise += simplex.Evaluate(x / 25f, y / 25f) / 6;
        noise += simplex.Evaluate(x / 50f, y / 50f);
        noise += simplex.Evaluate(x / 100f, y / 100f);
        //noise += simplex.Evaluate(x / 750f, y / 750f)*1;

        noise = noise / 2;
        noise = noise - 0.5;

        if (noise >= -0.5)
        {
            noise = (noise * 1.75) + 0.38; //increases height above -0.5, set it to * 10 to see where it is
        }
        if (noise >= 0.1)
        {
            noise = (noise * 1.75) - 0.07;
        }

        if (noise * 50f <= waterThreshold)
        {
            noise = waterThreshold / 50f + (noise / 5) + 0.16;
        }

        if (flatWorld)
        {
            noise = 0f;
        }

        return((float)noise * 50f);
    }
Exemple #3
0
    public float GetElevation(Vector3 point)
    {
        float elevation = 0;
        float frequency = settings.baseRoughness;
        float amplitude = 1;

        for (int i = 0; i < settings.nbOctaves; i++)
        {
            float v = simplex.Evaluate(point * frequency + settings.centre);
            elevation += (v + 1) * .5f * amplitude;
            frequency *= settings.roughness;
            amplitude *= settings.persistence;
        }

        elevation = Mathf.Max(0, elevation - settings.minValue);
        return(elevation * settings.strength);
    }
Exemple #4
0
    public float GetElevation(Vector3 point)
    {
        float noiseValue = 0;
        float frequency  = settings.baseRoughness;
        float amplitude  = 1;
        float weight     = 1;

        for (int i = 0; i < settings.nbOctaves; i++)
        {
            float v = 1 - Mathf.Abs(simplex.Evaluate(point * frequency + settings.centre));
            v     *= v;
            v     *= weight;
            weight = Mathf.Clamp01(v * settings.weightMultiplier);

            noiseValue += v * amplitude;
            frequency  *= settings.roughness;
            amplitude  *= settings.persistence;
        }

        noiseValue = Mathf.Max(0, noiseValue - settings.minValue);
        return(noiseValue * settings.strength);
    }