Skip to content
This repository was archived by the owner on Feb 23, 2024. It is now read-only.

Commit e591843

Browse files
committed
Update supporting scripts - 0.11.0.
1 parent 745823a commit e591843

File tree

8 files changed

+43
-49
lines changed

8 files changed

+43
-49
lines changed

SupportingScripts/Editor/Scripts/MapRendererEditor.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ internal class MapRendererEditor : Editor
3636
private SerializedProperty _mapEdgeColorProperty;
3737
private SerializedProperty _mapEdgeColorFadeDistanceProperty;
3838
private SerializedProperty _clippingVolumeMaterialProperty;
39-
private SerializedProperty _clippingVolumeDistanceTextureResolution;
39+
private SerializedProperty _clippingVolumeDistanceTextureResolutionProperty;
40+
private SerializedProperty _clippingDistanceLayerProperty;
4041

4142
private static bool _showQualityOptions = true;
4243
private SerializedProperty _detailOffsetProperty;
@@ -127,7 +128,8 @@ private void OnEnable()
127128
_terrainMaterialProperty = serializedObject.FindProperty("_terrainMaterial");
128129
_isClippingVolumeWallEnabledProperty = serializedObject.FindProperty("_isClippingVolumeWallEnabled");
129130
_clippingVolumeMaterialProperty = serializedObject.FindProperty("_clippingVolumeMaterial");
130-
_clippingVolumeDistanceTextureResolution = serializedObject.FindProperty("_clippingVolumeDistanceTextureResolution");
131+
_clippingVolumeDistanceTextureResolutionProperty = serializedObject.FindProperty("_clippingVolumeDistanceTextureResolution");
132+
_clippingDistanceLayerProperty = serializedObject.FindProperty("_clippingDistanceLayer");
131133
_mapEdgeColorProperty = serializedObject.FindProperty("_mapEdgeColor");
132134
_mapEdgeColorFadeDistanceProperty = serializedObject.FindProperty("_mapEdgeColorFadeDistance");
133135
_detailOffsetProperty = serializedObject.FindProperty("_detailOffset");
@@ -403,10 +405,12 @@ public override void OnInspectorGUI()
403405
// Texture Camera Resolution
404406
GUILayout.BeginHorizontal();
405407
EditorGUILayout.PrefixLabel("Clipping Edge Resolution");
406-
_clippingVolumeDistanceTextureResolution.enumValueIndex = GUILayout.Toolbar(
407-
_clippingVolumeDistanceTextureResolution.enumValueIndex, _clippingVolumeDistanceTextureResolutionOptions);
408+
_clippingVolumeDistanceTextureResolutionProperty.enumValueIndex = GUILayout.Toolbar(
409+
_clippingVolumeDistanceTextureResolutionProperty.enumValueIndex, _clippingVolumeDistanceTextureResolutionOptions);
408410
GUILayout.EndHorizontal();
409411

412+
EditorGUILayout.PropertyField(_clippingDistanceLayerProperty);
413+
410414
EditorGUI.indentLevel--;
411415
}
412416

SupportingScripts/Runtime/Shaders/ClippingDistanceShader-MapsSDK.shader

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ Shader "Maps SDK/Clipping Distance"
5454
}
5555

5656
// Writes the linear, normalized depth of the pixel to the render texture.
57-
#if SHADER_API_GLES
58-
// Cannot return float directly in GLES API because float to fixed4 conversion fails.
59-
fixed4 frag(v2f i) : SV_Target
57+
#if SHADER_API_GLES || SHADER_API_METAL
58+
// Cannot return float directly in GLES API because float to float4 conversion fails.
59+
float4 frag(v2f i) : SV_Target
6060
{
6161
#if UNITY_REVERSED_Z
62-
return 1 - i.pos.zzzz;
62+
return float4(1, 1, 1, 1) - i.pos.zzzz;
6363
#else
6464
return i.pos.zzzz;
6565
#endif
@@ -77,4 +77,4 @@ Shader "Maps SDK/Clipping Distance"
7777
ENDCG
7878
}
7979
}
80-
}
80+
}

SupportingScripts/Runtime/Shaders/ClippingVolume-MapsSDK.cginc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
float3 _ClippingVolumePosition;
66
float4 _ClippingVolumeNormals[2];
77
float3 _ClippingVolumeUp;
8-
fixed4 _ClippingVolumeColor;
8+
float4 _ClippingVolumeColor;
99
float3 _ClippingVolumeSize;
1010
float _ClippingVolumeFadeDistance;
1111

SupportingScripts/Runtime/Shaders/ContourLines-MapsSDK.cginc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
#if ENABLE_CONTOUR_LINES
55

