Getting the border points of a distortet voronoi texture

I am trying to make a random world generator. to make the Biome shapes I use a voronoi texture that is distorted with perlin noise. But for it to work with the actual hight map generator I need to check the distance from any point to the next borders of the biome.

I tried to find a way to solve this Mathematically, but since the texture is distorted (semi) randomly through Perlin noise nothing really worked. Now I am trying to store all the coordinates of the border points in an array and then finding the nearest Borderpoint for each point in the texture.

Howewer this is really ineficient and also there is no clean way of finding all the border points.

when I try it it looks like this:


the borders are not evenly “thic”

Any suggestions?

One idea is to solve this with image manipulation.
Step 1) Detect the edges and make everything black except for the edges (all your colored areas would be black).
Step 2) Blur the whole image
Now the texture is your lookup table. The blackness of each pixel gives you the distance to the edge. Apply different blur algorithms depending on how “smooth” you want your terrain.
I think you could use a shader or OpenCV to implement it.

About the thickness of the borders. I think that’s more a 2d aliasing issue. What kind of border do you need? If you need exact borders then using a mathematical representation instead of an image would be best imho. From there you can always generate the edge lines with your desired anti-aliasing method.

Another thought. From what I see in your image the whole area could be represented (with good precision) by about 100 2d points. Why not use an array of points and apply the noise on those. From there it would be much easier to generate a smooth outline (bezier) and do distance calculations.