3
\$\begingroup\$

Currently I am trying to make a procedural terrain generator. When I first started creating my terrain generator I decided to use a radial mask to generate my islands/continents like so: small radical island

But as time went along, I decided that these islands were way too small and I needed the islands to be much larger almost like continents than islands. So what I did was simply make the radial mask bigger. Which did overall result in bigger islands but my islands were now very much 'centered-based' with each island generating roughly the same except for the very outer extremities:

large radical island

Here is the code I used to generate the procedural island. I included a comment on what value I changed to make the island larger. I used Libnoise for the perlin noise.

 void createRadiIsland(int centerX, int centerY)
{
    Perlin perlin = new Perlin();
    perlin.OctaveCount = 8;
    perlin.Frequency = 0.1;
    int seed = 50;
    float BiasX = 7f;
    float BiasY = 7f;
    for (int x = 0; x < grid.columns; x++)
    {
        for (int y = 0; y < grid.rows; y++)
        {


            float distanceX = (centerX - x) * (centerX - x);
            float distanceY = (centerY - y) * (centerY - y);

            float distanceToCenter = Mathf.Sqrt(distanceX * BiasX + distanceY * BiasY);
            distanceToCenter = distanceToCenter / 500; //<-- larger the value the bigger the island
            grid.FindTile(x, y).elevation = Mathf.RoundToInt(((float)perlin.GetValue(x - 0.98 + seed, y - 0.98 + seed, .1) - distanceToCenter * 10));

        }

    }
}

How should I modify my code so that it generates islands/continents that have the general uniqueness of the first island but at a much greater scale? Would I even be able to use a mask anymore? Would I have to use a completely new approach to generating my terrain?

side note:

I thought about solving my problem by using multiple radial gradients instead of just one but I am afraid that it will end up making my islands too blobby looking and not very realistic. Is that true?

\$\endgroup\$

2 Answers 2

1
\$\begingroup\$
  1. create the low-resolution elevation map with the algorithm you used first
  2. scale it up using linear interpolation
  3. add another round of perlin noise to the upscaled elevation map, this time with the higher resolution but smaller height scale. This will add more detail to your landscape.
\$\endgroup\$
2
\$\begingroup\$

I do this in my game by generating a distance field to a set of line segments, and using that as an additional mask on top of the radial one. Here's how its done:

  • Generate N pairs of random points and connect them together as line segments.
  • For each pixel in the mask, determine the distance to every line segment. Take the min over all segments, called d*.
  • Set the pixel to MAX_DISTANCE - d*
  • The result is a mask with values between 0 and MAX_DISTANCE. Higher values correspond to pixels that are closer to line segments, while lower values are further away.
  • Multiply the heightmap by this mask after applying the radial gradient.
  • Scale the mask as desired.

The result is "mountain ranges" and "valleys" in straight lines. For a crazier effect, you can distort the distances in the mask using Perlin noise.

\$\endgroup\$
1
  • \$\begingroup\$ You don't happen to have any images of what this looks like? \$\endgroup\$
    – Jacob Edie
    Commented Mar 3, 2015 at 1:53

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .