Topic: Extend Online Maps to create a horizon

Example of how to extend the map area to make a beautiful horizon.
In addition, this script shows how to use elevations from Mapbox.

Post's attachments

Attachment icon Horizon2.cs 12.36 kb, 122 downloads since 2018-04-03 

Kind Regards,
Infinity Code Team

Re: Extend Online Maps to create a horizon


Re: Extend Online Maps to create a horizon

works well so far, nice effect. however i am not using elevation at the moment.
could you explain what the inspector options do? Also, there is a noticeable line from "normal" map to horizon map, any way to blend it a little more?

Re: Extend Online Maps to create a horizon

Updated the script in the first post.
Fixed minor bugs, added description and tooltips for all public fields.

Yes, you can blend it for example in this way (Online Maps Tileset Control / Materials & Shaders / Tile Shader):

Shader "Infinity Code/Online Maps/Tileset Fade Shader"
        _MainTex("Base (RGB) Trans (A)", 2D) = "white" {}

        Tags{ "Queue" = "Transparent-100" "IgnoreProjector" = "True" "RenderType" = "Transparent" }
        LOD 200

#pragma surface surf Lambert alpha

        sampler2D _MainTex;

        struct Input
            float2 uv_MainTex;
            float3 worldPos;

        void surf(Input IN, inout SurfaceOutput o)
            float tilesetSizeX = 1024;
            float tilesetSizeY = 1024;
            float startFadeDist = 480;
            float fadeRange = 32;

            float3 center = float3(tilesetSizeX / -2, 0, tilesetSizeY / 2);

            float3 dist = center - IN.worldPos;
            float len = length(dist);
            float scale = (len - startFadeDist) / fadeRange;

            o.Alpha = saturate(1 - scale);

            fixed4 c = tex2D(_MainTex, IN.uv_MainTex);
            o.Albedo = c.rgb;

    Fallback "Transparent/Cutout/Diffuse"
Kind Regards,
Infinity Code Team

5 (edited by Lurch 2018-12-10 15:01:34)

Re: Extend Online Maps to create a horizon

Do you have an updated version of this, that works with beta?


Re: Extend Online Maps to create a horizon

Version for Online Maps v3 is attached.

Post's attachments

Attachment icon Horizon2_OM3.cs 12.73 kb, 26 downloads since 2018-12-11 

Kind Regards,
Infinity Code Team

Re: Extend Online Maps to create a horizon

Thanks, really appreciate it. I guess I'm the first one to download it. smile

8 (edited by Lurch 2018-12-11 21:04:04)

Re: Extend Online Maps to create a horizon

Thanks again for the OM3 script, however I have noticed something odd. When I rotate my camera view round the horizon, when facing South West, South and South East, the extended textures disappear. when I rotate past East, toward North and until I rotate past West, I can see them.

Tried tweaking the camera Near/Far values, but that does not appear to have any effect on the issue. Also I have tried to set tile sizes to 1024, 512 and 256 but that too does not have any effect.

Attempting to look through the script, it appears the tiles are created, but for some reason they do not appear when facing in a southerly direction.

Update: I was using your ResizeMap script with in conjunction with the OM3 script:

        private void ResizeMap()
            int screenSize = (int) Math.Round(Screen.width);
            int mapSquareSize = screenSize / 256 * 256;
            if (screenSize % 256 != 0) mapSquareSize += 256;

            OnlineMapsTileSetControl.instance.Resize(mapSquareSize, mapSquareSize);
            OnlineMapsCameraOrbit.instance.distance = Screen.height * 0.9f;

and commenting this script out did appear to fix the issue. So not sure of adjusting the map size based on the screen size may be breaking something.

9 (edited by Lurch 2018-12-12 20:09:49)

Re: Extend Online Maps to create a horizon

Good news with my horizon issue, with the OM3 script. Now management have decreed that the tile map is to function in 2D mode. In other words, no camera pitch just up, down, left, right and rotate.

I guess the decision came down after they got a quote from Google, for their new fancy 3D Google Maps for Unity API, at a sticker-shock inducing 2 million dollars per month... yes that's right... per month.

So those issues I was having with the horizon have magically gone away. However I've had to add a few lines of code to your OnlineMapsCameraOrbit.cs file, so that I can lock either the pitch and/or the rotation of the camera. This way I can keep the tile map as is, but have it behave just like a 2D texture map.

The changes are:

1. Two new public variables to allow setting the camera locks, from the inspector:

[Header("Camera Lock Options")]
public bool LockPitch;
public bool LockRotate;

2. Adding in a logic check just before you update the rotation axis:

if (!control.IsCursorOnUIElement(inputPosition))
    isCameraControl = true;

    if (lastInputPosition == lastInputPosition = inputPosition;
    if (lastInputPosition != inputPosition && lastInputPosition !=
        Vector2 offset = lastInputPosition - inputPosition;

        // Lock pitch.
        if (!LockPitch) rotation.x -= offset.y / 10f * speed.x;
        // Lock rotate.
        if (!LockRotate) rotation.y -= offset.x / 10f * speed.y;

    lastInputPosition = inputPosition;

That's it.

Not sure if you think this is worth keeping within the camera orbit control, but it does allow you to control access to these camera movement axis if desired.

Re: Extend Online Maps to create a horizon

I have never seen prices for Google Maps for Unity before.
Two million per month ... good price.
I think every Unity user will buy it.

About locks:
You can simply set the speed to 0.
This will lock the rotation on the desired axis.
These fields will be present in the next version, but I renamed it lockTilt and lockPan.

Kind Regards,
Infinity Code Team