I'm working on a grand strategy game map and would like a way to render fairly smooth borders between provinces like in Paradox Interactive's Imperator: Rome below.

It seems that they use Unsigned Distance Fields (UDFs) to render smooth, reasonably artifact-less borders with support for additional color gradients and hashmarkings. Most of the work, as I understand, around DF rendering comes from Valve's paper from 2007.

Apparently pressing enter while editing tags sends off your post :/

Anyways, these Distance Fields can be rendered with a surprisingly short shader:

shader_type spatial;
uniform sampler2d sdf;

void fragment() {
    ALPHA_SCISSOR = 0.5;
    float alpha = texture(sdf, UV).r;
    ALPHA = alpha;
}

So with a Distance Field that loooks like this:

these are the results...

Not particularly pretty.

Is there a better way to do this?

Maybe try disabling or lowering the alpha scissor? That may make the blending at the edges of the lines a little smoother.

@WinstonHartnett said: Apparently pressing enter while editing tags sends off your post :/

That happens because in web browsers, pressing Enter while on a single-line field will submit the form. This can be prevented using JavaScript code, but it's usually not done in practice for convenience reasons (some people actually expect forms to work this way). When you're mass-fixing tags on posts, this can be a godsend :)

2 years later