From 653118323b16d45bfddec0a2456d25f1061fc76c Mon Sep 17 00:00:00 2001 From: David Rhodes Date: Tue, 2 May 2017 10:12:06 -0600 Subject: [PATCH 1/8] Submodule bump --- dependencies/mapbox-sdk-cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dependencies/mapbox-sdk-cs b/dependencies/mapbox-sdk-cs index d4850704d..dde155d06 160000 --- a/dependencies/mapbox-sdk-cs +++ b/dependencies/mapbox-sdk-cs @@ -1 +1 @@ -Subproject commit d4850704db12269df261ff61aea999fef542e3f6 +Subproject commit dde155d06b8c861399e2c8c8e19223309724f6ca From 54762b6bdbbc9710d759447efafec2751b5aa96c Mon Sep 17 00:00:00 2001 From: David Rhodes Date: Tue, 2 May 2017 14:21:15 -0600 Subject: [PATCH 2/8] Bumping for classic raster --- dependencies/mapbox-sdk-cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dependencies/mapbox-sdk-cs b/dependencies/mapbox-sdk-cs index dde155d06..e15c64553 160000 --- a/dependencies/mapbox-sdk-cs +++ b/dependencies/mapbox-sdk-cs @@ -1 +1 @@ -Subproject commit dde155d06b8c861399e2c8c8e19223309724f6ca +Subproject commit e15c64553b2c3f33bfb14fee558864e88bcc0f6e From 6a3152664b53037f6c3484fc8a519a53acab8b58 Mon Sep 17 00:00:00 2001 From: David Rhodes Date: Tue, 2 May 2017 15:02:13 -0600 Subject: [PATCH 3/8] Formatting fix. --- dependencies/mapbox-sdk-cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dependencies/mapbox-sdk-cs b/dependencies/mapbox-sdk-cs index e15c64553..9b66e3b76 160000 --- a/dependencies/mapbox-sdk-cs +++ b/dependencies/mapbox-sdk-cs @@ -1 +1 @@ -Subproject commit e15c64553b2c3f33bfb14fee558864e88bcc0f6e +Subproject commit 9b66e3b7674f5d2cf5482af73bbcbbbf98ccdb46 From 1c0b281764e8790a2665e73bf4d55bc45057dc2d Mon Sep 17 00:00:00 2001 From: David Rhodes Date: Wed, 3 May 2017 11:09:08 -0600 Subject: [PATCH 4/8] Adding retina, mipmap, and compression settings to mapimagefactory. --- .../Unity/Editor/MapImageFactoryEditor.cs | 47 +++++++++++++++++-- .../Factories/MapImageFactory.cs | 25 ++++++++-- 2 files changed, 64 insertions(+), 8 deletions(-) diff --git a/sdkproject/Assets/Mapbox/Core/Unity/Editor/MapImageFactoryEditor.cs b/sdkproject/Assets/Mapbox/Core/Unity/Editor/MapImageFactoryEditor.cs index 027a25406..b4143939d 100644 --- a/sdkproject/Assets/Mapbox/Core/Unity/Editor/MapImageFactoryEditor.cs +++ b/sdkproject/Assets/Mapbox/Core/Unity/Editor/MapImageFactoryEditor.cs @@ -1,4 +1,4 @@ -using UnityEngine; +using UnityEngine; using System.Collections; using UnityEditor; using Mapbox.Unity.MeshGeneration.Factories; @@ -12,9 +12,14 @@ public SerializedProperty material_Prop, basicMaps_Prop, customMapId_Prop, + useMipMap_Prop, + textureFormat_Prop, + useRetina_Prop, mapId_Prop; private MonoScript script; + TextureFormat _textureFormat; + private string[] _basicMapIds = new string[6] { "mapbox://styles/mapbox/streets-v10", "mapbox://styles/mapbox/outdoors-v10", @@ -39,8 +44,15 @@ void OnEnable() mapIdType_Prop = serializedObject.FindProperty("_mapIdType"); mapId_Prop = serializedObject.FindProperty("_mapId"); material_Prop = serializedObject.FindProperty("_baseMaterial"); - basicMaps_Prop = serializedObject.FindProperty("_basicMapIds"); - + useMipMap_Prop = serializedObject.FindProperty("_useMipMap"); + textureFormat_Prop = serializedObject.FindProperty("_textureFormat"); + useRetina_Prop = serializedObject.FindProperty("_useRetina"); + _textureFormat = (TextureFormat)textureFormat_Prop.intValue; + if (textureFormat_Prop.enumValueIndex < 0) + { + textureFormat_Prop.intValue = (int)TextureFormat.DXT1; + _textureFormat = TextureFormat.DXT1; + } script = MonoScript.FromScriptableObject((MapImageFactory)target); for (int i = 0; i < _basicMapIds.Length; i++) { @@ -49,7 +61,7 @@ void OnEnable() _choiceIndex = i; break; } - } + } } public override void OnInspectorGUI() @@ -65,7 +77,7 @@ public override void OnInspectorGUI() EditorGUILayout.Space(); var st = (MapImageType)mapIdType_Prop.enumValueIndex; EditorGUI.indentLevel++; - + switch (st) { case MapImageType.BasicMapboxStyle: @@ -91,6 +103,31 @@ public override void OnInspectorGUI() } EditorGUI.indentLevel--; + EditorGUILayout.LabelField("Raster Tile Texture Settings"); + EditorGUI.indentLevel++; + _textureFormat = (TextureFormat)EditorGUILayout.EnumPopup("Texture Format", _textureFormat); + textureFormat_Prop.intValue = (int)_textureFormat; + if (_textureFormat == TextureFormat.DXT1 || _textureFormat == TextureFormat.DXT5) + { + EditorGUILayout.HelpBox("Texture will be compressed. This will reduce image quality and lead to longer initialization times but save memory.", MessageType.Info); + } + else + { + EditorGUILayout.HelpBox("Use DXT format to save memory.", MessageType.Warning); + } + + EditorGUILayout.PropertyField(useMipMap_Prop, new GUIContent("Create Mip Maps")); + if (useMipMap_Prop.boolValue) + { + EditorGUILayout.HelpBox("Mip maps will consume additional memory but reduce noise at increasing distances.", MessageType.Warning); + } + EditorGUILayout.PropertyField(useRetina_Prop, new GUIContent("Request Retina-resolution")); + if (useRetina_Prop.boolValue) + { + EditorGUILayout.HelpBox("Retina will consume additional memory but greatly improves visual quality.", MessageType.Warning); + } + EditorGUI.indentLevel--; + if (GUILayout.Button("Update")) { _factory.Update(); diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Factories/MapImageFactory.cs b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Factories/MapImageFactory.cs index 4f6ad271c..7460d0957 100644 --- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Factories/MapImageFactory.cs +++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Factories/MapImageFactory.cs @@ -1,3 +1,4 @@ +using Mapbox.Unity.Utilities; namespace Mapbox.Unity.MeshGeneration.Factories { using System; @@ -30,6 +31,15 @@ public class MapImageFactory : Factory [SerializeField] public Material _baseMaterial; + [SerializeField] + TextureFormat _textureFormat; + + [SerializeField] + bool _useMipMap = false; + + [SerializeField] + bool _useRetina; + private Dictionary _tiles; public override void Initialize(IFileSource fs) @@ -69,7 +79,17 @@ private void Run(UnityTile tile) parameters.MapId = _mapId; tile.ImageDataState = TilePropertyState.Loading; - var rasterTile = parameters.MapId.StartsWith("mapbox://") ? new RasterTile() : new ClassicRasterTile(); + + RasterTile rasterTile; + if (parameters.MapId.StartsWith("mapbox://", StringComparison.Ordinal)) + { + rasterTile = _useRetina ? new RetinaRasterTile() : new RasterTile(); + } + else + { + rasterTile = _useRetina ? new ClassicRetinaRasterTile() : new ClassicRasterTile(); + } + rasterTile.Initialize(parameters, (Action)(() => { if (rasterTile.Error != null) @@ -80,8 +100,7 @@ private void Run(UnityTile tile) var rend = tile.GetComponent(); rend.material = _baseMaterial; - tile.ImageData = new Texture2D(256, 256, TextureFormat.RGB24, false); - tile.ImageData.wrapMode = TextureWrapMode.Clamp; + tile.ImageData = new Texture2D(0, 0, _textureFormat, _useMipMap); tile.ImageData.LoadImage(rasterTile.Data); rend.material.mainTexture = tile.ImageData; tile.ImageDataState = TilePropertyState.Loaded; From c08250eb09da8753c2090253af891a6be37a83f3 Mon Sep 17 00:00:00 2001 From: David Rhodes Date: Wed, 3 May 2017 11:13:18 -0600 Subject: [PATCH 5/8] updating changelog for develop --- documentation/docs/05-changelog.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/documentation/docs/05-changelog.md b/documentation/docs/05-changelog.md index 19dd19f6c..d5a05f90f 100644 --- a/documentation/docs/05-changelog.md +++ b/documentation/docs/05-changelog.md @@ -1,5 +1,10 @@ ## CHANGELOG +#### [Develop](https://github.com/mapbox/mapbox-unity-sdk/tree/develop) + +- Added new raster tiles that request retina resolution +- Added mipmap, texture format (and compression via DXT), and retina resolution support to `MapImageFactory` + #### v0.5.1 *05/01/2017* From b0c7d26d854b9dc7ddb35fd9797d783ba8b685f5 Mon Sep 17 00:00:00 2001 From: David Rhodes Date: Wed, 3 May 2017 11:44:22 -0600 Subject: [PATCH 6/8] bumping submodule to fix inheritance issue. --- dependencies/mapbox-sdk-cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dependencies/mapbox-sdk-cs b/dependencies/mapbox-sdk-cs index 9b66e3b76..1121e372d 160000 --- a/dependencies/mapbox-sdk-cs +++ b/dependencies/mapbox-sdk-cs @@ -1 +1 @@ -Subproject commit 9b66e3b7674f5d2cf5482af73bbcbbbf98ccdb46 +Subproject commit 1121e372dafb4e8d13be1d45329099704a8c4553 From ce6bcf9947e017e3accd741df638726512aec27a Mon Sep 17 00:00:00 2001 From: David Rhodes Date: Wed, 3 May 2017 11:51:57 -0600 Subject: [PATCH 7/8] simplified property for texture format dropdown --- .../Core/Unity/Editor/MapImageFactoryEditor.cs | 15 ++++----------- .../MeshGeneration/Factories/MapImageFactory.cs | 2 +- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/sdkproject/Assets/Mapbox/Core/Unity/Editor/MapImageFactoryEditor.cs b/sdkproject/Assets/Mapbox/Core/Unity/Editor/MapImageFactoryEditor.cs index b4143939d..cf0fbf99c 100644 --- a/sdkproject/Assets/Mapbox/Core/Unity/Editor/MapImageFactoryEditor.cs +++ b/sdkproject/Assets/Mapbox/Core/Unity/Editor/MapImageFactoryEditor.cs @@ -18,8 +18,6 @@ public SerializedProperty mapId_Prop; private MonoScript script; - TextureFormat _textureFormat; - private string[] _basicMapIds = new string[6] { "mapbox://styles/mapbox/streets-v10", "mapbox://styles/mapbox/outdoors-v10", @@ -47,12 +45,6 @@ void OnEnable() useMipMap_Prop = serializedObject.FindProperty("_useMipMap"); textureFormat_Prop = serializedObject.FindProperty("_textureFormat"); useRetina_Prop = serializedObject.FindProperty("_useRetina"); - _textureFormat = (TextureFormat)textureFormat_Prop.intValue; - if (textureFormat_Prop.enumValueIndex < 0) - { - textureFormat_Prop.intValue = (int)TextureFormat.DXT1; - _textureFormat = TextureFormat.DXT1; - } script = MonoScript.FromScriptableObject((MapImageFactory)target); for (int i = 0; i < _basicMapIds.Length; i++) { @@ -105,9 +97,10 @@ public override void OnInspectorGUI() EditorGUILayout.LabelField("Raster Tile Texture Settings"); EditorGUI.indentLevel++; - _textureFormat = (TextureFormat)EditorGUILayout.EnumPopup("Texture Format", _textureFormat); - textureFormat_Prop.intValue = (int)_textureFormat; - if (_textureFormat == TextureFormat.DXT1 || _textureFormat == TextureFormat.DXT5) + + EditorGUILayout.PropertyField(textureFormat_Prop, new GUIContent("Texture Format")); + var textureFormat = (TextureFormat)textureFormat_Prop.intValue; + if (textureFormat == TextureFormat.DXT1 || textureFormat == TextureFormat.DXT5) { EditorGUILayout.HelpBox("Texture will be compressed. This will reduce image quality and lead to longer initialization times but save memory.", MessageType.Info); } diff --git a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Factories/MapImageFactory.cs b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Factories/MapImageFactory.cs index 7460d0957..0965f39c3 100644 --- a/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Factories/MapImageFactory.cs +++ b/sdkproject/Assets/Mapbox/Core/Unity/MeshGeneration/Factories/MapImageFactory.cs @@ -32,7 +32,7 @@ public class MapImageFactory : Factory public Material _baseMaterial; [SerializeField] - TextureFormat _textureFormat; + TextureFormat _textureFormat = TextureFormat.DXT1; [SerializeField] bool _useMipMap = false; From e23eb3f9c052f7ef5ce997f15a0e3fd3e1cad310 Mon Sep 17 00:00:00 2001 From: brnkhy Date: Wed, 3 May 2017 22:38:41 +0300 Subject: [PATCH 8/8] add small empty space in the map image factory inspector --- .../Assets/Mapbox/Core/Unity/Editor/MapImageFactoryEditor.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sdkproject/Assets/Mapbox/Core/Unity/Editor/MapImageFactoryEditor.cs b/sdkproject/Assets/Mapbox/Core/Unity/Editor/MapImageFactoryEditor.cs index cf0fbf99c..a48cdecde 100644 --- a/sdkproject/Assets/Mapbox/Core/Unity/Editor/MapImageFactoryEditor.cs +++ b/sdkproject/Assets/Mapbox/Core/Unity/Editor/MapImageFactoryEditor.cs @@ -94,7 +94,8 @@ public override void OnInspectorGUI() } EditorGUI.indentLevel--; - + EditorGUILayout.Space(); + EditorGUILayout.Space(); EditorGUILayout.LabelField("Raster Tile Texture Settings"); EditorGUI.indentLevel++;