66
// Assumes premultiplied alpha for colors.
7-
fixed4 _MajorContourLineColor;
8-
fixed4 _MinorContourLineColor;
7+
half4 _MajorContourLineColor;
8+
half4 _MinorContourLineColor;
99
float _HalfMajorContourLinePixelSize;
1010
float _HalfMinorContourLinePixelSize;
1111
float _NumMinorContourIntervalSections;
1212
float _MinorContourLineIntervalInMeters;
1313

14-
fixed4 ApplyContourLines(fixed4 color, float elevation /* in meters */)
14+
half4 ApplyContourLines(half4 color, float elevation /* in meters */)
1515
{
1616
// Compute the opacity of the contour line.
1717
float changeInIntervalForOnePixel = fwidth(elevation / _MinorContourLineIntervalInMeters);

SupportingScripts/Runtime/Shaders/MRTKIntegration-MapsSDK.cginc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,18 @@ inline float HoverLight(float4 hoverLight, float inverseRadius, float3 worldPosi
1414
return (1.0 - saturate(length(hoverLight.xyz - worldPosition) * inverseRadius)) * hoverLight.w;
1515
}
1616

17-
inline fixed4 ApplyHoverLight(float3 worldPosition, fixed4 color)
17+
inline half4 ApplyHoverLight(float3 worldPosition, half4 color)
1818
{
19-
fixed pointToLight = 0.0;
20-
fixed3 fluentLightColor = fixed3(0.0, 0.0, 0.0);
19+
half pointToLight = 0.0;
20+
half3 fluentLightColor = half3(0.0, 0.0, 0.0);
2121

2222
[unroll]
2323
for (int hoverLightIndex = 0; hoverLightIndex < HOVER_LIGHT_COUNT; ++hoverLightIndex)
2424
{
2525
int dataIndex = hoverLightIndex * HOVER_LIGHT_DATA_SIZE;
26-
fixed hoverValue = HoverLight(_HoverLightData[dataIndex], _HoverLightData[dataIndex + 1].w, worldPosition);
26+
half hoverValue = HoverLight(_HoverLightData[dataIndex], _HoverLightData[dataIndex + 1].w, worldPosition);
2727
pointToLight += hoverValue;
28-
fluentLightColor += lerp(fixed3(0.0, 0.0, 0.0), _HoverLightData[dataIndex + 1].rgb, hoverValue);
28+
fluentLightColor += lerp(half3(0.0, 0.0, 0.0), _HoverLightData[dataIndex + 1].rgb, hoverValue);
2929
}
3030

3131
color.rgb += fluentLightColor * pointToLight;
@@ -34,7 +34,7 @@ inline fixed4 ApplyHoverLight(float3 worldPosition, fixed4 color)
3434

3535
#else
3636

37-
inline fixed4 ApplyHoverLight(float3 worldPosition, fixed4 color)
37+
inline half4 ApplyHoverLight(float3 worldPosition, half4 color)
3838
{
3939
return color;
4040
}

SupportingScripts/Runtime/Shaders/StandardClippingVolumeShader-MapsSDK.shader

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,6 @@ Shader "Maps SDK/Standard Clipping Volume"
2929
#include "ClippingVolume-MapsSDK.cginc"
3030
#include "MRTKIntegration-MapsSDK.cginc"
3131

32-
sampler2D _TerrainDistanceTex;
33-
float2 _MapDimension;
34-
float4x4 _WorldToDistanceCameraMatrix;
35-
float _MapCurrentHeight;
36-
3732
struct appdata
3833
{
3934
float3 vertex : POSITION;
@@ -49,7 +44,6 @@ Shader "Maps SDK/Standard Clipping Volume"
4944
#if ENABLE_MRTK_INTEGRATION
5045
float3 worldPosition : POSITION2;
5146
#endif
52-
float2 texcoord : TEXCOORD0;
5347
float3 normal : NORMAL;
5448

5549
SHADOW_COORDS(1)
@@ -58,6 +52,11 @@ Shader "Maps SDK/Standard Clipping Volume"
5852
UNITY_VERTEX_OUTPUT_STEREO
5953
};
6054

55+
sampler2D _TerrainDistanceTex;
56+
float2 _MapDimension;
57+
float4x4 _WorldToDistanceCameraMatrix;
58+
float _MapCurrentHeight;
59+
6160
v2f vert(appdata v)
6261
{
6362
UNITY_SETUP_INSTANCE_ID(v);
@@ -72,10 +71,10 @@ Shader "Maps SDK/Standard Clipping Volume"
7271
#if ENABLE_MRTK_INTEGRATION
7372
o.worldPosition = worldPosition;
7473
#endif
75-
o.cameraPosition = mul(_WorldToDistanceCameraMatrix, float4(worldPosition, 1.0));
74+
o.cameraPosition = mul(_WorldToDistanceCameraMatrix, float4(worldPosition, 1.0)).xyz;
7675

7776
o.normal = UnityObjectToWorldNormal(v.normal);
78-
77+
7978
TRANSFER_SHADOW(o);
8079
UNITY_TRANSFER_FOG(o, o.pos);
8180

@@ -140,7 +139,6 @@ Shader "Maps SDK/Standard Clipping Volume"
140139
struct appdata
141140
{
142141
float4 vertex : POSITION;
143-
float2 uv: TEXCOORD;
144142
float3 normal : NORMAL;
145143
UNITY_VERTEX_INPUT_INSTANCE_ID
146144
};
@@ -184,4 +182,4 @@ Shader "Maps SDK/Standard Clipping Volume"
184182
ENDCG
185183
}
186184
}
187-
}
185+
}

