I have a sea trading game that I'm working on developing. Right now, my world looks like this:

enter image description here

There are 4 different "biomes", with more to be added. Internally, this is a large mesh which has 4 different types of materials added to it, to make it work. Each region has a material associated with it.

The problem that I'm trying to overcome is to make it look less squary, I believe the process is known as bitmasking. The traditional way to do so I believe is to use images to show the boundary between each one, having one for each possible curve. That doesn't work with my current mesh architecture so far as I can tell. What I'm wondering is if there is a way to make the edges of the mesh to be curvy instead of straight lines. I assume it would have to be a shader of some kind, but my mind isn't quite figuring out the specifics of how to make it work. Any tips? Thanks!


You could interpolate and make the grid smaller. Basically the idea would be to take those large squares and make them smaller so that the edges are not so obvious.

I posted the algorithm here with an example and some pretty pictures:

Creating colour spectrum by light flux values

Essentially, you would have to take your generated map data array -- and then just stretch it out over a larger map array, making the edges look a lot smoother. This would be an alternative approach to utilizing bitmasking.

Considering you are already converting your map into a mesh, I would assume this wouldn't be much of a performance hit during gameplay, so as long as you pre-calculate it all during the map creation portion.

Edit Alternatively to this -- you could also just sample a larger dataset so that your world is larger to begin with.

  • \$\begingroup\$ That's probably what I'm going to end up doing, although it would have been nice if there was an easier way. Thanks! \$\endgroup\$ – PearsonArtPhoto Jun 21 '16 at 13:36

What I ultimately decided to do was to use a single material with all of the texture compiled together, and add a shader. The effect is as follows:

enter image description here

The shader code is below. I added a texture of some pre-generated noise to let it work.

Shader "Custom/Position Blur" {
        _MainTex("Main", 2D) = "white"{}
        _BumpMap("Bumpmap", 2D) = "bump" {}
        _Noise("Position Noise", 2D) = "gray"{}
        _Smoothness("Smoothness", Range(0,1)) = 0.5
        _Metallic("Metallic", Range(0,1)) = 0.5
        _WorldPosOffset("World Offset",Range(1,100)) = 10
        _MovementOffset("Local Offset",Range(1,100)) = 50
        Tags{ "RenderType" = "Opaque" }
        Cull Off
        #include "UnityPBSLighting.cginc"
        #pragma surface surf Standard

        struct Input {
            float2 uv_MainTex;
            float2 uv_BumpMap;
            float3 viewDir;
            float3 worldPos;

        sampler2D _MainTex;
        sampler2D _Noise;
        sampler2D _BumpMap;
        float _Smoothness;
        float _Metallic;
        float _WorldPosOffset;
        float _MovementOffset;

        void surf(Input IN, inout SurfaceOutputStandard o) {
            float2 offset = float2(
                tex2D(_Noise, float2(IN.uv_MainTex.y / _WorldPosOffset, 0)).r-0.5,
                tex2D(_Noise, float2(0, IN.uv_MainTex.x / _WorldPosOffset)).r-0.5
            o.Albedo = tex2D(_MainTex,IN.uv_MainTex+offset/ _MovementOffset);
            o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
            o.Smoothness = _Smoothness;
            o.Metallic = _Metallic;
        Fallback "Diffuse"

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.