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.

These scripts require a Bing Maps Elevation Manager on the map GameObject.
They download the elevation data from the sources and pass it to the Bing Maps Elevation Manager, so you won't actually be making requests to the Bing Maps Elevation API.

Horizon2.cs - version for Online Maps v2.x. Elevation source - Mapbox. For Online Maps v3 will not work.
Horizon2_OM3.cs - version for Online Maps v3. Elevation source - Mapbox.
Horizon2_BingMaps.cs - version for Online Maps v3. Elevation source - Bing Maps.
Horizon2_ArcGIS.cs - version for Online Maps v3. Elevation source - ArcGIS. Currently not working because ArcGIS has stopped its elevation service.

Post's attachments

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

Attachment icon Horizon2_ArcGIS.cs 26.86 kb, 116 downloads since 2022-09-22 

Attachment icon Horizon2_BingMaps.cs 21.72 kb, 51 downloads since 2023-12-08 

Attachment icon Horizon2_OM3.cs 13.79 kb, 49 downloads since 2023-12-08 

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: Extend Online Maps to create a horizon

excellent!

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"
{
    Properties
    {
        _MainTex("Base (RGB) Trans (A)", 2D) = "white" {}
    }

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

        CGPROGRAM
#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;
        }
        ENDCG
    }

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

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

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 3.0.0.30 beta?

Thanks.

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, 432 downloads since 2018-12-11 

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

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 == Vector2.zero) lastInputPosition = inputPosition;
    if (lastInputPosition != inputPosition && lastInputPosition != Vector2.zero)
    {
        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.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: Extend Online Maps to create a horizon

is there a way to do that with ArcGis elevations?

Re: Extend Online Maps to create a horizon

Yes, if you have programming skills you can modify it to work with ArcGIS.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: Extend Online Maps to create a horizon

i was using the sahder script of #4 ((Online Maps Tileset Control / Materials & Shaders / Tile Shader)
to eleminer to see the "normal line" between my Map and the horizon and now when changing the postion and the size in scene of my map,it's no longer working .By using this shader i have transparent map,
How can I change that to no longer see the normal map whatever my map postion and my map size in scene
THANK you

Re: Extend Online Maps to create a horizon

Unfortunately, I did not understand your post.
Please rephrase that.
And perhaps a screenshot of your materials & shaders settings will help to better understand the problem.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

15 (edited by Amen 2019-07-22 13:03:03)

Re: Extend Online Maps to create a horizon

Sorry, what I meant...I m using your shader  in order to have a round map and no longer see "normal line"
Shader "Infinity Code/Online Maps/Tileset Fade Shader"
{
    Properties
    {
        _MainTex("Base (RGB) Trans (A)", 2D) = "white" {}
    }

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

        CGPROGRAM
#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;
        }
        ENDCG
    }

        Fallback "Transparent/Cutout/Diffuse"
}


and it workes verry well as in the next picture ...but what I noticed is that when I change the postion of the map, I have more the same result.
Any way to solve the problem ? .
Thank you ,

Post's attachments

Attachment icon round.PNG 787.2 kb, 155 downloads since 2019-07-22 

Re: Extend Online Maps to create a horizon

Try this:

// ...
float3 dist = center - IN.worldPos + mul(unity_ObjectToWorld, float4(0,0,0,1)).xyz;
// ...
Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

17 (edited by Amen 2019-07-23 08:33:23)

Re: Extend Online Maps to create a horizon

thank youuuu ,
it works if I change position ,and in the case that I  change map rotation I see no longer the map.
What should I modify ?
thank youuuuu

Re: Extend Online Maps to create a horizon

Something like that:

// ...
float3 wp = mul(unity_WorldToObject, float4(IN.worldPos, 1)).xyz;
float3 dist = center - float3(wp.x, 0, wp.z);
// ...
Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: Extend Online Maps to create a horizon

It works ,thank you

Re: Extend Online Maps to create a horizon

hello,Can the horizon be loaded with elevation,think you!

Re: Extend Online Maps to create a horizon

Yes, all scripts in the first post support elevations.
I recommend ArcGIS version of the script.

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: Extend Online Maps to create a horizon

hello,
Here's how I do it:
1.I use the HorizonWithoutElevations.cs in OnlineMaps V3,Maps can load elevation, but the horizon cannot load elevation.
2.I use the Horizon2_OM3.cs,Maps and horizons cannot be loaded with elevation.
Am I using it wrong?
Think you.

Re: Extend Online Maps to create a horizon

Here's a video:
https://www.dropbox.com/s/ie2jbt2k3evyo … 4.mp4?dl=0

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.

Re: Extend Online Maps to create a horizon

Cheers, and thank you for the wonderful support!

I added the ArcGIS script to my project and I got it to "half-work". There is clearly a horizon loading, but something is glitching with the elevation (perhaps).

I'm using URP, and both the map and the horizon script is configured to use the TilesetPBRShader.

When I start the project, it looks ok. Then I drag the map to the left and suddenly the screen is covered with a low resolution image (sort of like looking at the map from really really close). Then I continue dragging and it goes away and stuff looks normal again.

Also, while running, if I untick the "ArcGIS" script, the same thing happens and the screen is covered with something "too close".

I'm only able to attach one pic so there's one were you can see a green bar appearing on the right side. A nudge more to the left and it will cover the whole screen.

https://storage.googleapis.com/naked-sailor.appspot.com/public/greenappearing.jpg

Re: Extend Online Maps to create a horizon

Horizon 2 ArcGIS has many ways to fix this:
1. Decrease Position Y Offset, for example to “-25”.
2. Decrease In Map View Y Offset, for example to “-70”.
3. Increase Render Queue Offset, for example to "300".

Kind Regards,
Infinity Code Team.

Boost your productivity a lot and immediately using Ultimate Editor Enhancer. Trial and non-commerce versions available.