SupportingScripts/Runtime/Shaders/StandardTerrainShader-MapsSDK.shader

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,6 @@
33

44
Shader "Maps SDK/Standard Terrain"
55
{
6-
Properties
7-
{
8-
_Color("Color", Color) = (1,1,1,1)
9-
_MainTex0("Albedo (RGB)", 2D) = "white" {}
10-
_MainTex1("Color", Color) = (1,1,1,1)
11-
_MainTex2("Color", Color) = (1,1,1,1)
12-
_MainTex3("Color", Color) = (1,1,1,1)
13-
}
14-
156
SubShader
167
{
178
Pass
@@ -83,7 +74,6 @@ Shader "Maps SDK/Standard Terrain"
8374
UNITY_SETUP_INSTANCE_ID(v);
8475

8576
v2f o;
86-
8777
UNITY_INITIALIZE_OUTPUT(v2f, o);
8878
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
8979

@@ -104,10 +94,10 @@ Shader "Maps SDK/Standard Terrain"
10494
#endif
10595

10696
o.pos = UnityObjectToClipPos(v.vertex);
107-
if (_MainTexCount > 0) { o.uv = _TexScaleAndOffset[0].x * v.uv + _TexScaleAndOffset[0].yz; }
108-
if (_MainTexCount > 1) { o.uv2 = _TexScaleAndOffset[1].x * v.uv + _TexScaleAndOffset[1].yz; }
109-
if (_MainTexCount > 2) { o.uv3 = _TexScaleAndOffset[2].x * v.uv + _TexScaleAndOffset[2].yz; }
110-
if (_MainTexCount > 3) { o.uv4 = _TexScaleAndOffset[3].x * v.uv + _TexScaleAndOffset[3].yz; }
97+
if (_MainTexCount > 0) { o.uv = _TexScaleAndOffset[0].x * v.uv.xy + _TexScaleAndOffset[0].yz; }
98+
if (_MainTexCount > 1) { o.uv2 = _TexScaleAndOffset[1].x * v.uv.xy + _TexScaleAndOffset[1].yz; }
99+
if (_MainTexCount > 2) { o.uv3 = _TexScaleAndOffset[2].x * v.uv.xy + _TexScaleAndOffset[2].yz; }
100+
if (_MainTexCount > 3) { o.uv4 = _TexScaleAndOffset[3].x * v.uv.xy + _TexScaleAndOffset[3].yz; }
111101

112102
float3 worldPosition = mul(unity_ObjectToWorld, float4(v.vertex.xyz, 1.0)).xyz;
113103
o.worldPosition = worldPosition;
@@ -136,7 +126,6 @@ Shader "Maps SDK/Standard Terrain"
136126
if (_MainTexCount > 1) { color = blend(color, tex2D(_MainTex1, i.uv2)); }
137127
if (_MainTexCount > 2) { color = blend(color, tex2D(_MainTex2, i.uv3)); }
138128
if (_MainTexCount > 3) { color = blend(color, tex2D(_MainTex3, i.uv4)); }
139-
color *= _Color;
140129

141130
// Apply contours.
142131
#if ENABLE_ELEVATION_TEXTURE && ENABLE_CONTOUR_LINES
@@ -204,6 +193,13 @@ Shader "Maps SDK/Standard Terrain"
204193
{
205194
UNITY_SETUP_INSTANCE_ID(v);
206195

196+
v2f o;
197+
UNITY_INITIALIZE_OUTPUT(v2f, o);
198+
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
199+
200+
// Extract skirt indicator from the third item in uv
201+
o.isSkirt = v.uv.z;
202+
207203
#if ENABLE_ELEVATION_TEXTURE
208204
float elevationOffset =
209205
CalculateElevationOffset(
@@ -214,12 +210,8 @@ Shader "Maps SDK/Standard Terrain"
214210
v.vertex.y += elevationOffset;
215211
#endif
216212

217-
v2f o;
218-
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
219-
220213
float3 worldPosition = mul(unity_ObjectToWorld, float4(v.vertex.xyz, 1.0)).xyz;
221214
o.worldPosition = worldPosition;
222-
o.isSkirt = v.uv.z;
223215

224216
TRANSFER_SHADOW_CASTER_NORMALOFFSET(o)
225217

SupportingScripts/version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.10.2
1+
0.11.0

0 commit comments

Comments
 (0)