3
\$\begingroup\$

I'm using Voronoi regions to create a map for my game, much like this. However, the lines are too straight and perfect. How do I make the borders more natural looking? As in, less like US state borders and more like international borders in Europe or Asia.

\$\endgroup\$
  • \$\begingroup\$ Try merging some adjacent cells randomly. \$\endgroup\$ – msell Jan 18 '14 at 14:21
  • 2
    \$\begingroup\$ When anyone mentions map and Voronoi anywhere near each other, I think of this series of map generation studies from the perpetually fantastic Amit Patel. I highly recommend checking them out. \$\endgroup\$ – Anko Jan 19 '14 at 3:24
  • \$\begingroup\$ I don't completely understand what this question is about. Which parts of the Voronoi map are you treating as countries? (Each cell, or some combination?) Do you want a map you can use in gameplay, or is this just a background visuals thing? \$\endgroup\$ – Anko Jan 19 '14 at 3:30
  • \$\begingroup\$ @Anko each cell is a country yes. Is that weird? I want to use it in gameplay but I recognize that that might bring additional challenges. \$\endgroup\$ – Harry Jan 19 '14 at 3:41
  • \$\begingroup\$ @Harry Remember Voronoi regions are guaranteed to be convex, which is why your results resemble US state borders. Most countries' borders have lots of concave features, so msell's suggestion of merging some adjacent cells would likely be more realistic. Arthur's image processing solution won't cut it if you want to have the shapes for use in your game's data model. \$\endgroup\$ – Anko Jan 19 '14 at 5:07
1
\$\begingroup\$

Simply add smooth noise in the form of waves of different amplitudes and frequencies. You would need to add more vertices and split these edges. You could use a noise map to compute nice looking points based on the original edges at random.

Here is some working code:

/*****************************************************************************
 * Artur Wulf White - 18/1/14
 *****************************************************************************/

<languageVersion: 1.0;>

kernel Pres3D
<   namespace : "AWW37";
    vendor : "Arthur";
    version : 1;
    description : "Add noise to map"; >
{
    input image4 src;
    input image4 src2; // some smooth random colorful noise
    output float4 dst;

    parameter float4 coeffx;
    parameter float4 coeffy;

    void
    evaluatePixel()
    {
        const float2 imgSize = float2(512.0, 512.0);

        float2 c2D = (outCoord() / imgSize) - float2(0.5, 0.5);

        float4 tmp = sampleLinear(src2, outCoord());
        c2D.x += tmp.x * coeffx.x + tmp.y * coeffx.y + tmp.z * coeffx.z + tmp.w * coeffx.w;
        c2D.y += tmp.x * coeffy.x + tmp.y * coeffy.y + tmp.z * coeffy.z + tmp.w * coeffy.w;
        if(outCoord().x < imgSize.x && outCoord().y < imgSize.y){
            dst = sampleLinear(src, (c2D + float2(0.5, 0.5)) * imgSize);
        } else{
            dst = float4(0.0, 0.0, 0.0, 0.0);
        }

    }
}

And the result:

enter image description here

I used Pixel Bender for prototyping quickly. Can be re-written in another language.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.