What's the best technique for creating contour borders?

I’m trying to create borders for provinces within my strategy game. The game has towns which are placed randomly at runtime and I have an algorithm which generates the border points for each town. I’d like to draw textured borders which have a material which can change color to indicate which player faction controls the town.

Here is what I have so far:

What I’m currently doing:
Each town has a series of vertex points in world space which define the end points of each border. If I just draw a straight line between these two points, the line will clip through the terrain. So, I currently have a small script which steps along the line segment and samples the terrain position and creates a sub vertex point and adds it to an array. Once I have this list of vertex points, I use “DrawDebugLine” to draw a colored line which follows the contours of the terrain.

Why it’s wrong:
-It’s a debug line! It looks ugly, it’s not meant for production release, etc.
-I can’t texture it with materials.
-If a border is shared, it needs to show both faction colors. This approach doesn’t support that.

What I’ve tried:
-I tried to create splines at run time. I can do this, but I’m new to splines and ran into some clipping and shape issues. My borders have hard corners and splines don’t.
-I tried to manually create textured lines using quad meshes. It’s a pain in the ***, especially when you try to get the mesh to follow the contours of the terrain. A quad has four corners which need to match the terrain shape, and the vertices of one quad need to match the vertices with the next quad (or else you get gaps!). This could work, but it seems like its the “hard way” to do it.

What I’d like to do:
Have some sort of blueprint or object which takes a series of vertex points, draws a contoured line between each line segment, and accepts two colors to apply to each side of the border texture.

What I don’t know how to do:
Create a spline or contour line which follows the contours of the terrain (and only the terrain) without gaps in the mesh and has hard corners (up to 179 degrees).

So, what do you guys think is the best approach to doing something like this?


Hi Slayemin,
Do you ever find a solution for this? For the past weeks I’ve been scratching my head. The closest thing I could find was

This was about two years ago, so I’m just going off of memory here.
A) You don’t want to use “DrawDebugLine()” for rendering lines. It’s debug stuff, so it gets removed when you do a packaged build! To draw lines, you want to draw quads which follow the contours of a surface. If you’re trying to draw borders which can represent ownership by color, you’ll want to draw a line which contains two colors (left and right side), which means each line segment will actually be 2 quads, side by side. It can be drawn with 4 triangles. A border is just a large series of line segments. You’ll also want to look at where line segments intersect so that you can color the sides appropriately.

B) If you’re asking about how I generated the border positions, I used Voronoi. It can sort of work, but in real life, some borders are defined by rivers, lakes, and other natural boundaries.