64 1965 TileGridCell.fs float calculatePixelToMeterFactor(vec4 scaledCenterPos, float screenHeight, mat4 viewMatrix, mat4 projectionMatrix) { vec4 screenPos1 = projectionMatrix * viewMatrix * scaledCenterPos; screenPos1.xy /= abs(screenPos1.w); float distance = abs(screenPos1.w) / 20.0; vec4 position2 = viewMatrix * scaledCenterPos; position2.y += distance; vec4 screenPos2 = projectionMatrix * position2; screenPos2.xy /= abs(screenPos2.w); vec2 screenDiff = screenPos1.xy - screenPos2.xy; float screenDistance = length(screenDiff); float screenToView = 2.0 / screenHeight; float pixelDistance = screenDistance / screenToView; return distance / pixelDistance; } float edgeAntiAliasing(float distance, float edge) { float halfPixel = 0.5; return smoothstep(edge - halfPixel, edge + halfPixel, distance); } vec4 antiAliasedBorder(float distance, float borderStart, float borderEnd, vec4 mainColor, vec4 borderColor) { float alphaBorder = edgeAntiAliasing(distance, borderStart); float alphaOutside = edgeAntiAliasing(distance, borderEnd); vec4 col = mix(mainColor, borderColor, alphaBorder); col = mix(col, vec4(borderColor.rgb, 0), alphaOutside); return col; } vec4 unitBoxVertex(vec4 pos) { pos.xyz = normalize(pos.xyz) * 1.4142; return pos; } uniform vec4 mainColor; uniform float gridSize; varying vec2 _uv; varying float transitionAlpha; varying float pixelToMeterFactor; void main() { float distanceFromCenter = sqrt(_uv.x * _uv.x / 2.0 + _uv.y * _uv.y / 2.0); float distanceFromCenterPixels = distanceFromCenter * gridSize / pixelToMeterFactor; float expandValue = transitionAlpha; float fillAmountPixels = expandValue * gridSize / pixelToMeterFactor; vec4 fillColor = mainColor * transitionAlpha; gl_FragColor = antiAliasedBorder(distanceFromCenterPixels, 0.0, fillAmountPixels, fillColor, fillColor); } 2252 TileGrid.fs float calculatePixelToMeterFactor(vec4 scaledCenterPos, float screenHeight, mat4 viewMatrix, mat4 projectionMatrix) { vec4 screenPos1 = projectionMatrix * viewMatrix * scaledCenterPos; screenPos1.xy /= abs(screenPos1.w); float distance = abs(screenPos1.w) / 20.0; vec4 position2 = viewMatrix * scaledCenterPos; position2.y += distance; vec4 screenPos2 = projectionMatrix * position2; screenPos2.xy /= abs(screenPos2.w); vec2 screenDiff = screenPos1.xy - screenPos2.xy; float screenDistance = length(screenDiff); float screenToView = 2.0 / screenHeight; float pixelDistance = screenDistance / screenToView; return distance / pixelDistance; } float edgeAntiAliasing(float distance, float edge) { float halfPixel = 0.5; return smoothstep(edge - halfPixel, edge + halfPixel, distance); } vec4 antiAliasedBorder(float distance, float borderStart, float borderEnd, vec4 mainColor, vec4 borderColor) { float alphaBorder = edgeAntiAliasing(distance, borderStart); float alphaOutside = edgeAntiAliasing(distance, borderEnd); vec4 col = mix(mainColor, borderColor, alphaBorder); col = mix(col, vec4(borderColor.rgb, 0), alphaOutside); return col; } vec4 unitBoxVertex(vec4 pos) { pos.xyz = normalize(pos.xyz) * 1.4142; return pos; } uniform vec4 mainColor; uniform float gridSize; uniform float dashLength; uniform float dashWidthPixels; varying vec2 gridPosition; varying float pixelToMeterFactor; void main() { float x = gridPosition.x; float y = gridPosition.y; float cellX = x - (gridSize * floor(x / gridSize)); float cellY = y - (gridSize * floor(y / gridSize)); cellX = min(cellX, gridSize - cellX); cellY = min(cellY, gridSize - cellY); float distanceToEdge = min(cellX, cellY); float phase = max(cellX, cellY); float dashPhase = phase - (dashLength * floor(phase / dashLength)); dashPhase = min(dashPhase, dashLength - dashPhase) - 0.25 * dashLength + dashWidthPixels; float distanceToEdgePixels = max(distanceToEdge / pixelToMeterFactor, dashPhase); gl_FragColor = antiAliasedBorder(distanceToEdgePixels, 0.0, dashWidthPixels, mainColor, mainColor); } 267 Skybox.fs uniform sampler2D textureLow; uniform sampler2D textureHigh; varying vec2 vUvLow; varying vec2 vUvHigh; varying float vSkyColorFactor; void main() { gl_FragColor = mix(texture2D(textureHigh, vUvHigh), texture2D(textureLow, vUvLow), vSkyColorFactor); } 2069 TileGridCell.vs float calculatePixelToMeterFactor(vec4 scaledCenterPos, float screenHeight, mat4 viewMatrix, mat4 projectionMatrix) { vec4 screenPos1 = projectionMatrix * viewMatrix * scaledCenterPos; screenPos1.xy /= abs(screenPos1.w); float distance = abs(screenPos1.w) / 20.0; vec4 position2 = viewMatrix * scaledCenterPos; position2.y += distance; vec4 screenPos2 = projectionMatrix * position2; screenPos2.xy /= abs(screenPos2.w); vec2 screenDiff = screenPos1.xy - screenPos2.xy; float screenDistance = length(screenDiff); float screenToView = 2.0 / screenHeight; float pixelDistance = screenDistance / screenToView; return distance / pixelDistance; } float edgeAntiAliasing(float distance, float edge) { float halfPixel = 0.5; return smoothstep(edge - halfPixel, edge + halfPixel, distance); } vec4 antiAliasedBorder(float distance, float borderStart, float borderEnd, vec4 mainColor, vec4 borderColor) { float alphaBorder = edgeAntiAliasing(distance, borderStart); float alphaOutside = edgeAntiAliasing(distance, borderEnd); vec4 col = mix(mainColor, borderColor, alphaBorder); col = mix(col, vec4(borderColor.rgb, 0), alphaOutside); return col; } vec4 unitBoxVertex(vec4 pos) { pos.xyz = normalize(pos.xyz) * 1.4142; return pos; } mat3 mat4ToMat3(mat4 m) { return mat3(m[0].xyz, m[1].xyz, m[2].xyz); } uniform float screenHeight; uniform float currentTime; varying vec2 _uv; varying float transitionAlpha; varying float pixelToMeterFactor; float transitionAlphaFunction(float x, float a, float b, float c) { float y = a * (x - b) + c; return clamp(y, 0.0, 1.0); } void main() { gl_Position = projectionMatrix * modelViewMatrix * position; pixelToMeterFactor = calculatePixelToMeterFactor(modelMatrix * position, screenHeight, viewMatrix, projectionMatrix); transitionAlpha = transitionAlphaFunction(currentTime, normal.x, normal.y, normal.z); _uv = uv0; } 1831 TileGrid.vs float calculatePixelToMeterFactor(vec4 scaledCenterPos, float screenHeight, mat4 viewMatrix, mat4 projectionMatrix) { vec4 screenPos1 = projectionMatrix * viewMatrix * scaledCenterPos; screenPos1.xy /= abs(screenPos1.w); float distance = abs(screenPos1.w) / 20.0; vec4 position2 = viewMatrix * scaledCenterPos; position2.y += distance; vec4 screenPos2 = projectionMatrix * position2; screenPos2.xy /= abs(screenPos2.w); vec2 screenDiff = screenPos1.xy - screenPos2.xy; float screenDistance = length(screenDiff); float screenToView = 2.0 / screenHeight; float pixelDistance = screenDistance / screenToView; return distance / pixelDistance; } float edgeAntiAliasing(float distance, float edge) { float halfPixel = 0.5; return smoothstep(edge - halfPixel, edge + halfPixel, distance); } vec4 antiAliasedBorder(float distance, float borderStart, float borderEnd, vec4 mainColor, vec4 borderColor) { float alphaBorder = edgeAntiAliasing(distance, borderStart); float alphaOutside = edgeAntiAliasing(distance, borderEnd); vec4 col = mix(mainColor, borderColor, alphaBorder); col = mix(col, vec4(borderColor.rgb, 0), alphaOutside); return col; } vec4 unitBoxVertex(vec4 pos) { pos.xyz = normalize(pos.xyz) * 1.4142; return pos; } mat3 mat4ToMat3(mat4 m) { return mat3(m[0].xyz, m[1].xyz, m[2].xyz); } uniform float screenHeight; varying vec2 gridPosition; varying float pixelToMeterFactor; void main() { gl_Position = projectionMatrix * modelViewMatrix * position; pixelToMeterFactor = calculatePixelToMeterFactor(modelMatrix * position, screenHeight, viewMatrix, projectionMatrix); gridPosition = (modelMatrix * position).xy; } 3228 Skybox.vs const int kSC_SymbolCullingDistanceFactor = 4; const int kSC_OSMTileCullingDistanceFactor = 4; const float kSC_MapboxZoomLevelOffset = 0.7; const int kSC_UseOSMDataFromAncestorDiff = 1; const int kSC_MaxOSMLevelFromServer = 15; const float kSC_Skybox_MinVisibleDistance = 500000.0; const float kSC_Skybox_Height = 1000000.0; const float kSC_UserMarker_OuterCircleRadius = 12.0; const int kSC_MaxBoundingBoxesPerTopoLayer = 16; const float kSC_CameraFOV = 42.0; const float kSC_ElevationExaggerationMinHeightRange = 200.0; const float kSC_ElevationExaggerationMinHeightRangeFactor = 1.9; const float kSC_ElevationExaggerationMaxHeightRange = 2000.0; const float kSC_ElevationExaggerationMaxHeightRangeFactor = 1.15; const float kSC_FlatModeExaggeration = 0.1; const float kHazeAltitudeFadeoff = 100000.0; const float kHazeDistancePowerLow = 0.8; const float kHazeDistancePowerHigh = 0.8; vec4 kHazeColorLow0 = vec4(0.67, 0.80, 0.94, 0.95); vec4 kHazeColorLow1 = vec4(0.77, 0.87, 0.94, 0.0); vec4 kHazeColorHigh0 = vec4(0.81, 0.79, 0.80, 0.95); vec4 kHazeColorHigh1 = vec4(0.64, 0.75, 0.82, 0.0); float calculateVisibleDistance(float cameraPositionZ) { float cameraAltitude = max(1.0, cameraPositionZ); float radius = 6367444.65712; float visibleDistance = sqrt((radius + cameraAltitude) * (radius + cameraAltitude) - radius * radius); visibleDistance = max(kSC_Skybox_MinVisibleDistance, visibleDistance); visibleDistance += max(0.0, (cameraPositionZ - kSC_Skybox_Height / 2.0) * 10.0); return visibleDistance; } float calculateHazeAltitudeFactor(float altitude) { return exp(-altitude / kHazeAltitudeFadeoff); } float calculateHazeDistanceFactor(float vertexDistance, float visibleDistance, float powerFactor) { vertexDistance = min(vertexDistance, visibleDistance); return smoothstep(0.0, 1.0, pow(vertexDistance / visibleDistance, powerFactor)); } vec4 calculateHaze(vec3 vertexWorldPos, vec3 cameraPosition) { vec3 dir = vertexWorldPos - cameraPosition; float visibleDistance = calculateVisibleDistance(cameraPosition.z); float vertexDistance = length(dir.xy); float altitudeFactor = calculateHazeAltitudeFactor(cameraPosition.z); float vertexDistanceLow = visibleDistance / mix(1.0, 2.5, altitudeFactor); vec4 hazeColor = mix( mix(kHazeColorHigh1, kHazeColorHigh0, calculateHazeDistanceFactor(vertexDistance, visibleDistance, kHazeDistancePowerHigh)), mix(kHazeColorLow1, kHazeColorLow0, calculateHazeDistanceFactor(vertexDistance, vertexDistanceLow, kHazeDistancePowerLow)), altitudeFactor ); return hazeColor; } mat3 mat4ToMat3(mat4 m) { return mat3(m[0].xyz, m[1].xyz, m[2].xyz); } varying vec2 vUvLow; varying vec2 vUvHigh; varying float vSkyColorFactor; void main() { vec4 worldPosition = modelMatrix * vec4(position, 1.0); vSkyColorFactor = calculateHazeAltitudeFactor(cameraPosition.z); const float textureHeight = 90000.0; vUvHigh = vec2(uv.x, 1.0 - worldPosition.z / textureHeight); vUvLow = vec2(uv.x, 1.0 - worldPosition.z / textureHeight / mix(2.0, 3.0, vSkyColorFactor)); gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); } 335 Terrain/TerrainVectormap.fs varying vec2 vUv; uniform sampler2D _TopoTex; uniform float tileOutlineWidth; void main() { vec3 terrainColor = texture2D(_TopoTex, vUv).rgb; if (tileOutlineWidth > 0.0) { if (vUv.x < 0.05) terrainColor.r = 0.7; if (vUv.y < 0.05) terrainColor.r = 0.7; } gl_FragColor = vec4(terrainColor, 1.0); } 5644 Terrain/Terrain-DEFAULT-NONE.vs mat3 mat4ToMat3(mat4 m) { return mat3(m[0].xyz, m[1].xyz, m[2].xyz); } const int kSC_SymbolCullingDistanceFactor = 4; const int kSC_OSMTileCullingDistanceFactor = 4; const float kSC_MapboxZoomLevelOffset = 0.7; const int kSC_UseOSMDataFromAncestorDiff = 1; const int kSC_MaxOSMLevelFromServer = 15; const float kSC_Skybox_MinVisibleDistance = 500000.0; const float kSC_Skybox_Height = 1000000.0; const float kSC_UserMarker_OuterCircleRadius = 12.0; const int kSC_MaxBoundingBoxesPerTopoLayer = 16; const float kSC_CameraFOV = 42.0; const float kSC_ElevationExaggerationMinHeightRange = 200.0; const float kSC_ElevationExaggerationMinHeightRangeFactor = 1.9; const float kSC_ElevationExaggerationMaxHeightRange = 2000.0; const float kSC_ElevationExaggerationMaxHeightRangeFactor = 1.15; const float kSC_FlatModeExaggeration = 0.1; uniform float mercatorScale; uniform float elevationExaggerationFactor; vec4 upScalePoint(vec4 point, mat4 modelMatrix) { vec4 scaledPoint = point; float offsetZ = modelMatrix[3][2]; scaledPoint.z = (scaledPoint.z + offsetZ) * mercatorScale * elevationExaggerationFactor - offsetZ; return scaledPoint; } vec4 upScalePoint(vec4 vec) { vec4 scaledVec = vec; scaledVec.z *= mercatorScale * elevationExaggerationFactor; return scaledVec; } vec3 _applyScaleOnNormal(vec3 vec, float scale) { vec3 scaledVec = vec; scaledVec.xy *= scale; return normalize(scaledVec); } vec3 applyElevationScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale * elevationExaggerationFactor); } vec3 applyMercatorScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale); } vec3 rgb2hsv(vec3 c) { vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); float d = q.x - min(q.w, q.y); float e = 1.0e-10; return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); } vec3 hsv2rgb(vec3 c) { vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); } const float PI = 3.14159265359; const float halfPI = PI * 0.5; const float doublePI = PI * 2.0; uniform int loadState; varying vec2 vUv; varying vec4 vHazeColor; varying vec2 vGeneratedUv; varying float vDistanceAlpha; varying vec2 vGradientUv; const float kHazeAltitudeFadeoff = 100000.0; const float kHazeDistancePowerLow = 0.8; const float kHazeDistancePowerHigh = 0.8; vec4 kHazeColorLow0 = vec4(0.67, 0.80, 0.94, 0.95); vec4 kHazeColorLow1 = vec4(0.77, 0.87, 0.94, 0.0); vec4 kHazeColorHigh0 = vec4(0.81, 0.79, 0.80, 0.95); vec4 kHazeColorHigh1 = vec4(0.64, 0.75, 0.82, 0.0); float calculateVisibleDistance(float cameraPositionZ) { float cameraAltitude = max(1.0, cameraPositionZ); float radius = 6367444.65712; float visibleDistance = sqrt((radius + cameraAltitude) * (radius + cameraAltitude) - radius * radius); visibleDistance = max(kSC_Skybox_MinVisibleDistance, visibleDistance); visibleDistance += max(0.0, (cameraPositionZ - kSC_Skybox_Height / 2.0) * 10.0); return visibleDistance; } float calculateHazeAltitudeFactor(float altitude) { return exp(-altitude / kHazeAltitudeFadeoff); } float calculateHazeDistanceFactor(float vertexDistance, float visibleDistance, float powerFactor) { vertexDistance = min(vertexDistance, visibleDistance); return smoothstep(0.0, 1.0, pow(vertexDistance / visibleDistance, powerFactor)); } vec4 calculateHaze(vec3 vertexWorldPos, vec3 cameraPosition) { vec3 dir = vertexWorldPos - cameraPosition; float visibleDistance = calculateVisibleDistance(cameraPosition.z); float vertexDistance = length(dir.xy); float altitudeFactor = calculateHazeAltitudeFactor(cameraPosition.z); float vertexDistanceLow = visibleDistance / mix(1.0, 2.5, altitudeFactor); vec4 hazeColor = mix( mix(kHazeColorHigh1, kHazeColorHigh0, calculateHazeDistanceFactor(vertexDistance, visibleDistance, kHazeDistancePowerHigh)), mix(kHazeColorLow1, kHazeColorLow0, calculateHazeDistanceFactor(vertexDistance, vertexDistanceLow, kHazeDistancePowerLow)), altitudeFactor ); return hazeColor; } uniform float averageDepth; float getDistanceAlpha(float vertexDistance) { float fadeStart = averageDepth * 1.0; float fadeEnd = averageDepth * 10.0; float distanceAlpha = 1.0 - (vertexDistance - fadeStart) / (fadeEnd - fadeStart); distanceAlpha = clamp(distanceAlpha, 0.0, 1.0); return distanceAlpha; } uniform vec4 _MainTexTransform; uniform vec4 _GradientTransform; uniform vec4 _SecondaryTexTransform; uniform vec4 _GeneratedTexTransform; uniform vec4 _TopoTransform; vec2 CalculateUV(vec4 ipos, vec4 texTransform) { return (ipos.xy - texTransform.xy) / texTransform.zw; } vec4 calc_vertex_pos(vec2 _uv) { vec3 outPos = vec4(position, 1.0).xyz; vUv = CalculateUV(vec4(outPos, 1.0), _MainTexTransform); vGradientUv = CalculateUV(vec4(outPos, 1.0), _GradientTransform); vec4 scaledPosition = upScalePoint(vec4(position, 1.0)); { vec3 vertexWorldPos = (modelMatrix * scaledPosition).xyz; vHazeColor = calculateHaze(vertexWorldPos, cameraPosition); } vec4 _position = projectionMatrix * modelViewMatrix * scaledPosition; vGeneratedUv = CalculateUV(vec4(outPos, 1.0), _GeneratedTexTransform); vDistanceAlpha = getDistanceAlpha(_position.w); return _position; } void main() { gl_Position = calc_vertex_pos(uv); } 6415 Terrain/Terrain-DEFAULT-ALTITUDE.vs mat3 mat4ToMat3(mat4 m) { return mat3(m[0].xyz, m[1].xyz, m[2].xyz); } const int kSC_SymbolCullingDistanceFactor = 4; const int kSC_OSMTileCullingDistanceFactor = 4; const float kSC_MapboxZoomLevelOffset = 0.7; const int kSC_UseOSMDataFromAncestorDiff = 1; const int kSC_MaxOSMLevelFromServer = 15; const float kSC_Skybox_MinVisibleDistance = 500000.0; const float kSC_Skybox_Height = 1000000.0; const float kSC_UserMarker_OuterCircleRadius = 12.0; const int kSC_MaxBoundingBoxesPerTopoLayer = 16; const float kSC_CameraFOV = 42.0; const float kSC_ElevationExaggerationMinHeightRange = 200.0; const float kSC_ElevationExaggerationMinHeightRangeFactor = 1.9; const float kSC_ElevationExaggerationMaxHeightRange = 2000.0; const float kSC_ElevationExaggerationMaxHeightRangeFactor = 1.15; const float kSC_FlatModeExaggeration = 0.1; uniform float mercatorScale; uniform float elevationExaggerationFactor; vec4 upScalePoint(vec4 point, mat4 modelMatrix) { vec4 scaledPoint = point; float offsetZ = modelMatrix[3][2]; scaledPoint.z = (scaledPoint.z + offsetZ) * mercatorScale * elevationExaggerationFactor - offsetZ; return scaledPoint; } vec4 upScalePoint(vec4 vec) { vec4 scaledVec = vec; scaledVec.z *= mercatorScale * elevationExaggerationFactor; return scaledVec; } vec3 _applyScaleOnNormal(vec3 vec, float scale) { vec3 scaledVec = vec; scaledVec.xy *= scale; return normalize(scaledVec); } vec3 applyElevationScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale * elevationExaggerationFactor); } vec3 applyMercatorScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale); } vec3 rgb2hsv(vec3 c) { vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); float d = q.x - min(q.w, q.y); float e = 1.0e-10; return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); } vec3 hsv2rgb(vec3 c) { vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); } const float PI = 3.14159265359; const float halfPI = PI * 0.5; const float doublePI = PI * 2.0; uniform int loadState; varying vec2 vUv; varying vec4 vHazeColor; varying vec2 vGeneratedUv; varying float vDistanceAlpha; varying float vDepth; varying vec3 vPosition; varying float vLineWidthFactor; varying vec2 vGradientUv; varying vec3 vScaledNormal; const float kHazeAltitudeFadeoff = 100000.0; const float kHazeDistancePowerLow = 0.8; const float kHazeDistancePowerHigh = 0.8; vec4 kHazeColorLow0 = vec4(0.67, 0.80, 0.94, 0.95); vec4 kHazeColorLow1 = vec4(0.77, 0.87, 0.94, 0.0); vec4 kHazeColorHigh0 = vec4(0.81, 0.79, 0.80, 0.95); vec4 kHazeColorHigh1 = vec4(0.64, 0.75, 0.82, 0.0); float calculateVisibleDistance(float cameraPositionZ) { float cameraAltitude = max(1.0, cameraPositionZ); float radius = 6367444.65712; float visibleDistance = sqrt((radius + cameraAltitude) * (radius + cameraAltitude) - radius * radius); visibleDistance = max(kSC_Skybox_MinVisibleDistance, visibleDistance); visibleDistance += max(0.0, (cameraPositionZ - kSC_Skybox_Height / 2.0) * 10.0); return visibleDistance; } float calculateHazeAltitudeFactor(float altitude) { return exp(-altitude / kHazeAltitudeFadeoff); } float calculateHazeDistanceFactor(float vertexDistance, float visibleDistance, float powerFactor) { vertexDistance = min(vertexDistance, visibleDistance); return smoothstep(0.0, 1.0, pow(vertexDistance / visibleDistance, powerFactor)); } vec4 calculateHaze(vec3 vertexWorldPos, vec3 cameraPosition) { vec3 dir = vertexWorldPos - cameraPosition; float visibleDistance = calculateVisibleDistance(cameraPosition.z); float vertexDistance = length(dir.xy); float altitudeFactor = calculateHazeAltitudeFactor(cameraPosition.z); float vertexDistanceLow = visibleDistance / mix(1.0, 2.5, altitudeFactor); vec4 hazeColor = mix( mix(kHazeColorHigh1, kHazeColorHigh0, calculateHazeDistanceFactor(vertexDistance, visibleDistance, kHazeDistancePowerHigh)), mix(kHazeColorLow1, kHazeColorLow0, calculateHazeDistanceFactor(vertexDistance, vertexDistanceLow, kHazeDistancePowerLow)), altitudeFactor ); return hazeColor; } uniform float averageDepth; float getDistanceAlpha(float vertexDistance) { float fadeStart = averageDepth * 1.0; float fadeEnd = averageDepth * 10.0; float distanceAlpha = 1.0 - (vertexDistance - fadeStart) / (fadeEnd - fadeStart); distanceAlpha = clamp(distanceAlpha, 0.0, 1.0); return distanceAlpha; } uniform vec4 _MainTexTransform; uniform vec4 _GradientTransform; uniform vec4 _SecondaryTexTransform; uniform vec4 _GeneratedTexTransform; uniform vec4 _TopoTransform; vec2 CalculateUV(vec4 ipos, vec4 texTransform) { return (ipos.xy - texTransform.xy) / texTransform.zw; } vec4 calc_vertex_pos(vec2 _uv) { vScaledNormal = applyElevationScaleOnNormal(normal); vec3 outPos = vec4(position, 1.0).xyz; vPosition = outPos; vUv = CalculateUV(vec4(outPos, 1.0), _MainTexTransform); vGradientUv = CalculateUV(vec4(outPos, 1.0), _GradientTransform); vec4 scaledPosition = upScalePoint(vec4(position, 1.0)); { vec3 vertexWorldPos = (modelMatrix * scaledPosition).xyz; vHazeColor = calculateHaze(vertexWorldPos, cameraPosition); } vec4 _position = projectionMatrix * modelViewMatrix * scaledPosition; vec3 up = vec3(0, 0, 1); vec3 tangent = cross(vScaledNormal, up); vec3 binormal = cross(tangent, vScaledNormal); binormal = length(binormal) > 0.01 ? binormal : vec3(0, 1, 0.001); binormal /= binormal.z; vec4 wp1 = _position; vec4 wp2 = projectionMatrix * modelViewMatrix * (scaledPosition + vec4(binormal, 0.0)); vec2 ll = wp1.xy / wp1.w - wp2.xy / wp2.w; float aspect = projectionMatrix[1][1] / projectionMatrix[0][0]; ll.x *= aspect; vLineWidthFactor = length(ll) * mercatorScale * elevationExaggerationFactor; vDepth = _position.w; vGeneratedUv = CalculateUV(vec4(outPos, 1.0), _GeneratedTexTransform); vDistanceAlpha = getDistanceAlpha(_position.w); return _position; } void main() { gl_Position = calc_vertex_pos(uv); } 5644 Terrain/Terrain-DEFAULT-ASPECT.vs mat3 mat4ToMat3(mat4 m) { return mat3(m[0].xyz, m[1].xyz, m[2].xyz); } const int kSC_SymbolCullingDistanceFactor = 4; const int kSC_OSMTileCullingDistanceFactor = 4; const float kSC_MapboxZoomLevelOffset = 0.7; const int kSC_UseOSMDataFromAncestorDiff = 1; const int kSC_MaxOSMLevelFromServer = 15; const float kSC_Skybox_MinVisibleDistance = 500000.0; const float kSC_Skybox_Height = 1000000.0; const float kSC_UserMarker_OuterCircleRadius = 12.0; const int kSC_MaxBoundingBoxesPerTopoLayer = 16; const float kSC_CameraFOV = 42.0; const float kSC_ElevationExaggerationMinHeightRange = 200.0; const float kSC_ElevationExaggerationMinHeightRangeFactor = 1.9; const float kSC_ElevationExaggerationMaxHeightRange = 2000.0; const float kSC_ElevationExaggerationMaxHeightRangeFactor = 1.15; const float kSC_FlatModeExaggeration = 0.1; uniform float mercatorScale; uniform float elevationExaggerationFactor; vec4 upScalePoint(vec4 point, mat4 modelMatrix) { vec4 scaledPoint = point; float offsetZ = modelMatrix[3][2]; scaledPoint.z = (scaledPoint.z + offsetZ) * mercatorScale * elevationExaggerationFactor - offsetZ; return scaledPoint; } vec4 upScalePoint(vec4 vec) { vec4 scaledVec = vec; scaledVec.z *= mercatorScale * elevationExaggerationFactor; return scaledVec; } vec3 _applyScaleOnNormal(vec3 vec, float scale) { vec3 scaledVec = vec; scaledVec.xy *= scale; return normalize(scaledVec); } vec3 applyElevationScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale * elevationExaggerationFactor); } vec3 applyMercatorScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale); } vec3 rgb2hsv(vec3 c) { vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); float d = q.x - min(q.w, q.y); float e = 1.0e-10; return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); } vec3 hsv2rgb(vec3 c) { vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); } const float PI = 3.14159265359; const float halfPI = PI * 0.5; const float doublePI = PI * 2.0; uniform int loadState; varying vec2 vUv; varying vec4 vHazeColor; varying vec2 vGeneratedUv; varying float vDistanceAlpha; varying vec2 vGradientUv; const float kHazeAltitudeFadeoff = 100000.0; const float kHazeDistancePowerLow = 0.8; const float kHazeDistancePowerHigh = 0.8; vec4 kHazeColorLow0 = vec4(0.67, 0.80, 0.94, 0.95); vec4 kHazeColorLow1 = vec4(0.77, 0.87, 0.94, 0.0); vec4 kHazeColorHigh0 = vec4(0.81, 0.79, 0.80, 0.95); vec4 kHazeColorHigh1 = vec4(0.64, 0.75, 0.82, 0.0); float calculateVisibleDistance(float cameraPositionZ) { float cameraAltitude = max(1.0, cameraPositionZ); float radius = 6367444.65712; float visibleDistance = sqrt((radius + cameraAltitude) * (radius + cameraAltitude) - radius * radius); visibleDistance = max(kSC_Skybox_MinVisibleDistance, visibleDistance); visibleDistance += max(0.0, (cameraPositionZ - kSC_Skybox_Height / 2.0) * 10.0); return visibleDistance; } float calculateHazeAltitudeFactor(float altitude) { return exp(-altitude / kHazeAltitudeFadeoff); } float calculateHazeDistanceFactor(float vertexDistance, float visibleDistance, float powerFactor) { vertexDistance = min(vertexDistance, visibleDistance); return smoothstep(0.0, 1.0, pow(vertexDistance / visibleDistance, powerFactor)); } vec4 calculateHaze(vec3 vertexWorldPos, vec3 cameraPosition) { vec3 dir = vertexWorldPos - cameraPosition; float visibleDistance = calculateVisibleDistance(cameraPosition.z); float vertexDistance = length(dir.xy); float altitudeFactor = calculateHazeAltitudeFactor(cameraPosition.z); float vertexDistanceLow = visibleDistance / mix(1.0, 2.5, altitudeFactor); vec4 hazeColor = mix( mix(kHazeColorHigh1, kHazeColorHigh0, calculateHazeDistanceFactor(vertexDistance, visibleDistance, kHazeDistancePowerHigh)), mix(kHazeColorLow1, kHazeColorLow0, calculateHazeDistanceFactor(vertexDistance, vertexDistanceLow, kHazeDistancePowerLow)), altitudeFactor ); return hazeColor; } uniform float averageDepth; float getDistanceAlpha(float vertexDistance) { float fadeStart = averageDepth * 1.0; float fadeEnd = averageDepth * 10.0; float distanceAlpha = 1.0 - (vertexDistance - fadeStart) / (fadeEnd - fadeStart); distanceAlpha = clamp(distanceAlpha, 0.0, 1.0); return distanceAlpha; } uniform vec4 _MainTexTransform; uniform vec4 _GradientTransform; uniform vec4 _SecondaryTexTransform; uniform vec4 _GeneratedTexTransform; uniform vec4 _TopoTransform; vec2 CalculateUV(vec4 ipos, vec4 texTransform) { return (ipos.xy - texTransform.xy) / texTransform.zw; } vec4 calc_vertex_pos(vec2 _uv) { vec3 outPos = vec4(position, 1.0).xyz; vUv = CalculateUV(vec4(outPos, 1.0), _MainTexTransform); vGradientUv = CalculateUV(vec4(outPos, 1.0), _GradientTransform); vec4 scaledPosition = upScalePoint(vec4(position, 1.0)); { vec3 vertexWorldPos = (modelMatrix * scaledPosition).xyz; vHazeColor = calculateHaze(vertexWorldPos, cameraPosition); } vec4 _position = projectionMatrix * modelViewMatrix * scaledPosition; vGeneratedUv = CalculateUV(vec4(outPos, 1.0), _GeneratedTexTransform); vDistanceAlpha = getDistanceAlpha(_position.w); return _position; } void main() { gl_Position = calc_vertex_pos(uv); } 5692 Terrain/Terrain-DEFAULT-CUSTOM.vs mat3 mat4ToMat3(mat4 m) { return mat3(m[0].xyz, m[1].xyz, m[2].xyz); } const int kSC_SymbolCullingDistanceFactor = 4; const int kSC_OSMTileCullingDistanceFactor = 4; const float kSC_MapboxZoomLevelOffset = 0.7; const int kSC_UseOSMDataFromAncestorDiff = 1; const int kSC_MaxOSMLevelFromServer = 15; const float kSC_Skybox_MinVisibleDistance = 500000.0; const float kSC_Skybox_Height = 1000000.0; const float kSC_UserMarker_OuterCircleRadius = 12.0; const int kSC_MaxBoundingBoxesPerTopoLayer = 16; const float kSC_CameraFOV = 42.0; const float kSC_ElevationExaggerationMinHeightRange = 200.0; const float kSC_ElevationExaggerationMinHeightRangeFactor = 1.9; const float kSC_ElevationExaggerationMaxHeightRange = 2000.0; const float kSC_ElevationExaggerationMaxHeightRangeFactor = 1.15; const float kSC_FlatModeExaggeration = 0.1; uniform float mercatorScale; uniform float elevationExaggerationFactor; vec4 upScalePoint(vec4 point, mat4 modelMatrix) { vec4 scaledPoint = point; float offsetZ = modelMatrix[3][2]; scaledPoint.z = (scaledPoint.z + offsetZ) * mercatorScale * elevationExaggerationFactor - offsetZ; return scaledPoint; } vec4 upScalePoint(vec4 vec) { vec4 scaledVec = vec; scaledVec.z *= mercatorScale * elevationExaggerationFactor; return scaledVec; } vec3 _applyScaleOnNormal(vec3 vec, float scale) { vec3 scaledVec = vec; scaledVec.xy *= scale; return normalize(scaledVec); } vec3 applyElevationScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale * elevationExaggerationFactor); } vec3 applyMercatorScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale); } vec3 rgb2hsv(vec3 c) { vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); float d = q.x - min(q.w, q.y); float e = 1.0e-10; return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); } vec3 hsv2rgb(vec3 c) { vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); } const float PI = 3.14159265359; const float halfPI = PI * 0.5; const float doublePI = PI * 2.0; uniform int loadState; varying vec2 vUv; varying vec4 vHazeColor; varying vec2 vGeneratedUv; varying float vDistanceAlpha; varying vec3 vPosition; varying vec2 vGradientUv; const float kHazeAltitudeFadeoff = 100000.0; const float kHazeDistancePowerLow = 0.8; const float kHazeDistancePowerHigh = 0.8; vec4 kHazeColorLow0 = vec4(0.67, 0.80, 0.94, 0.95); vec4 kHazeColorLow1 = vec4(0.77, 0.87, 0.94, 0.0); vec4 kHazeColorHigh0 = vec4(0.81, 0.79, 0.80, 0.95); vec4 kHazeColorHigh1 = vec4(0.64, 0.75, 0.82, 0.0); float calculateVisibleDistance(float cameraPositionZ) { float cameraAltitude = max(1.0, cameraPositionZ); float radius = 6367444.65712; float visibleDistance = sqrt((radius + cameraAltitude) * (radius + cameraAltitude) - radius * radius); visibleDistance = max(kSC_Skybox_MinVisibleDistance, visibleDistance); visibleDistance += max(0.0, (cameraPositionZ - kSC_Skybox_Height / 2.0) * 10.0); return visibleDistance; } float calculateHazeAltitudeFactor(float altitude) { return exp(-altitude / kHazeAltitudeFadeoff); } float calculateHazeDistanceFactor(float vertexDistance, float visibleDistance, float powerFactor) { vertexDistance = min(vertexDistance, visibleDistance); return smoothstep(0.0, 1.0, pow(vertexDistance / visibleDistance, powerFactor)); } vec4 calculateHaze(vec3 vertexWorldPos, vec3 cameraPosition) { vec3 dir = vertexWorldPos - cameraPosition; float visibleDistance = calculateVisibleDistance(cameraPosition.z); float vertexDistance = length(dir.xy); float altitudeFactor = calculateHazeAltitudeFactor(cameraPosition.z); float vertexDistanceLow = visibleDistance / mix(1.0, 2.5, altitudeFactor); vec4 hazeColor = mix( mix(kHazeColorHigh1, kHazeColorHigh0, calculateHazeDistanceFactor(vertexDistance, visibleDistance, kHazeDistancePowerHigh)), mix(kHazeColorLow1, kHazeColorLow0, calculateHazeDistanceFactor(vertexDistance, vertexDistanceLow, kHazeDistancePowerLow)), altitudeFactor ); return hazeColor; } uniform float averageDepth; float getDistanceAlpha(float vertexDistance) { float fadeStart = averageDepth * 1.0; float fadeEnd = averageDepth * 10.0; float distanceAlpha = 1.0 - (vertexDistance - fadeStart) / (fadeEnd - fadeStart); distanceAlpha = clamp(distanceAlpha, 0.0, 1.0); return distanceAlpha; } uniform vec4 _MainTexTransform; uniform vec4 _GradientTransform; uniform vec4 _SecondaryTexTransform; uniform vec4 _GeneratedTexTransform; uniform vec4 _TopoTransform; vec2 CalculateUV(vec4 ipos, vec4 texTransform) { return (ipos.xy - texTransform.xy) / texTransform.zw; } vec4 calc_vertex_pos(vec2 _uv) { vec3 outPos = vec4(position, 1.0).xyz; vPosition = outPos; vUv = CalculateUV(vec4(outPos, 1.0), _MainTexTransform); vGradientUv = CalculateUV(vec4(outPos, 1.0), _GradientTransform); vec4 scaledPosition = upScalePoint(vec4(position, 1.0)); { vec3 vertexWorldPos = (modelMatrix * scaledPosition).xyz; vHazeColor = calculateHaze(vertexWorldPos, cameraPosition); } vec4 _position = projectionMatrix * modelViewMatrix * scaledPosition; vGeneratedUv = CalculateUV(vec4(outPos, 1.0), _GeneratedTexTransform); vDistanceAlpha = getDistanceAlpha(_position.w); return _position; } void main() { gl_Position = calc_vertex_pos(uv); } 5644 Terrain/Terrain-DEFAULT-GRADIENT.vs mat3 mat4ToMat3(mat4 m) { return mat3(m[0].xyz, m[1].xyz, m[2].xyz); } const int kSC_SymbolCullingDistanceFactor = 4; const int kSC_OSMTileCullingDistanceFactor = 4; const float kSC_MapboxZoomLevelOffset = 0.7; const int kSC_UseOSMDataFromAncestorDiff = 1; const int kSC_MaxOSMLevelFromServer = 15; const float kSC_Skybox_MinVisibleDistance = 500000.0; const float kSC_Skybox_Height = 1000000.0; const float kSC_UserMarker_OuterCircleRadius = 12.0; const int kSC_MaxBoundingBoxesPerTopoLayer = 16; const float kSC_CameraFOV = 42.0; const float kSC_ElevationExaggerationMinHeightRange = 200.0; const float kSC_ElevationExaggerationMinHeightRangeFactor = 1.9; const float kSC_ElevationExaggerationMaxHeightRange = 2000.0; const float kSC_ElevationExaggerationMaxHeightRangeFactor = 1.15; const float kSC_FlatModeExaggeration = 0.1; uniform float mercatorScale; uniform float elevationExaggerationFactor; vec4 upScalePoint(vec4 point, mat4 modelMatrix) { vec4 scaledPoint = point; float offsetZ = modelMatrix[3][2]; scaledPoint.z = (scaledPoint.z + offsetZ) * mercatorScale * elevationExaggerationFactor - offsetZ; return scaledPoint; } vec4 upScalePoint(vec4 vec) { vec4 scaledVec = vec; scaledVec.z *= mercatorScale * elevationExaggerationFactor; return scaledVec; } vec3 _applyScaleOnNormal(vec3 vec, float scale) { vec3 scaledVec = vec; scaledVec.xy *= scale; return normalize(scaledVec); } vec3 applyElevationScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale * elevationExaggerationFactor); } vec3 applyMercatorScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale); } vec3 rgb2hsv(vec3 c) { vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); float d = q.x - min(q.w, q.y); float e = 1.0e-10; return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); } vec3 hsv2rgb(vec3 c) { vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); } const float PI = 3.14159265359; const float halfPI = PI * 0.5; const float doublePI = PI * 2.0; uniform int loadState; varying vec2 vUv; varying vec4 vHazeColor; varying vec2 vGeneratedUv; varying float vDistanceAlpha; varying vec2 vGradientUv; const float kHazeAltitudeFadeoff = 100000.0; const float kHazeDistancePowerLow = 0.8; const float kHazeDistancePowerHigh = 0.8; vec4 kHazeColorLow0 = vec4(0.67, 0.80, 0.94, 0.95); vec4 kHazeColorLow1 = vec4(0.77, 0.87, 0.94, 0.0); vec4 kHazeColorHigh0 = vec4(0.81, 0.79, 0.80, 0.95); vec4 kHazeColorHigh1 = vec4(0.64, 0.75, 0.82, 0.0); float calculateVisibleDistance(float cameraPositionZ) { float cameraAltitude = max(1.0, cameraPositionZ); float radius = 6367444.65712; float visibleDistance = sqrt((radius + cameraAltitude) * (radius + cameraAltitude) - radius * radius); visibleDistance = max(kSC_Skybox_MinVisibleDistance, visibleDistance); visibleDistance += max(0.0, (cameraPositionZ - kSC_Skybox_Height / 2.0) * 10.0); return visibleDistance; } float calculateHazeAltitudeFactor(float altitude) { return exp(-altitude / kHazeAltitudeFadeoff); } float calculateHazeDistanceFactor(float vertexDistance, float visibleDistance, float powerFactor) { vertexDistance = min(vertexDistance, visibleDistance); return smoothstep(0.0, 1.0, pow(vertexDistance / visibleDistance, powerFactor)); } vec4 calculateHaze(vec3 vertexWorldPos, vec3 cameraPosition) { vec3 dir = vertexWorldPos - cameraPosition; float visibleDistance = calculateVisibleDistance(cameraPosition.z); float vertexDistance = length(dir.xy); float altitudeFactor = calculateHazeAltitudeFactor(cameraPosition.z); float vertexDistanceLow = visibleDistance / mix(1.0, 2.5, altitudeFactor); vec4 hazeColor = mix( mix(kHazeColorHigh1, kHazeColorHigh0, calculateHazeDistanceFactor(vertexDistance, visibleDistance, kHazeDistancePowerHigh)), mix(kHazeColorLow1, kHazeColorLow0, calculateHazeDistanceFactor(vertexDistance, vertexDistanceLow, kHazeDistancePowerLow)), altitudeFactor ); return hazeColor; } uniform float averageDepth; float getDistanceAlpha(float vertexDistance) { float fadeStart = averageDepth * 1.0; float fadeEnd = averageDepth * 10.0; float distanceAlpha = 1.0 - (vertexDistance - fadeStart) / (fadeEnd - fadeStart); distanceAlpha = clamp(distanceAlpha, 0.0, 1.0); return distanceAlpha; } uniform vec4 _MainTexTransform; uniform vec4 _GradientTransform; uniform vec4 _SecondaryTexTransform; uniform vec4 _GeneratedTexTransform; uniform vec4 _TopoTransform; vec2 CalculateUV(vec4 ipos, vec4 texTransform) { return (ipos.xy - texTransform.xy) / texTransform.zw; } vec4 calc_vertex_pos(vec2 _uv) { vec3 outPos = vec4(position, 1.0).xyz; vUv = CalculateUV(vec4(outPos, 1.0), _MainTexTransform); vGradientUv = CalculateUV(vec4(outPos, 1.0), _GradientTransform); vec4 scaledPosition = upScalePoint(vec4(position, 1.0)); { vec3 vertexWorldPos = (modelMatrix * scaledPosition).xyz; vHazeColor = calculateHaze(vertexWorldPos, cameraPosition); } vec4 _position = projectionMatrix * modelViewMatrix * scaledPosition; vGeneratedUv = CalculateUV(vec4(outPos, 1.0), _GeneratedTexTransform); vDistanceAlpha = getDistanceAlpha(_position.w); return _position; } void main() { gl_Position = calc_vertex_pos(uv); } 5644 Terrain/Terrain-DEFAULT-GRADIENT_FLAT.vs mat3 mat4ToMat3(mat4 m) { return mat3(m[0].xyz, m[1].xyz, m[2].xyz); } const int kSC_SymbolCullingDistanceFactor = 4; const int kSC_OSMTileCullingDistanceFactor = 4; const float kSC_MapboxZoomLevelOffset = 0.7; const int kSC_UseOSMDataFromAncestorDiff = 1; const int kSC_MaxOSMLevelFromServer = 15; const float kSC_Skybox_MinVisibleDistance = 500000.0; const float kSC_Skybox_Height = 1000000.0; const float kSC_UserMarker_OuterCircleRadius = 12.0; const int kSC_MaxBoundingBoxesPerTopoLayer = 16; const float kSC_CameraFOV = 42.0; const float kSC_ElevationExaggerationMinHeightRange = 200.0; const float kSC_ElevationExaggerationMinHeightRangeFactor = 1.9; const float kSC_ElevationExaggerationMaxHeightRange = 2000.0; const float kSC_ElevationExaggerationMaxHeightRangeFactor = 1.15; const float kSC_FlatModeExaggeration = 0.1; uniform float mercatorScale; uniform float elevationExaggerationFactor; vec4 upScalePoint(vec4 point, mat4 modelMatrix) { vec4 scaledPoint = point; float offsetZ = modelMatrix[3][2]; scaledPoint.z = (scaledPoint.z + offsetZ) * mercatorScale * elevationExaggerationFactor - offsetZ; return scaledPoint; } vec4 upScalePoint(vec4 vec) { vec4 scaledVec = vec; scaledVec.z *= mercatorScale * elevationExaggerationFactor; return scaledVec; } vec3 _applyScaleOnNormal(vec3 vec, float scale) { vec3 scaledVec = vec; scaledVec.xy *= scale; return normalize(scaledVec); } vec3 applyElevationScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale * elevationExaggerationFactor); } vec3 applyMercatorScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale); } vec3 rgb2hsv(vec3 c) { vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); float d = q.x - min(q.w, q.y); float e = 1.0e-10; return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); } vec3 hsv2rgb(vec3 c) { vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); } const float PI = 3.14159265359; const float halfPI = PI * 0.5; const float doublePI = PI * 2.0; uniform int loadState; varying vec2 vUv; varying vec4 vHazeColor; varying vec2 vGeneratedUv; varying float vDistanceAlpha; varying vec2 vGradientUv; const float kHazeAltitudeFadeoff = 100000.0; const float kHazeDistancePowerLow = 0.8; const float kHazeDistancePowerHigh = 0.8; vec4 kHazeColorLow0 = vec4(0.67, 0.80, 0.94, 0.95); vec4 kHazeColorLow1 = vec4(0.77, 0.87, 0.94, 0.0); vec4 kHazeColorHigh0 = vec4(0.81, 0.79, 0.80, 0.95); vec4 kHazeColorHigh1 = vec4(0.64, 0.75, 0.82, 0.0); float calculateVisibleDistance(float cameraPositionZ) { float cameraAltitude = max(1.0, cameraPositionZ); float radius = 6367444.65712; float visibleDistance = sqrt((radius + cameraAltitude) * (radius + cameraAltitude) - radius * radius); visibleDistance = max(kSC_Skybox_MinVisibleDistance, visibleDistance); visibleDistance += max(0.0, (cameraPositionZ - kSC_Skybox_Height / 2.0) * 10.0); return visibleDistance; } float calculateHazeAltitudeFactor(float altitude) { return exp(-altitude / kHazeAltitudeFadeoff); } float calculateHazeDistanceFactor(float vertexDistance, float visibleDistance, float powerFactor) { vertexDistance = min(vertexDistance, visibleDistance); return smoothstep(0.0, 1.0, pow(vertexDistance / visibleDistance, powerFactor)); } vec4 calculateHaze(vec3 vertexWorldPos, vec3 cameraPosition) { vec3 dir = vertexWorldPos - cameraPosition; float visibleDistance = calculateVisibleDistance(cameraPosition.z); float vertexDistance = length(dir.xy); float altitudeFactor = calculateHazeAltitudeFactor(cameraPosition.z); float vertexDistanceLow = visibleDistance / mix(1.0, 2.5, altitudeFactor); vec4 hazeColor = mix( mix(kHazeColorHigh1, kHazeColorHigh0, calculateHazeDistanceFactor(vertexDistance, visibleDistance, kHazeDistancePowerHigh)), mix(kHazeColorLow1, kHazeColorLow0, calculateHazeDistanceFactor(vertexDistance, vertexDistanceLow, kHazeDistancePowerLow)), altitudeFactor ); return hazeColor; } uniform float averageDepth; float getDistanceAlpha(float vertexDistance) { float fadeStart = averageDepth * 1.0; float fadeEnd = averageDepth * 10.0; float distanceAlpha = 1.0 - (vertexDistance - fadeStart) / (fadeEnd - fadeStart); distanceAlpha = clamp(distanceAlpha, 0.0, 1.0); return distanceAlpha; } uniform vec4 _MainTexTransform; uniform vec4 _GradientTransform; uniform vec4 _SecondaryTexTransform; uniform vec4 _GeneratedTexTransform; uniform vec4 _TopoTransform; vec2 CalculateUV(vec4 ipos, vec4 texTransform) { return (ipos.xy - texTransform.xy) / texTransform.zw; } vec4 calc_vertex_pos(vec2 _uv) { vec3 outPos = vec4(position, 1.0).xyz; vUv = CalculateUV(vec4(outPos, 1.0), _MainTexTransform); vGradientUv = CalculateUV(vec4(outPos, 1.0), _GradientTransform); vec4 scaledPosition = upScalePoint(vec4(position, 1.0)); { vec3 vertexWorldPos = (modelMatrix * scaledPosition).xyz; vHazeColor = calculateHaze(vertexWorldPos, cameraPosition); } vec4 _position = projectionMatrix * modelViewMatrix * scaledPosition; vGeneratedUv = CalculateUV(vec4(outPos, 1.0), _GeneratedTexTransform); vDistanceAlpha = getDistanceAlpha(_position.w); return _position; } void main() { gl_Position = calc_vertex_pos(uv); } 5740 Terrain/Terrain-DEFAULT-GRID.vs mat3 mat4ToMat3(mat4 m) { return mat3(m[0].xyz, m[1].xyz, m[2].xyz); } const int kSC_SymbolCullingDistanceFactor = 4; const int kSC_OSMTileCullingDistanceFactor = 4; const float kSC_MapboxZoomLevelOffset = 0.7; const int kSC_UseOSMDataFromAncestorDiff = 1; const int kSC_MaxOSMLevelFromServer = 15; const float kSC_Skybox_MinVisibleDistance = 500000.0; const float kSC_Skybox_Height = 1000000.0; const float kSC_UserMarker_OuterCircleRadius = 12.0; const int kSC_MaxBoundingBoxesPerTopoLayer = 16; const float kSC_CameraFOV = 42.0; const float kSC_ElevationExaggerationMinHeightRange = 200.0; const float kSC_ElevationExaggerationMinHeightRangeFactor = 1.9; const float kSC_ElevationExaggerationMaxHeightRange = 2000.0; const float kSC_ElevationExaggerationMaxHeightRangeFactor = 1.15; const float kSC_FlatModeExaggeration = 0.1; uniform float mercatorScale; uniform float elevationExaggerationFactor; vec4 upScalePoint(vec4 point, mat4 modelMatrix) { vec4 scaledPoint = point; float offsetZ = modelMatrix[3][2]; scaledPoint.z = (scaledPoint.z + offsetZ) * mercatorScale * elevationExaggerationFactor - offsetZ; return scaledPoint; } vec4 upScalePoint(vec4 vec) { vec4 scaledVec = vec; scaledVec.z *= mercatorScale * elevationExaggerationFactor; return scaledVec; } vec3 _applyScaleOnNormal(vec3 vec, float scale) { vec3 scaledVec = vec; scaledVec.xy *= scale; return normalize(scaledVec); } vec3 applyElevationScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale * elevationExaggerationFactor); } vec3 applyMercatorScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale); } vec3 rgb2hsv(vec3 c) { vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); float d = q.x - min(q.w, q.y); float e = 1.0e-10; return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); } vec3 hsv2rgb(vec3 c) { vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); } const float PI = 3.14159265359; const float halfPI = PI * 0.5; const float doublePI = PI * 2.0; uniform int loadState; varying vec2 vUv; varying vec4 vHazeColor; varying vec2 vGeneratedUv; varying float vDistanceAlpha; varying float vDepth; varying vec3 vPosition; varying vec2 vGradientUv; const float kHazeAltitudeFadeoff = 100000.0; const float kHazeDistancePowerLow = 0.8; const float kHazeDistancePowerHigh = 0.8; vec4 kHazeColorLow0 = vec4(0.67, 0.80, 0.94, 0.95); vec4 kHazeColorLow1 = vec4(0.77, 0.87, 0.94, 0.0); vec4 kHazeColorHigh0 = vec4(0.81, 0.79, 0.80, 0.95); vec4 kHazeColorHigh1 = vec4(0.64, 0.75, 0.82, 0.0); float calculateVisibleDistance(float cameraPositionZ) { float cameraAltitude = max(1.0, cameraPositionZ); float radius = 6367444.65712; float visibleDistance = sqrt((radius + cameraAltitude) * (radius + cameraAltitude) - radius * radius); visibleDistance = max(kSC_Skybox_MinVisibleDistance, visibleDistance); visibleDistance += max(0.0, (cameraPositionZ - kSC_Skybox_Height / 2.0) * 10.0); return visibleDistance; } float calculateHazeAltitudeFactor(float altitude) { return exp(-altitude / kHazeAltitudeFadeoff); } float calculateHazeDistanceFactor(float vertexDistance, float visibleDistance, float powerFactor) { vertexDistance = min(vertexDistance, visibleDistance); return smoothstep(0.0, 1.0, pow(vertexDistance / visibleDistance, powerFactor)); } vec4 calculateHaze(vec3 vertexWorldPos, vec3 cameraPosition) { vec3 dir = vertexWorldPos - cameraPosition; float visibleDistance = calculateVisibleDistance(cameraPosition.z); float vertexDistance = length(dir.xy); float altitudeFactor = calculateHazeAltitudeFactor(cameraPosition.z); float vertexDistanceLow = visibleDistance / mix(1.0, 2.5, altitudeFactor); vec4 hazeColor = mix( mix(kHazeColorHigh1, kHazeColorHigh0, calculateHazeDistanceFactor(vertexDistance, visibleDistance, kHazeDistancePowerHigh)), mix(kHazeColorLow1, kHazeColorLow0, calculateHazeDistanceFactor(vertexDistance, vertexDistanceLow, kHazeDistancePowerLow)), altitudeFactor ); return hazeColor; } uniform float averageDepth; float getDistanceAlpha(float vertexDistance) { float fadeStart = averageDepth * 1.0; float fadeEnd = averageDepth * 10.0; float distanceAlpha = 1.0 - (vertexDistance - fadeStart) / (fadeEnd - fadeStart); distanceAlpha = clamp(distanceAlpha, 0.0, 1.0); return distanceAlpha; } uniform vec4 _MainTexTransform; uniform vec4 _GradientTransform; uniform vec4 _SecondaryTexTransform; uniform vec4 _GeneratedTexTransform; uniform vec4 _TopoTransform; vec2 CalculateUV(vec4 ipos, vec4 texTransform) { return (ipos.xy - texTransform.xy) / texTransform.zw; } vec4 calc_vertex_pos(vec2 _uv) { vec3 outPos = vec4(position, 1.0).xyz; vPosition = outPos; vUv = CalculateUV(vec4(outPos, 1.0), _MainTexTransform); vGradientUv = CalculateUV(vec4(outPos, 1.0), _GradientTransform); vec4 scaledPosition = upScalePoint(vec4(position, 1.0)); { vec3 vertexWorldPos = (modelMatrix * scaledPosition).xyz; vHazeColor = calculateHaze(vertexWorldPos, cameraPosition); } vec4 _position = projectionMatrix * modelViewMatrix * scaledPosition; vDepth = _position.w; vGeneratedUv = CalculateUV(vec4(outPos, 1.0), _GeneratedTexTransform); vDistanceAlpha = getDistanceAlpha(_position.w); return _position; } void main() { gl_Position = calc_vertex_pos(uv); } 5746 Terrain/Terrain-DEFAULT-SNOW_COVER.vs mat3 mat4ToMat3(mat4 m) { return mat3(m[0].xyz, m[1].xyz, m[2].xyz); } const int kSC_SymbolCullingDistanceFactor = 4; const int kSC_OSMTileCullingDistanceFactor = 4; const float kSC_MapboxZoomLevelOffset = 0.7; const int kSC_UseOSMDataFromAncestorDiff = 1; const int kSC_MaxOSMLevelFromServer = 15; const float kSC_Skybox_MinVisibleDistance = 500000.0; const float kSC_Skybox_Height = 1000000.0; const float kSC_UserMarker_OuterCircleRadius = 12.0; const int kSC_MaxBoundingBoxesPerTopoLayer = 16; const float kSC_CameraFOV = 42.0; const float kSC_ElevationExaggerationMinHeightRange = 200.0; const float kSC_ElevationExaggerationMinHeightRangeFactor = 1.9; const float kSC_ElevationExaggerationMaxHeightRange = 2000.0; const float kSC_ElevationExaggerationMaxHeightRangeFactor = 1.15; const float kSC_FlatModeExaggeration = 0.1; uniform float mercatorScale; uniform float elevationExaggerationFactor; vec4 upScalePoint(vec4 point, mat4 modelMatrix) { vec4 scaledPoint = point; float offsetZ = modelMatrix[3][2]; scaledPoint.z = (scaledPoint.z + offsetZ) * mercatorScale * elevationExaggerationFactor - offsetZ; return scaledPoint; } vec4 upScalePoint(vec4 vec) { vec4 scaledVec = vec; scaledVec.z *= mercatorScale * elevationExaggerationFactor; return scaledVec; } vec3 _applyScaleOnNormal(vec3 vec, float scale) { vec3 scaledVec = vec; scaledVec.xy *= scale; return normalize(scaledVec); } vec3 applyElevationScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale * elevationExaggerationFactor); } vec3 applyMercatorScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale); } vec3 rgb2hsv(vec3 c) { vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); float d = q.x - min(q.w, q.y); float e = 1.0e-10; return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); } vec3 hsv2rgb(vec3 c) { vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); } const float PI = 3.14159265359; const float halfPI = PI * 0.5; const float doublePI = PI * 2.0; uniform int loadState; varying vec2 vUv; varying vec4 vHazeColor; varying vec2 vGeneratedUv; varying float vDistanceAlpha; varying vec2 vSnowCoverUv; varying vec2 vGradientUv; const float kHazeAltitudeFadeoff = 100000.0; const float kHazeDistancePowerLow = 0.8; const float kHazeDistancePowerHigh = 0.8; vec4 kHazeColorLow0 = vec4(0.67, 0.80, 0.94, 0.95); vec4 kHazeColorLow1 = vec4(0.77, 0.87, 0.94, 0.0); vec4 kHazeColorHigh0 = vec4(0.81, 0.79, 0.80, 0.95); vec4 kHazeColorHigh1 = vec4(0.64, 0.75, 0.82, 0.0); float calculateVisibleDistance(float cameraPositionZ) { float cameraAltitude = max(1.0, cameraPositionZ); float radius = 6367444.65712; float visibleDistance = sqrt((radius + cameraAltitude) * (radius + cameraAltitude) - radius * radius); visibleDistance = max(kSC_Skybox_MinVisibleDistance, visibleDistance); visibleDistance += max(0.0, (cameraPositionZ - kSC_Skybox_Height / 2.0) * 10.0); return visibleDistance; } float calculateHazeAltitudeFactor(float altitude) { return exp(-altitude / kHazeAltitudeFadeoff); } float calculateHazeDistanceFactor(float vertexDistance, float visibleDistance, float powerFactor) { vertexDistance = min(vertexDistance, visibleDistance); return smoothstep(0.0, 1.0, pow(vertexDistance / visibleDistance, powerFactor)); } vec4 calculateHaze(vec3 vertexWorldPos, vec3 cameraPosition) { vec3 dir = vertexWorldPos - cameraPosition; float visibleDistance = calculateVisibleDistance(cameraPosition.z); float vertexDistance = length(dir.xy); float altitudeFactor = calculateHazeAltitudeFactor(cameraPosition.z); float vertexDistanceLow = visibleDistance / mix(1.0, 2.5, altitudeFactor); vec4 hazeColor = mix( mix(kHazeColorHigh1, kHazeColorHigh0, calculateHazeDistanceFactor(vertexDistance, visibleDistance, kHazeDistancePowerHigh)), mix(kHazeColorLow1, kHazeColorLow0, calculateHazeDistanceFactor(vertexDistance, vertexDistanceLow, kHazeDistancePowerLow)), altitudeFactor ); return hazeColor; } uniform float averageDepth; float getDistanceAlpha(float vertexDistance) { float fadeStart = averageDepth * 1.0; float fadeEnd = averageDepth * 10.0; float distanceAlpha = 1.0 - (vertexDistance - fadeStart) / (fadeEnd - fadeStart); distanceAlpha = clamp(distanceAlpha, 0.0, 1.0); return distanceAlpha; } uniform vec4 _MainTexTransform; uniform vec4 _GradientTransform; uniform vec4 _SecondaryTexTransform; uniform vec4 _GeneratedTexTransform; uniform vec4 _TopoTransform; vec2 CalculateUV(vec4 ipos, vec4 texTransform) { return (ipos.xy - texTransform.xy) / texTransform.zw; } vec4 calc_vertex_pos(vec2 _uv) { vec3 outPos = vec4(position, 1.0).xyz; vUv = CalculateUV(vec4(outPos, 1.0), _MainTexTransform); vGradientUv = CalculateUV(vec4(outPos, 1.0), _GradientTransform); vec4 scaledPosition = upScalePoint(vec4(position, 1.0)); { vec3 vertexWorldPos = (modelMatrix * scaledPosition).xyz; vHazeColor = calculateHaze(vertexWorldPos, cameraPosition); } vec4 _position = projectionMatrix * modelViewMatrix * scaledPosition; vSnowCoverUv = CalculateUV(vec4(outPos, 1.0), _SecondaryTexTransform); vGeneratedUv = CalculateUV(vec4(outPos, 1.0), _GeneratedTexTransform); vDistanceAlpha = getDistanceAlpha(_position.w); return _position; } void main() { gl_Position = calc_vertex_pos(uv); } 5822 Terrain/Terrain-DEFAULT-TRAVEL_DISTANCE.vs mat3 mat4ToMat3(mat4 m) { return mat3(m[0].xyz, m[1].xyz, m[2].xyz); } const int kSC_SymbolCullingDistanceFactor = 4; const int kSC_OSMTileCullingDistanceFactor = 4; const float kSC_MapboxZoomLevelOffset = 0.7; const int kSC_UseOSMDataFromAncestorDiff = 1; const int kSC_MaxOSMLevelFromServer = 15; const float kSC_Skybox_MinVisibleDistance = 500000.0; const float kSC_Skybox_Height = 1000000.0; const float kSC_UserMarker_OuterCircleRadius = 12.0; const int kSC_MaxBoundingBoxesPerTopoLayer = 16; const float kSC_CameraFOV = 42.0; const float kSC_ElevationExaggerationMinHeightRange = 200.0; const float kSC_ElevationExaggerationMinHeightRangeFactor = 1.9; const float kSC_ElevationExaggerationMaxHeightRange = 2000.0; const float kSC_ElevationExaggerationMaxHeightRangeFactor = 1.15; const float kSC_FlatModeExaggeration = 0.1; uniform float mercatorScale; uniform float elevationExaggerationFactor; vec4 upScalePoint(vec4 point, mat4 modelMatrix) { vec4 scaledPoint = point; float offsetZ = modelMatrix[3][2]; scaledPoint.z = (scaledPoint.z + offsetZ) * mercatorScale * elevationExaggerationFactor - offsetZ; return scaledPoint; } vec4 upScalePoint(vec4 vec) { vec4 scaledVec = vec; scaledVec.z *= mercatorScale * elevationExaggerationFactor; return scaledVec; } vec3 _applyScaleOnNormal(vec3 vec, float scale) { vec3 scaledVec = vec; scaledVec.xy *= scale; return normalize(scaledVec); } vec3 applyElevationScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale * elevationExaggerationFactor); } vec3 applyMercatorScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale); } vec3 rgb2hsv(vec3 c) { vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); float d = q.x - min(q.w, q.y); float e = 1.0e-10; return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); } vec3 hsv2rgb(vec3 c) { vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); } const float PI = 3.14159265359; const float halfPI = PI * 0.5; const float doublePI = PI * 2.0; uniform int loadState; varying vec2 vUv; varying vec4 vHazeColor; varying vec2 vGeneratedUv; varying float vDistanceAlpha; varying float vDepth; varying vec2 vWorldPosition; varying vec2 vGradientUv; const float kHazeAltitudeFadeoff = 100000.0; const float kHazeDistancePowerLow = 0.8; const float kHazeDistancePowerHigh = 0.8; vec4 kHazeColorLow0 = vec4(0.67, 0.80, 0.94, 0.95); vec4 kHazeColorLow1 = vec4(0.77, 0.87, 0.94, 0.0); vec4 kHazeColorHigh0 = vec4(0.81, 0.79, 0.80, 0.95); vec4 kHazeColorHigh1 = vec4(0.64, 0.75, 0.82, 0.0); float calculateVisibleDistance(float cameraPositionZ) { float cameraAltitude = max(1.0, cameraPositionZ); float radius = 6367444.65712; float visibleDistance = sqrt((radius + cameraAltitude) * (radius + cameraAltitude) - radius * radius); visibleDistance = max(kSC_Skybox_MinVisibleDistance, visibleDistance); visibleDistance += max(0.0, (cameraPositionZ - kSC_Skybox_Height / 2.0) * 10.0); return visibleDistance; } float calculateHazeAltitudeFactor(float altitude) { return exp(-altitude / kHazeAltitudeFadeoff); } float calculateHazeDistanceFactor(float vertexDistance, float visibleDistance, float powerFactor) { vertexDistance = min(vertexDistance, visibleDistance); return smoothstep(0.0, 1.0, pow(vertexDistance / visibleDistance, powerFactor)); } vec4 calculateHaze(vec3 vertexWorldPos, vec3 cameraPosition) { vec3 dir = vertexWorldPos - cameraPosition; float visibleDistance = calculateVisibleDistance(cameraPosition.z); float vertexDistance = length(dir.xy); float altitudeFactor = calculateHazeAltitudeFactor(cameraPosition.z); float vertexDistanceLow = visibleDistance / mix(1.0, 2.5, altitudeFactor); vec4 hazeColor = mix( mix(kHazeColorHigh1, kHazeColorHigh0, calculateHazeDistanceFactor(vertexDistance, visibleDistance, kHazeDistancePowerHigh)), mix(kHazeColorLow1, kHazeColorLow0, calculateHazeDistanceFactor(vertexDistance, vertexDistanceLow, kHazeDistancePowerLow)), altitudeFactor ); return hazeColor; } uniform float averageDepth; float getDistanceAlpha(float vertexDistance) { float fadeStart = averageDepth * 1.0; float fadeEnd = averageDepth * 10.0; float distanceAlpha = 1.0 - (vertexDistance - fadeStart) / (fadeEnd - fadeStart); distanceAlpha = clamp(distanceAlpha, 0.0, 1.0); return distanceAlpha; } uniform vec4 _MainTexTransform; uniform vec4 _GradientTransform; uniform vec4 _SecondaryTexTransform; uniform vec4 _GeneratedTexTransform; uniform vec4 _TopoTransform; vec2 CalculateUV(vec4 ipos, vec4 texTransform) { return (ipos.xy - texTransform.xy) / texTransform.zw; } vec4 calc_vertex_pos(vec2 _uv) { vec3 outPos = vec4(position, 1.0).xyz; vUv = CalculateUV(vec4(outPos, 1.0), _MainTexTransform); vGradientUv = CalculateUV(vec4(outPos, 1.0), _GradientTransform); vec4 scaledPosition = upScalePoint(vec4(position, 1.0)); { vec3 vertexWorldPos = (modelMatrix * scaledPosition).xyz; vHazeColor = calculateHaze(vertexWorldPos, cameraPosition); } vec4 _position = projectionMatrix * modelViewMatrix * scaledPosition; vDepth = _position.w; vec2 worldPosition = (modelMatrix * vec4(position, 1.0)).xy; vWorldPosition = worldPosition; vGeneratedUv = CalculateUV(vec4(outPos, 1.0), _GeneratedTexTransform); vDistanceAlpha = getDistanceAlpha(_position.w); return _position; } void main() { gl_Position = calc_vertex_pos(uv); } 5732 Terrain/Terrain-TOPO-NONE.vs mat3 mat4ToMat3(mat4 m) { return mat3(m[0].xyz, m[1].xyz, m[2].xyz); } const int kSC_SymbolCullingDistanceFactor = 4; const int kSC_OSMTileCullingDistanceFactor = 4; const float kSC_MapboxZoomLevelOffset = 0.7; const int kSC_UseOSMDataFromAncestorDiff = 1; const int kSC_MaxOSMLevelFromServer = 15; const float kSC_Skybox_MinVisibleDistance = 500000.0; const float kSC_Skybox_Height = 1000000.0; const float kSC_UserMarker_OuterCircleRadius = 12.0; const int kSC_MaxBoundingBoxesPerTopoLayer = 16; const float kSC_CameraFOV = 42.0; const float kSC_ElevationExaggerationMinHeightRange = 200.0; const float kSC_ElevationExaggerationMinHeightRangeFactor = 1.9; const float kSC_ElevationExaggerationMaxHeightRange = 2000.0; const float kSC_ElevationExaggerationMaxHeightRangeFactor = 1.15; const float kSC_FlatModeExaggeration = 0.1; uniform float mercatorScale; uniform float elevationExaggerationFactor; vec4 upScalePoint(vec4 point, mat4 modelMatrix) { vec4 scaledPoint = point; float offsetZ = modelMatrix[3][2]; scaledPoint.z = (scaledPoint.z + offsetZ) * mercatorScale * elevationExaggerationFactor - offsetZ; return scaledPoint; } vec4 upScalePoint(vec4 vec) { vec4 scaledVec = vec; scaledVec.z *= mercatorScale * elevationExaggerationFactor; return scaledVec; } vec3 _applyScaleOnNormal(vec3 vec, float scale) { vec3 scaledVec = vec; scaledVec.xy *= scale; return normalize(scaledVec); } vec3 applyElevationScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale * elevationExaggerationFactor); } vec3 applyMercatorScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale); } vec3 rgb2hsv(vec3 c) { vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); float d = q.x - min(q.w, q.y); float e = 1.0e-10; return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); } vec3 hsv2rgb(vec3 c) { vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); } const float PI = 3.14159265359; const float halfPI = PI * 0.5; const float doublePI = PI * 2.0; uniform int loadState; varying vec2 vUv; varying vec4 vHazeColor; varying vec2 vGeneratedUv; varying float vDistanceAlpha; varying vec4 vTopoUv; const float kHazeAltitudeFadeoff = 100000.0; const float kHazeDistancePowerLow = 0.8; const float kHazeDistancePowerHigh = 0.8; vec4 kHazeColorLow0 = vec4(0.67, 0.80, 0.94, 0.95); vec4 kHazeColorLow1 = vec4(0.77, 0.87, 0.94, 0.0); vec4 kHazeColorHigh0 = vec4(0.81, 0.79, 0.80, 0.95); vec4 kHazeColorHigh1 = vec4(0.64, 0.75, 0.82, 0.0); float calculateVisibleDistance(float cameraPositionZ) { float cameraAltitude = max(1.0, cameraPositionZ); float radius = 6367444.65712; float visibleDistance = sqrt((radius + cameraAltitude) * (radius + cameraAltitude) - radius * radius); visibleDistance = max(kSC_Skybox_MinVisibleDistance, visibleDistance); visibleDistance += max(0.0, (cameraPositionZ - kSC_Skybox_Height / 2.0) * 10.0); return visibleDistance; } float calculateHazeAltitudeFactor(float altitude) { return exp(-altitude / kHazeAltitudeFadeoff); } float calculateHazeDistanceFactor(float vertexDistance, float visibleDistance, float powerFactor) { vertexDistance = min(vertexDistance, visibleDistance); return smoothstep(0.0, 1.0, pow(vertexDistance / visibleDistance, powerFactor)); } vec4 calculateHaze(vec3 vertexWorldPos, vec3 cameraPosition) { vec3 dir = vertexWorldPos - cameraPosition; float visibleDistance = calculateVisibleDistance(cameraPosition.z); float vertexDistance = length(dir.xy); float altitudeFactor = calculateHazeAltitudeFactor(cameraPosition.z); float vertexDistanceLow = visibleDistance / mix(1.0, 2.5, altitudeFactor); vec4 hazeColor = mix( mix(kHazeColorHigh1, kHazeColorHigh0, calculateHazeDistanceFactor(vertexDistance, visibleDistance, kHazeDistancePowerHigh)), mix(kHazeColorLow1, kHazeColorLow0, calculateHazeDistanceFactor(vertexDistance, vertexDistanceLow, kHazeDistancePowerLow)), altitudeFactor ); return hazeColor; } uniform float averageDepth; float getDistanceAlpha(float vertexDistance) { float fadeStart = averageDepth * 1.0; float fadeEnd = averageDepth * 10.0; float distanceAlpha = 1.0 - (vertexDistance - fadeStart) / (fadeEnd - fadeStart); distanceAlpha = clamp(distanceAlpha, 0.0, 1.0); return distanceAlpha; } uniform vec4 _MainTexTransform; uniform vec4 _GradientTransform; uniform vec4 _SecondaryTexTransform; uniform vec4 _GeneratedTexTransform; uniform vec4 _TopoTransform; vec2 CalculateUV(vec4 ipos, vec4 texTransform) { return (ipos.xy - texTransform.xy) / texTransform.zw; } vec4 calc_vertex_pos(vec2 _uv) { vec3 outPos = vec4(position, 1.0).xyz; vUv = CalculateUV(vec4(outPos, 1.0), _MainTexTransform); vec4 scaledPosition = upScalePoint(vec4(position, 1.0)); { vec3 vertexWorldPos = (modelMatrix * scaledPosition).xyz; vHazeColor = calculateHaze(vertexWorldPos, cameraPosition); } vec4 _position = projectionMatrix * modelViewMatrix * scaledPosition; vec2 worldPosition = (modelMatrix * vec4(position, 1.0)).xy; vTopoUv.xy = CalculateUV(vec4(outPos, 1.0), _TopoTransform); vTopoUv.zw = worldPosition; vGeneratedUv = CalculateUV(vec4(outPos, 1.0), _GeneratedTexTransform); vDistanceAlpha = getDistanceAlpha(_position.w); return _position; } void main() { gl_Position = calc_vertex_pos(uv); } 6503 Terrain/Terrain-TOPO-ALTITUDE.vs mat3 mat4ToMat3(mat4 m) { return mat3(m[0].xyz, m[1].xyz, m[2].xyz); } const int kSC_SymbolCullingDistanceFactor = 4; const int kSC_OSMTileCullingDistanceFactor = 4; const float kSC_MapboxZoomLevelOffset = 0.7; const int kSC_UseOSMDataFromAncestorDiff = 1; const int kSC_MaxOSMLevelFromServer = 15; const float kSC_Skybox_MinVisibleDistance = 500000.0; const float kSC_Skybox_Height = 1000000.0; const float kSC_UserMarker_OuterCircleRadius = 12.0; const int kSC_MaxBoundingBoxesPerTopoLayer = 16; const float kSC_CameraFOV = 42.0; const float kSC_ElevationExaggerationMinHeightRange = 200.0; const float kSC_ElevationExaggerationMinHeightRangeFactor = 1.9; const float kSC_ElevationExaggerationMaxHeightRange = 2000.0; const float kSC_ElevationExaggerationMaxHeightRangeFactor = 1.15; const float kSC_FlatModeExaggeration = 0.1; uniform float mercatorScale; uniform float elevationExaggerationFactor; vec4 upScalePoint(vec4 point, mat4 modelMatrix) { vec4 scaledPoint = point; float offsetZ = modelMatrix[3][2]; scaledPoint.z = (scaledPoint.z + offsetZ) * mercatorScale * elevationExaggerationFactor - offsetZ; return scaledPoint; } vec4 upScalePoint(vec4 vec) { vec4 scaledVec = vec; scaledVec.z *= mercatorScale * elevationExaggerationFactor; return scaledVec; } vec3 _applyScaleOnNormal(vec3 vec, float scale) { vec3 scaledVec = vec; scaledVec.xy *= scale; return normalize(scaledVec); } vec3 applyElevationScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale * elevationExaggerationFactor); } vec3 applyMercatorScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale); } vec3 rgb2hsv(vec3 c) { vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); float d = q.x - min(q.w, q.y); float e = 1.0e-10; return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); } vec3 hsv2rgb(vec3 c) { vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); } const float PI = 3.14159265359; const float halfPI = PI * 0.5; const float doublePI = PI * 2.0; uniform int loadState; varying vec2 vUv; varying vec4 vHazeColor; varying vec2 vGeneratedUv; varying float vDistanceAlpha; varying float vDepth; varying vec3 vPosition; varying vec4 vTopoUv; varying float vLineWidthFactor; varying vec3 vScaledNormal; const float kHazeAltitudeFadeoff = 100000.0; const float kHazeDistancePowerLow = 0.8; const float kHazeDistancePowerHigh = 0.8; vec4 kHazeColorLow0 = vec4(0.67, 0.80, 0.94, 0.95); vec4 kHazeColorLow1 = vec4(0.77, 0.87, 0.94, 0.0); vec4 kHazeColorHigh0 = vec4(0.81, 0.79, 0.80, 0.95); vec4 kHazeColorHigh1 = vec4(0.64, 0.75, 0.82, 0.0); float calculateVisibleDistance(float cameraPositionZ) { float cameraAltitude = max(1.0, cameraPositionZ); float radius = 6367444.65712; float visibleDistance = sqrt((radius + cameraAltitude) * (radius + cameraAltitude) - radius * radius); visibleDistance = max(kSC_Skybox_MinVisibleDistance, visibleDistance); visibleDistance += max(0.0, (cameraPositionZ - kSC_Skybox_Height / 2.0) * 10.0); return visibleDistance; } float calculateHazeAltitudeFactor(float altitude) { return exp(-altitude / kHazeAltitudeFadeoff); } float calculateHazeDistanceFactor(float vertexDistance, float visibleDistance, float powerFactor) { vertexDistance = min(vertexDistance, visibleDistance); return smoothstep(0.0, 1.0, pow(vertexDistance / visibleDistance, powerFactor)); } vec4 calculateHaze(vec3 vertexWorldPos, vec3 cameraPosition) { vec3 dir = vertexWorldPos - cameraPosition; float visibleDistance = calculateVisibleDistance(cameraPosition.z); float vertexDistance = length(dir.xy); float altitudeFactor = calculateHazeAltitudeFactor(cameraPosition.z); float vertexDistanceLow = visibleDistance / mix(1.0, 2.5, altitudeFactor); vec4 hazeColor = mix( mix(kHazeColorHigh1, kHazeColorHigh0, calculateHazeDistanceFactor(vertexDistance, visibleDistance, kHazeDistancePowerHigh)), mix(kHazeColorLow1, kHazeColorLow0, calculateHazeDistanceFactor(vertexDistance, vertexDistanceLow, kHazeDistancePowerLow)), altitudeFactor ); return hazeColor; } uniform float averageDepth; float getDistanceAlpha(float vertexDistance) { float fadeStart = averageDepth * 1.0; float fadeEnd = averageDepth * 10.0; float distanceAlpha = 1.0 - (vertexDistance - fadeStart) / (fadeEnd - fadeStart); distanceAlpha = clamp(distanceAlpha, 0.0, 1.0); return distanceAlpha; } uniform vec4 _MainTexTransform; uniform vec4 _GradientTransform; uniform vec4 _SecondaryTexTransform; uniform vec4 _GeneratedTexTransform; uniform vec4 _TopoTransform; vec2 CalculateUV(vec4 ipos, vec4 texTransform) { return (ipos.xy - texTransform.xy) / texTransform.zw; } vec4 calc_vertex_pos(vec2 _uv) { vScaledNormal = applyElevationScaleOnNormal(normal); vec3 outPos = vec4(position, 1.0).xyz; vPosition = outPos; vUv = CalculateUV(vec4(outPos, 1.0), _MainTexTransform); vec4 scaledPosition = upScalePoint(vec4(position, 1.0)); { vec3 vertexWorldPos = (modelMatrix * scaledPosition).xyz; vHazeColor = calculateHaze(vertexWorldPos, cameraPosition); } vec4 _position = projectionMatrix * modelViewMatrix * scaledPosition; vec3 up = vec3(0, 0, 1); vec3 tangent = cross(vScaledNormal, up); vec3 binormal = cross(tangent, vScaledNormal); binormal = length(binormal) > 0.01 ? binormal : vec3(0, 1, 0.001); binormal /= binormal.z; vec4 wp1 = _position; vec4 wp2 = projectionMatrix * modelViewMatrix * (scaledPosition + vec4(binormal, 0.0)); vec2 ll = wp1.xy / wp1.w - wp2.xy / wp2.w; float aspect = projectionMatrix[1][1] / projectionMatrix[0][0]; ll.x *= aspect; vLineWidthFactor = length(ll) * mercatorScale * elevationExaggerationFactor; vDepth = _position.w; vec2 worldPosition = (modelMatrix * vec4(position, 1.0)).xy; vTopoUv.xy = CalculateUV(vec4(outPos, 1.0), _TopoTransform); vTopoUv.zw = worldPosition; vGeneratedUv = CalculateUV(vec4(outPos, 1.0), _GeneratedTexTransform); vDistanceAlpha = getDistanceAlpha(_position.w); return _position; } void main() { gl_Position = calc_vertex_pos(uv); } 5828 Terrain/Terrain-TOPO-ASPECT.vs mat3 mat4ToMat3(mat4 m) { return mat3(m[0].xyz, m[1].xyz, m[2].xyz); } const int kSC_SymbolCullingDistanceFactor = 4; const int kSC_OSMTileCullingDistanceFactor = 4; const float kSC_MapboxZoomLevelOffset = 0.7; const int kSC_UseOSMDataFromAncestorDiff = 1; const int kSC_MaxOSMLevelFromServer = 15; const float kSC_Skybox_MinVisibleDistance = 500000.0; const float kSC_Skybox_Height = 1000000.0; const float kSC_UserMarker_OuterCircleRadius = 12.0; const int kSC_MaxBoundingBoxesPerTopoLayer = 16; const float kSC_CameraFOV = 42.0; const float kSC_ElevationExaggerationMinHeightRange = 200.0; const float kSC_ElevationExaggerationMinHeightRangeFactor = 1.9; const float kSC_ElevationExaggerationMaxHeightRange = 2000.0; const float kSC_ElevationExaggerationMaxHeightRangeFactor = 1.15; const float kSC_FlatModeExaggeration = 0.1; uniform float mercatorScale; uniform float elevationExaggerationFactor; vec4 upScalePoint(vec4 point, mat4 modelMatrix) { vec4 scaledPoint = point; float offsetZ = modelMatrix[3][2]; scaledPoint.z = (scaledPoint.z + offsetZ) * mercatorScale * elevationExaggerationFactor - offsetZ; return scaledPoint; } vec4 upScalePoint(vec4 vec) { vec4 scaledVec = vec; scaledVec.z *= mercatorScale * elevationExaggerationFactor; return scaledVec; } vec3 _applyScaleOnNormal(vec3 vec, float scale) { vec3 scaledVec = vec; scaledVec.xy *= scale; return normalize(scaledVec); } vec3 applyElevationScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale * elevationExaggerationFactor); } vec3 applyMercatorScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale); } vec3 rgb2hsv(vec3 c) { vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); float d = q.x - min(q.w, q.y); float e = 1.0e-10; return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); } vec3 hsv2rgb(vec3 c) { vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); } const float PI = 3.14159265359; const float halfPI = PI * 0.5; const float doublePI = PI * 2.0; uniform int loadState; varying vec2 vUv; varying vec4 vHazeColor; varying vec2 vGeneratedUv; varying float vDistanceAlpha; varying vec4 vTopoUv; varying vec2 vGradientUv; const float kHazeAltitudeFadeoff = 100000.0; const float kHazeDistancePowerLow = 0.8; const float kHazeDistancePowerHigh = 0.8; vec4 kHazeColorLow0 = vec4(0.67, 0.80, 0.94, 0.95); vec4 kHazeColorLow1 = vec4(0.77, 0.87, 0.94, 0.0); vec4 kHazeColorHigh0 = vec4(0.81, 0.79, 0.80, 0.95); vec4 kHazeColorHigh1 = vec4(0.64, 0.75, 0.82, 0.0); float calculateVisibleDistance(float cameraPositionZ) { float cameraAltitude = max(1.0, cameraPositionZ); float radius = 6367444.65712; float visibleDistance = sqrt((radius + cameraAltitude) * (radius + cameraAltitude) - radius * radius); visibleDistance = max(kSC_Skybox_MinVisibleDistance, visibleDistance); visibleDistance += max(0.0, (cameraPositionZ - kSC_Skybox_Height / 2.0) * 10.0); return visibleDistance; } float calculateHazeAltitudeFactor(float altitude) { return exp(-altitude / kHazeAltitudeFadeoff); } float calculateHazeDistanceFactor(float vertexDistance, float visibleDistance, float powerFactor) { vertexDistance = min(vertexDistance, visibleDistance); return smoothstep(0.0, 1.0, pow(vertexDistance / visibleDistance, powerFactor)); } vec4 calculateHaze(vec3 vertexWorldPos, vec3 cameraPosition) { vec3 dir = vertexWorldPos - cameraPosition; float visibleDistance = calculateVisibleDistance(cameraPosition.z); float vertexDistance = length(dir.xy); float altitudeFactor = calculateHazeAltitudeFactor(cameraPosition.z); float vertexDistanceLow = visibleDistance / mix(1.0, 2.5, altitudeFactor); vec4 hazeColor = mix( mix(kHazeColorHigh1, kHazeColorHigh0, calculateHazeDistanceFactor(vertexDistance, visibleDistance, kHazeDistancePowerHigh)), mix(kHazeColorLow1, kHazeColorLow0, calculateHazeDistanceFactor(vertexDistance, vertexDistanceLow, kHazeDistancePowerLow)), altitudeFactor ); return hazeColor; } uniform float averageDepth; float getDistanceAlpha(float vertexDistance) { float fadeStart = averageDepth * 1.0; float fadeEnd = averageDepth * 10.0; float distanceAlpha = 1.0 - (vertexDistance - fadeStart) / (fadeEnd - fadeStart); distanceAlpha = clamp(distanceAlpha, 0.0, 1.0); return distanceAlpha; } uniform vec4 _MainTexTransform; uniform vec4 _GradientTransform; uniform vec4 _SecondaryTexTransform; uniform vec4 _GeneratedTexTransform; uniform vec4 _TopoTransform; vec2 CalculateUV(vec4 ipos, vec4 texTransform) { return (ipos.xy - texTransform.xy) / texTransform.zw; } vec4 calc_vertex_pos(vec2 _uv) { vec3 outPos = vec4(position, 1.0).xyz; vUv = CalculateUV(vec4(outPos, 1.0), _MainTexTransform); vGradientUv = CalculateUV(vec4(outPos, 1.0), _GradientTransform); vec4 scaledPosition = upScalePoint(vec4(position, 1.0)); { vec3 vertexWorldPos = (modelMatrix * scaledPosition).xyz; vHazeColor = calculateHaze(vertexWorldPos, cameraPosition); } vec4 _position = projectionMatrix * modelViewMatrix * scaledPosition; vec2 worldPosition = (modelMatrix * vec4(position, 1.0)).xy; vTopoUv.xy = CalculateUV(vec4(outPos, 1.0), _TopoTransform); vTopoUv.zw = worldPosition; vGeneratedUv = CalculateUV(vec4(outPos, 1.0), _GeneratedTexTransform); vDistanceAlpha = getDistanceAlpha(_position.w); return _position; } void main() { gl_Position = calc_vertex_pos(uv); } 5876 Terrain/Terrain-TOPO-CUSTOM.vs mat3 mat4ToMat3(mat4 m) { return mat3(m[0].xyz, m[1].xyz, m[2].xyz); } const int kSC_SymbolCullingDistanceFactor = 4; const int kSC_OSMTileCullingDistanceFactor = 4; const float kSC_MapboxZoomLevelOffset = 0.7; const int kSC_UseOSMDataFromAncestorDiff = 1; const int kSC_MaxOSMLevelFromServer = 15; const float kSC_Skybox_MinVisibleDistance = 500000.0; const float kSC_Skybox_Height = 1000000.0; const float kSC_UserMarker_OuterCircleRadius = 12.0; const int kSC_MaxBoundingBoxesPerTopoLayer = 16; const float kSC_CameraFOV = 42.0; const float kSC_ElevationExaggerationMinHeightRange = 200.0; const float kSC_ElevationExaggerationMinHeightRangeFactor = 1.9; const float kSC_ElevationExaggerationMaxHeightRange = 2000.0; const float kSC_ElevationExaggerationMaxHeightRangeFactor = 1.15; const float kSC_FlatModeExaggeration = 0.1; uniform float mercatorScale; uniform float elevationExaggerationFactor; vec4 upScalePoint(vec4 point, mat4 modelMatrix) { vec4 scaledPoint = point; float offsetZ = modelMatrix[3][2]; scaledPoint.z = (scaledPoint.z + offsetZ) * mercatorScale * elevationExaggerationFactor - offsetZ; return scaledPoint; } vec4 upScalePoint(vec4 vec) { vec4 scaledVec = vec; scaledVec.z *= mercatorScale * elevationExaggerationFactor; return scaledVec; } vec3 _applyScaleOnNormal(vec3 vec, float scale) { vec3 scaledVec = vec; scaledVec.xy *= scale; return normalize(scaledVec); } vec3 applyElevationScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale * elevationExaggerationFactor); } vec3 applyMercatorScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale); } vec3 rgb2hsv(vec3 c) { vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); float d = q.x - min(q.w, q.y); float e = 1.0e-10; return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); } vec3 hsv2rgb(vec3 c) { vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); } const float PI = 3.14159265359; const float halfPI = PI * 0.5; const float doublePI = PI * 2.0; uniform int loadState; varying vec2 vUv; varying vec4 vHazeColor; varying vec2 vGeneratedUv; varying float vDistanceAlpha; varying vec3 vPosition; varying vec4 vTopoUv; varying vec2 vGradientUv; const float kHazeAltitudeFadeoff = 100000.0; const float kHazeDistancePowerLow = 0.8; const float kHazeDistancePowerHigh = 0.8; vec4 kHazeColorLow0 = vec4(0.67, 0.80, 0.94, 0.95); vec4 kHazeColorLow1 = vec4(0.77, 0.87, 0.94, 0.0); vec4 kHazeColorHigh0 = vec4(0.81, 0.79, 0.80, 0.95); vec4 kHazeColorHigh1 = vec4(0.64, 0.75, 0.82, 0.0); float calculateVisibleDistance(float cameraPositionZ) { float cameraAltitude = max(1.0, cameraPositionZ); float radius = 6367444.65712; float visibleDistance = sqrt((radius + cameraAltitude) * (radius + cameraAltitude) - radius * radius); visibleDistance = max(kSC_Skybox_MinVisibleDistance, visibleDistance); visibleDistance += max(0.0, (cameraPositionZ - kSC_Skybox_Height / 2.0) * 10.0); return visibleDistance; } float calculateHazeAltitudeFactor(float altitude) { return exp(-altitude / kHazeAltitudeFadeoff); } float calculateHazeDistanceFactor(float vertexDistance, float visibleDistance, float powerFactor) { vertexDistance = min(vertexDistance, visibleDistance); return smoothstep(0.0, 1.0, pow(vertexDistance / visibleDistance, powerFactor)); } vec4 calculateHaze(vec3 vertexWorldPos, vec3 cameraPosition) { vec3 dir = vertexWorldPos - cameraPosition; float visibleDistance = calculateVisibleDistance(cameraPosition.z); float vertexDistance = length(dir.xy); float altitudeFactor = calculateHazeAltitudeFactor(cameraPosition.z); float vertexDistanceLow = visibleDistance / mix(1.0, 2.5, altitudeFactor); vec4 hazeColor = mix( mix(kHazeColorHigh1, kHazeColorHigh0, calculateHazeDistanceFactor(vertexDistance, visibleDistance, kHazeDistancePowerHigh)), mix(kHazeColorLow1, kHazeColorLow0, calculateHazeDistanceFactor(vertexDistance, vertexDistanceLow, kHazeDistancePowerLow)), altitudeFactor ); return hazeColor; } uniform float averageDepth; float getDistanceAlpha(float vertexDistance) { float fadeStart = averageDepth * 1.0; float fadeEnd = averageDepth * 10.0; float distanceAlpha = 1.0 - (vertexDistance - fadeStart) / (fadeEnd - fadeStart); distanceAlpha = clamp(distanceAlpha, 0.0, 1.0); return distanceAlpha; } uniform vec4 _MainTexTransform; uniform vec4 _GradientTransform; uniform vec4 _SecondaryTexTransform; uniform vec4 _GeneratedTexTransform; uniform vec4 _TopoTransform; vec2 CalculateUV(vec4 ipos, vec4 texTransform) { return (ipos.xy - texTransform.xy) / texTransform.zw; } vec4 calc_vertex_pos(vec2 _uv) { vec3 outPos = vec4(position, 1.0).xyz; vPosition = outPos; vUv = CalculateUV(vec4(outPos, 1.0), _MainTexTransform); vGradientUv = CalculateUV(vec4(outPos, 1.0), _GradientTransform); vec4 scaledPosition = upScalePoint(vec4(position, 1.0)); { vec3 vertexWorldPos = (modelMatrix * scaledPosition).xyz; vHazeColor = calculateHaze(vertexWorldPos, cameraPosition); } vec4 _position = projectionMatrix * modelViewMatrix * scaledPosition; vec2 worldPosition = (modelMatrix * vec4(position, 1.0)).xy; vTopoUv.xy = CalculateUV(vec4(outPos, 1.0), _TopoTransform); vTopoUv.zw = worldPosition; vGeneratedUv = CalculateUV(vec4(outPos, 1.0), _GeneratedTexTransform); vDistanceAlpha = getDistanceAlpha(_position.w); return _position; } void main() { gl_Position = calc_vertex_pos(uv); } 5828 Terrain/Terrain-TOPO-GRADIENT.vs mat3 mat4ToMat3(mat4 m) { return mat3(m[0].xyz, m[1].xyz, m[2].xyz); } const int kSC_SymbolCullingDistanceFactor = 4; const int kSC_OSMTileCullingDistanceFactor = 4; const float kSC_MapboxZoomLevelOffset = 0.7; const int kSC_UseOSMDataFromAncestorDiff = 1; const int kSC_MaxOSMLevelFromServer = 15; const float kSC_Skybox_MinVisibleDistance = 500000.0; const float kSC_Skybox_Height = 1000000.0; const float kSC_UserMarker_OuterCircleRadius = 12.0; const int kSC_MaxBoundingBoxesPerTopoLayer = 16; const float kSC_CameraFOV = 42.0; const float kSC_ElevationExaggerationMinHeightRange = 200.0; const float kSC_ElevationExaggerationMinHeightRangeFactor = 1.9; const float kSC_ElevationExaggerationMaxHeightRange = 2000.0; const float kSC_ElevationExaggerationMaxHeightRangeFactor = 1.15; const float kSC_FlatModeExaggeration = 0.1; uniform float mercatorScale; uniform float elevationExaggerationFactor; vec4 upScalePoint(vec4 point, mat4 modelMatrix) { vec4 scaledPoint = point; float offsetZ = modelMatrix[3][2]; scaledPoint.z = (scaledPoint.z + offsetZ) * mercatorScale * elevationExaggerationFactor - offsetZ; return scaledPoint; } vec4 upScalePoint(vec4 vec) { vec4 scaledVec = vec; scaledVec.z *= mercatorScale * elevationExaggerationFactor; return scaledVec; } vec3 _applyScaleOnNormal(vec3 vec, float scale) { vec3 scaledVec = vec; scaledVec.xy *= scale; return normalize(scaledVec); } vec3 applyElevationScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale * elevationExaggerationFactor); } vec3 applyMercatorScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale); } vec3 rgb2hsv(vec3 c) { vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); float d = q.x - min(q.w, q.y); float e = 1.0e-10; return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); } vec3 hsv2rgb(vec3 c) { vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); } const float PI = 3.14159265359; const float halfPI = PI * 0.5; const float doublePI = PI * 2.0; uniform int loadState; varying vec2 vUv; varying vec4 vHazeColor; varying vec2 vGeneratedUv; varying float vDistanceAlpha; varying vec4 vTopoUv; varying vec2 vGradientUv; const float kHazeAltitudeFadeoff = 100000.0; const float kHazeDistancePowerLow = 0.8; const float kHazeDistancePowerHigh = 0.8; vec4 kHazeColorLow0 = vec4(0.67, 0.80, 0.94, 0.95); vec4 kHazeColorLow1 = vec4(0.77, 0.87, 0.94, 0.0); vec4 kHazeColorHigh0 = vec4(0.81, 0.79, 0.80, 0.95); vec4 kHazeColorHigh1 = vec4(0.64, 0.75, 0.82, 0.0); float calculateVisibleDistance(float cameraPositionZ) { float cameraAltitude = max(1.0, cameraPositionZ); float radius = 6367444.65712; float visibleDistance = sqrt((radius + cameraAltitude) * (radius + cameraAltitude) - radius * radius); visibleDistance = max(kSC_Skybox_MinVisibleDistance, visibleDistance); visibleDistance += max(0.0, (cameraPositionZ - kSC_Skybox_Height / 2.0) * 10.0); return visibleDistance; } float calculateHazeAltitudeFactor(float altitude) { return exp(-altitude / kHazeAltitudeFadeoff); } float calculateHazeDistanceFactor(float vertexDistance, float visibleDistance, float powerFactor) { vertexDistance = min(vertexDistance, visibleDistance); return smoothstep(0.0, 1.0, pow(vertexDistance / visibleDistance, powerFactor)); } vec4 calculateHaze(vec3 vertexWorldPos, vec3 cameraPosition) { vec3 dir = vertexWorldPos - cameraPosition; float visibleDistance = calculateVisibleDistance(cameraPosition.z); float vertexDistance = length(dir.xy); float altitudeFactor = calculateHazeAltitudeFactor(cameraPosition.z); float vertexDistanceLow = visibleDistance / mix(1.0, 2.5, altitudeFactor); vec4 hazeColor = mix( mix(kHazeColorHigh1, kHazeColorHigh0, calculateHazeDistanceFactor(vertexDistance, visibleDistance, kHazeDistancePowerHigh)), mix(kHazeColorLow1, kHazeColorLow0, calculateHazeDistanceFactor(vertexDistance, vertexDistanceLow, kHazeDistancePowerLow)), altitudeFactor ); return hazeColor; } uniform float averageDepth; float getDistanceAlpha(float vertexDistance) { float fadeStart = averageDepth * 1.0; float fadeEnd = averageDepth * 10.0; float distanceAlpha = 1.0 - (vertexDistance - fadeStart) / (fadeEnd - fadeStart); distanceAlpha = clamp(distanceAlpha, 0.0, 1.0); return distanceAlpha; } uniform vec4 _MainTexTransform; uniform vec4 _GradientTransform; uniform vec4 _SecondaryTexTransform; uniform vec4 _GeneratedTexTransform; uniform vec4 _TopoTransform; vec2 CalculateUV(vec4 ipos, vec4 texTransform) { return (ipos.xy - texTransform.xy) / texTransform.zw; } vec4 calc_vertex_pos(vec2 _uv) { vec3 outPos = vec4(position, 1.0).xyz; vUv = CalculateUV(vec4(outPos, 1.0), _MainTexTransform); vGradientUv = CalculateUV(vec4(outPos, 1.0), _GradientTransform); vec4 scaledPosition = upScalePoint(vec4(position, 1.0)); { vec3 vertexWorldPos = (modelMatrix * scaledPosition).xyz; vHazeColor = calculateHaze(vertexWorldPos, cameraPosition); } vec4 _position = projectionMatrix * modelViewMatrix * scaledPosition; vec2 worldPosition = (modelMatrix * vec4(position, 1.0)).xy; vTopoUv.xy = CalculateUV(vec4(outPos, 1.0), _TopoTransform); vTopoUv.zw = worldPosition; vGeneratedUv = CalculateUV(vec4(outPos, 1.0), _GeneratedTexTransform); vDistanceAlpha = getDistanceAlpha(_position.w); return _position; } void main() { gl_Position = calc_vertex_pos(uv); } 5828 Terrain/Terrain-TOPO-GRADIENT_FLAT.vs mat3 mat4ToMat3(mat4 m) { return mat3(m[0].xyz, m[1].xyz, m[2].xyz); } const int kSC_SymbolCullingDistanceFactor = 4; const int kSC_OSMTileCullingDistanceFactor = 4; const float kSC_MapboxZoomLevelOffset = 0.7; const int kSC_UseOSMDataFromAncestorDiff = 1; const int kSC_MaxOSMLevelFromServer = 15; const float kSC_Skybox_MinVisibleDistance = 500000.0; const float kSC_Skybox_Height = 1000000.0; const float kSC_UserMarker_OuterCircleRadius = 12.0; const int kSC_MaxBoundingBoxesPerTopoLayer = 16; const float kSC_CameraFOV = 42.0; const float kSC_ElevationExaggerationMinHeightRange = 200.0; const float kSC_ElevationExaggerationMinHeightRangeFactor = 1.9; const float kSC_ElevationExaggerationMaxHeightRange = 2000.0; const float kSC_ElevationExaggerationMaxHeightRangeFactor = 1.15; const float kSC_FlatModeExaggeration = 0.1; uniform float mercatorScale; uniform float elevationExaggerationFactor; vec4 upScalePoint(vec4 point, mat4 modelMatrix) { vec4 scaledPoint = point; float offsetZ = modelMatrix[3][2]; scaledPoint.z = (scaledPoint.z + offsetZ) * mercatorScale * elevationExaggerationFactor - offsetZ; return scaledPoint; } vec4 upScalePoint(vec4 vec) { vec4 scaledVec = vec; scaledVec.z *= mercatorScale * elevationExaggerationFactor; return scaledVec; } vec3 _applyScaleOnNormal(vec3 vec, float scale) { vec3 scaledVec = vec; scaledVec.xy *= scale; return normalize(scaledVec); } vec3 applyElevationScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale * elevationExaggerationFactor); } vec3 applyMercatorScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale); } vec3 rgb2hsv(vec3 c) { vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); float d = q.x - min(q.w, q.y); float e = 1.0e-10; return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); } vec3 hsv2rgb(vec3 c) { vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); } const float PI = 3.14159265359; const float halfPI = PI * 0.5; const float doublePI = PI * 2.0; uniform int loadState; varying vec2 vUv; varying vec4 vHazeColor; varying vec2 vGeneratedUv; varying float vDistanceAlpha; varying vec4 vTopoUv; varying vec2 vGradientUv; const float kHazeAltitudeFadeoff = 100000.0; const float kHazeDistancePowerLow = 0.8; const float kHazeDistancePowerHigh = 0.8; vec4 kHazeColorLow0 = vec4(0.67, 0.80, 0.94, 0.95); vec4 kHazeColorLow1 = vec4(0.77, 0.87, 0.94, 0.0); vec4 kHazeColorHigh0 = vec4(0.81, 0.79, 0.80, 0.95); vec4 kHazeColorHigh1 = vec4(0.64, 0.75, 0.82, 0.0); float calculateVisibleDistance(float cameraPositionZ) { float cameraAltitude = max(1.0, cameraPositionZ); float radius = 6367444.65712; float visibleDistance = sqrt((radius + cameraAltitude) * (radius + cameraAltitude) - radius * radius); visibleDistance = max(kSC_Skybox_MinVisibleDistance, visibleDistance); visibleDistance += max(0.0, (cameraPositionZ - kSC_Skybox_Height / 2.0) * 10.0); return visibleDistance; } float calculateHazeAltitudeFactor(float altitude) { return exp(-altitude / kHazeAltitudeFadeoff); } float calculateHazeDistanceFactor(float vertexDistance, float visibleDistance, float powerFactor) { vertexDistance = min(vertexDistance, visibleDistance); return smoothstep(0.0, 1.0, pow(vertexDistance / visibleDistance, powerFactor)); } vec4 calculateHaze(vec3 vertexWorldPos, vec3 cameraPosition) { vec3 dir = vertexWorldPos - cameraPosition; float visibleDistance = calculateVisibleDistance(cameraPosition.z); float vertexDistance = length(dir.xy); float altitudeFactor = calculateHazeAltitudeFactor(cameraPosition.z); float vertexDistanceLow = visibleDistance / mix(1.0, 2.5, altitudeFactor); vec4 hazeColor = mix( mix(kHazeColorHigh1, kHazeColorHigh0, calculateHazeDistanceFactor(vertexDistance, visibleDistance, kHazeDistancePowerHigh)), mix(kHazeColorLow1, kHazeColorLow0, calculateHazeDistanceFactor(vertexDistance, vertexDistanceLow, kHazeDistancePowerLow)), altitudeFactor ); return hazeColor; } uniform float averageDepth; float getDistanceAlpha(float vertexDistance) { float fadeStart = averageDepth * 1.0; float fadeEnd = averageDepth * 10.0; float distanceAlpha = 1.0 - (vertexDistance - fadeStart) / (fadeEnd - fadeStart); distanceAlpha = clamp(distanceAlpha, 0.0, 1.0); return distanceAlpha; } uniform vec4 _MainTexTransform; uniform vec4 _GradientTransform; uniform vec4 _SecondaryTexTransform; uniform vec4 _GeneratedTexTransform; uniform vec4 _TopoTransform; vec2 CalculateUV(vec4 ipos, vec4 texTransform) { return (ipos.xy - texTransform.xy) / texTransform.zw; } vec4 calc_vertex_pos(vec2 _uv) { vec3 outPos = vec4(position, 1.0).xyz; vUv = CalculateUV(vec4(outPos, 1.0), _MainTexTransform); vGradientUv = CalculateUV(vec4(outPos, 1.0), _GradientTransform); vec4 scaledPosition = upScalePoint(vec4(position, 1.0)); { vec3 vertexWorldPos = (modelMatrix * scaledPosition).xyz; vHazeColor = calculateHaze(vertexWorldPos, cameraPosition); } vec4 _position = projectionMatrix * modelViewMatrix * scaledPosition; vec2 worldPosition = (modelMatrix * vec4(position, 1.0)).xy; vTopoUv.xy = CalculateUV(vec4(outPos, 1.0), _TopoTransform); vTopoUv.zw = worldPosition; vGeneratedUv = CalculateUV(vec4(outPos, 1.0), _GeneratedTexTransform); vDistanceAlpha = getDistanceAlpha(_position.w); return _position; } void main() { gl_Position = calc_vertex_pos(uv); } 5828 Terrain/Terrain-TOPO-GRID.vs mat3 mat4ToMat3(mat4 m) { return mat3(m[0].xyz, m[1].xyz, m[2].xyz); } const int kSC_SymbolCullingDistanceFactor = 4; const int kSC_OSMTileCullingDistanceFactor = 4; const float kSC_MapboxZoomLevelOffset = 0.7; const int kSC_UseOSMDataFromAncestorDiff = 1; const int kSC_MaxOSMLevelFromServer = 15; const float kSC_Skybox_MinVisibleDistance = 500000.0; const float kSC_Skybox_Height = 1000000.0; const float kSC_UserMarker_OuterCircleRadius = 12.0; const int kSC_MaxBoundingBoxesPerTopoLayer = 16; const float kSC_CameraFOV = 42.0; const float kSC_ElevationExaggerationMinHeightRange = 200.0; const float kSC_ElevationExaggerationMinHeightRangeFactor = 1.9; const float kSC_ElevationExaggerationMaxHeightRange = 2000.0; const float kSC_ElevationExaggerationMaxHeightRangeFactor = 1.15; const float kSC_FlatModeExaggeration = 0.1; uniform float mercatorScale; uniform float elevationExaggerationFactor; vec4 upScalePoint(vec4 point, mat4 modelMatrix) { vec4 scaledPoint = point; float offsetZ = modelMatrix[3][2]; scaledPoint.z = (scaledPoint.z + offsetZ) * mercatorScale * elevationExaggerationFactor - offsetZ; return scaledPoint; } vec4 upScalePoint(vec4 vec) { vec4 scaledVec = vec; scaledVec.z *= mercatorScale * elevationExaggerationFactor; return scaledVec; } vec3 _applyScaleOnNormal(vec3 vec, float scale) { vec3 scaledVec = vec; scaledVec.xy *= scale; return normalize(scaledVec); } vec3 applyElevationScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale * elevationExaggerationFactor); } vec3 applyMercatorScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale); } vec3 rgb2hsv(vec3 c) { vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); float d = q.x - min(q.w, q.y); float e = 1.0e-10; return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); } vec3 hsv2rgb(vec3 c) { vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); } const float PI = 3.14159265359; const float halfPI = PI * 0.5; const float doublePI = PI * 2.0; uniform int loadState; varying vec2 vUv; varying vec4 vHazeColor; varying vec2 vGeneratedUv; varying float vDistanceAlpha; varying float vDepth; varying vec3 vPosition; varying vec4 vTopoUv; const float kHazeAltitudeFadeoff = 100000.0; const float kHazeDistancePowerLow = 0.8; const float kHazeDistancePowerHigh = 0.8; vec4 kHazeColorLow0 = vec4(0.67, 0.80, 0.94, 0.95); vec4 kHazeColorLow1 = vec4(0.77, 0.87, 0.94, 0.0); vec4 kHazeColorHigh0 = vec4(0.81, 0.79, 0.80, 0.95); vec4 kHazeColorHigh1 = vec4(0.64, 0.75, 0.82, 0.0); float calculateVisibleDistance(float cameraPositionZ) { float cameraAltitude = max(1.0, cameraPositionZ); float radius = 6367444.65712; float visibleDistance = sqrt((radius + cameraAltitude) * (radius + cameraAltitude) - radius * radius); visibleDistance = max(kSC_Skybox_MinVisibleDistance, visibleDistance); visibleDistance += max(0.0, (cameraPositionZ - kSC_Skybox_Height / 2.0) * 10.0); return visibleDistance; } float calculateHazeAltitudeFactor(float altitude) { return exp(-altitude / kHazeAltitudeFadeoff); } float calculateHazeDistanceFactor(float vertexDistance, float visibleDistance, float powerFactor) { vertexDistance = min(vertexDistance, visibleDistance); return smoothstep(0.0, 1.0, pow(vertexDistance / visibleDistance, powerFactor)); } vec4 calculateHaze(vec3 vertexWorldPos, vec3 cameraPosition) { vec3 dir = vertexWorldPos - cameraPosition; float visibleDistance = calculateVisibleDistance(cameraPosition.z); float vertexDistance = length(dir.xy); float altitudeFactor = calculateHazeAltitudeFactor(cameraPosition.z); float vertexDistanceLow = visibleDistance / mix(1.0, 2.5, altitudeFactor); vec4 hazeColor = mix( mix(kHazeColorHigh1, kHazeColorHigh0, calculateHazeDistanceFactor(vertexDistance, visibleDistance, kHazeDistancePowerHigh)), mix(kHazeColorLow1, kHazeColorLow0, calculateHazeDistanceFactor(vertexDistance, vertexDistanceLow, kHazeDistancePowerLow)), altitudeFactor ); return hazeColor; } uniform float averageDepth; float getDistanceAlpha(float vertexDistance) { float fadeStart = averageDepth * 1.0; float fadeEnd = averageDepth * 10.0; float distanceAlpha = 1.0 - (vertexDistance - fadeStart) / (fadeEnd - fadeStart); distanceAlpha = clamp(distanceAlpha, 0.0, 1.0); return distanceAlpha; } uniform vec4 _MainTexTransform; uniform vec4 _GradientTransform; uniform vec4 _SecondaryTexTransform; uniform vec4 _GeneratedTexTransform; uniform vec4 _TopoTransform; vec2 CalculateUV(vec4 ipos, vec4 texTransform) { return (ipos.xy - texTransform.xy) / texTransform.zw; } vec4 calc_vertex_pos(vec2 _uv) { vec3 outPos = vec4(position, 1.0).xyz; vPosition = outPos; vUv = CalculateUV(vec4(outPos, 1.0), _MainTexTransform); vec4 scaledPosition = upScalePoint(vec4(position, 1.0)); { vec3 vertexWorldPos = (modelMatrix * scaledPosition).xyz; vHazeColor = calculateHaze(vertexWorldPos, cameraPosition); } vec4 _position = projectionMatrix * modelViewMatrix * scaledPosition; vDepth = _position.w; vec2 worldPosition = (modelMatrix * vec4(position, 1.0)).xy; vTopoUv.xy = CalculateUV(vec4(outPos, 1.0), _TopoTransform); vTopoUv.zw = worldPosition; vGeneratedUv = CalculateUV(vec4(outPos, 1.0), _GeneratedTexTransform); vDistanceAlpha = getDistanceAlpha(_position.w); return _position; } void main() { gl_Position = calc_vertex_pos(uv); } 5834 Terrain/Terrain-TOPO-SNOW_COVER.vs mat3 mat4ToMat3(mat4 m) { return mat3(m[0].xyz, m[1].xyz, m[2].xyz); } const int kSC_SymbolCullingDistanceFactor = 4; const int kSC_OSMTileCullingDistanceFactor = 4; const float kSC_MapboxZoomLevelOffset = 0.7; const int kSC_UseOSMDataFromAncestorDiff = 1; const int kSC_MaxOSMLevelFromServer = 15; const float kSC_Skybox_MinVisibleDistance = 500000.0; const float kSC_Skybox_Height = 1000000.0; const float kSC_UserMarker_OuterCircleRadius = 12.0; const int kSC_MaxBoundingBoxesPerTopoLayer = 16; const float kSC_CameraFOV = 42.0; const float kSC_ElevationExaggerationMinHeightRange = 200.0; const float kSC_ElevationExaggerationMinHeightRangeFactor = 1.9; const float kSC_ElevationExaggerationMaxHeightRange = 2000.0; const float kSC_ElevationExaggerationMaxHeightRangeFactor = 1.15; const float kSC_FlatModeExaggeration = 0.1; uniform float mercatorScale; uniform float elevationExaggerationFactor; vec4 upScalePoint(vec4 point, mat4 modelMatrix) { vec4 scaledPoint = point; float offsetZ = modelMatrix[3][2]; scaledPoint.z = (scaledPoint.z + offsetZ) * mercatorScale * elevationExaggerationFactor - offsetZ; return scaledPoint; } vec4 upScalePoint(vec4 vec) { vec4 scaledVec = vec; scaledVec.z *= mercatorScale * elevationExaggerationFactor; return scaledVec; } vec3 _applyScaleOnNormal(vec3 vec, float scale) { vec3 scaledVec = vec; scaledVec.xy *= scale; return normalize(scaledVec); } vec3 applyElevationScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale * elevationExaggerationFactor); } vec3 applyMercatorScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale); } vec3 rgb2hsv(vec3 c) { vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); float d = q.x - min(q.w, q.y); float e = 1.0e-10; return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); } vec3 hsv2rgb(vec3 c) { vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); } const float PI = 3.14159265359; const float halfPI = PI * 0.5; const float doublePI = PI * 2.0; uniform int loadState; varying vec2 vUv; varying vec4 vHazeColor; varying vec2 vGeneratedUv; varying float vDistanceAlpha; varying vec2 vSnowCoverUv; varying vec4 vTopoUv; const float kHazeAltitudeFadeoff = 100000.0; const float kHazeDistancePowerLow = 0.8; const float kHazeDistancePowerHigh = 0.8; vec4 kHazeColorLow0 = vec4(0.67, 0.80, 0.94, 0.95); vec4 kHazeColorLow1 = vec4(0.77, 0.87, 0.94, 0.0); vec4 kHazeColorHigh0 = vec4(0.81, 0.79, 0.80, 0.95); vec4 kHazeColorHigh1 = vec4(0.64, 0.75, 0.82, 0.0); float calculateVisibleDistance(float cameraPositionZ) { float cameraAltitude = max(1.0, cameraPositionZ); float radius = 6367444.65712; float visibleDistance = sqrt((radius + cameraAltitude) * (radius + cameraAltitude) - radius * radius); visibleDistance = max(kSC_Skybox_MinVisibleDistance, visibleDistance); visibleDistance += max(0.0, (cameraPositionZ - kSC_Skybox_Height / 2.0) * 10.0); return visibleDistance; } float calculateHazeAltitudeFactor(float altitude) { return exp(-altitude / kHazeAltitudeFadeoff); } float calculateHazeDistanceFactor(float vertexDistance, float visibleDistance, float powerFactor) { vertexDistance = min(vertexDistance, visibleDistance); return smoothstep(0.0, 1.0, pow(vertexDistance / visibleDistance, powerFactor)); } vec4 calculateHaze(vec3 vertexWorldPos, vec3 cameraPosition) { vec3 dir = vertexWorldPos - cameraPosition; float visibleDistance = calculateVisibleDistance(cameraPosition.z); float vertexDistance = length(dir.xy); float altitudeFactor = calculateHazeAltitudeFactor(cameraPosition.z); float vertexDistanceLow = visibleDistance / mix(1.0, 2.5, altitudeFactor); vec4 hazeColor = mix( mix(kHazeColorHigh1, kHazeColorHigh0, calculateHazeDistanceFactor(vertexDistance, visibleDistance, kHazeDistancePowerHigh)), mix(kHazeColorLow1, kHazeColorLow0, calculateHazeDistanceFactor(vertexDistance, vertexDistanceLow, kHazeDistancePowerLow)), altitudeFactor ); return hazeColor; } uniform float averageDepth; float getDistanceAlpha(float vertexDistance) { float fadeStart = averageDepth * 1.0; float fadeEnd = averageDepth * 10.0; float distanceAlpha = 1.0 - (vertexDistance - fadeStart) / (fadeEnd - fadeStart); distanceAlpha = clamp(distanceAlpha, 0.0, 1.0); return distanceAlpha; } uniform vec4 _MainTexTransform; uniform vec4 _GradientTransform; uniform vec4 _SecondaryTexTransform; uniform vec4 _GeneratedTexTransform; uniform vec4 _TopoTransform; vec2 CalculateUV(vec4 ipos, vec4 texTransform) { return (ipos.xy - texTransform.xy) / texTransform.zw; } vec4 calc_vertex_pos(vec2 _uv) { vec3 outPos = vec4(position, 1.0).xyz; vUv = CalculateUV(vec4(outPos, 1.0), _MainTexTransform); vec4 scaledPosition = upScalePoint(vec4(position, 1.0)); { vec3 vertexWorldPos = (modelMatrix * scaledPosition).xyz; vHazeColor = calculateHaze(vertexWorldPos, cameraPosition); } vec4 _position = projectionMatrix * modelViewMatrix * scaledPosition; vSnowCoverUv = CalculateUV(vec4(outPos, 1.0), _SecondaryTexTransform); vec2 worldPosition = (modelMatrix * vec4(position, 1.0)).xy; vTopoUv.xy = CalculateUV(vec4(outPos, 1.0), _TopoTransform); vTopoUv.zw = worldPosition; vGeneratedUv = CalculateUV(vec4(outPos, 1.0), _GeneratedTexTransform); vDistanceAlpha = getDistanceAlpha(_position.w); return _position; } void main() { gl_Position = calc_vertex_pos(uv); } 5845 Terrain/Terrain-TOPO-TRAVEL_DISTANCE.vs mat3 mat4ToMat3(mat4 m) { return mat3(m[0].xyz, m[1].xyz, m[2].xyz); } const int kSC_SymbolCullingDistanceFactor = 4; const int kSC_OSMTileCullingDistanceFactor = 4; const float kSC_MapboxZoomLevelOffset = 0.7; const int kSC_UseOSMDataFromAncestorDiff = 1; const int kSC_MaxOSMLevelFromServer = 15; const float kSC_Skybox_MinVisibleDistance = 500000.0; const float kSC_Skybox_Height = 1000000.0; const float kSC_UserMarker_OuterCircleRadius = 12.0; const int kSC_MaxBoundingBoxesPerTopoLayer = 16; const float kSC_CameraFOV = 42.0; const float kSC_ElevationExaggerationMinHeightRange = 200.0; const float kSC_ElevationExaggerationMinHeightRangeFactor = 1.9; const float kSC_ElevationExaggerationMaxHeightRange = 2000.0; const float kSC_ElevationExaggerationMaxHeightRangeFactor = 1.15; const float kSC_FlatModeExaggeration = 0.1; uniform float mercatorScale; uniform float elevationExaggerationFactor; vec4 upScalePoint(vec4 point, mat4 modelMatrix) { vec4 scaledPoint = point; float offsetZ = modelMatrix[3][2]; scaledPoint.z = (scaledPoint.z + offsetZ) * mercatorScale * elevationExaggerationFactor - offsetZ; return scaledPoint; } vec4 upScalePoint(vec4 vec) { vec4 scaledVec = vec; scaledVec.z *= mercatorScale * elevationExaggerationFactor; return scaledVec; } vec3 _applyScaleOnNormal(vec3 vec, float scale) { vec3 scaledVec = vec; scaledVec.xy *= scale; return normalize(scaledVec); } vec3 applyElevationScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale * elevationExaggerationFactor); } vec3 applyMercatorScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale); } vec3 rgb2hsv(vec3 c) { vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); float d = q.x - min(q.w, q.y); float e = 1.0e-10; return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); } vec3 hsv2rgb(vec3 c) { vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); } const float PI = 3.14159265359; const float halfPI = PI * 0.5; const float doublePI = PI * 2.0; uniform int loadState; varying vec2 vUv; varying vec4 vHazeColor; varying vec2 vGeneratedUv; varying float vDistanceAlpha; varying float vDepth; varying vec4 vTopoUv; varying vec2 vWorldPosition; const float kHazeAltitudeFadeoff = 100000.0; const float kHazeDistancePowerLow = 0.8; const float kHazeDistancePowerHigh = 0.8; vec4 kHazeColorLow0 = vec4(0.67, 0.80, 0.94, 0.95); vec4 kHazeColorLow1 = vec4(0.77, 0.87, 0.94, 0.0); vec4 kHazeColorHigh0 = vec4(0.81, 0.79, 0.80, 0.95); vec4 kHazeColorHigh1 = vec4(0.64, 0.75, 0.82, 0.0); float calculateVisibleDistance(float cameraPositionZ) { float cameraAltitude = max(1.0, cameraPositionZ); float radius = 6367444.65712; float visibleDistance = sqrt((radius + cameraAltitude) * (radius + cameraAltitude) - radius * radius); visibleDistance = max(kSC_Skybox_MinVisibleDistance, visibleDistance); visibleDistance += max(0.0, (cameraPositionZ - kSC_Skybox_Height / 2.0) * 10.0); return visibleDistance; } float calculateHazeAltitudeFactor(float altitude) { return exp(-altitude / kHazeAltitudeFadeoff); } float calculateHazeDistanceFactor(float vertexDistance, float visibleDistance, float powerFactor) { vertexDistance = min(vertexDistance, visibleDistance); return smoothstep(0.0, 1.0, pow(vertexDistance / visibleDistance, powerFactor)); } vec4 calculateHaze(vec3 vertexWorldPos, vec3 cameraPosition) { vec3 dir = vertexWorldPos - cameraPosition; float visibleDistance = calculateVisibleDistance(cameraPosition.z); float vertexDistance = length(dir.xy); float altitudeFactor = calculateHazeAltitudeFactor(cameraPosition.z); float vertexDistanceLow = visibleDistance / mix(1.0, 2.5, altitudeFactor); vec4 hazeColor = mix( mix(kHazeColorHigh1, kHazeColorHigh0, calculateHazeDistanceFactor(vertexDistance, visibleDistance, kHazeDistancePowerHigh)), mix(kHazeColorLow1, kHazeColorLow0, calculateHazeDistanceFactor(vertexDistance, vertexDistanceLow, kHazeDistancePowerLow)), altitudeFactor ); return hazeColor; } uniform float averageDepth; float getDistanceAlpha(float vertexDistance) { float fadeStart = averageDepth * 1.0; float fadeEnd = averageDepth * 10.0; float distanceAlpha = 1.0 - (vertexDistance - fadeStart) / (fadeEnd - fadeStart); distanceAlpha = clamp(distanceAlpha, 0.0, 1.0); return distanceAlpha; } uniform vec4 _MainTexTransform; uniform vec4 _GradientTransform; uniform vec4 _SecondaryTexTransform; uniform vec4 _GeneratedTexTransform; uniform vec4 _TopoTransform; vec2 CalculateUV(vec4 ipos, vec4 texTransform) { return (ipos.xy - texTransform.xy) / texTransform.zw; } vec4 calc_vertex_pos(vec2 _uv) { vec3 outPos = vec4(position, 1.0).xyz; vUv = CalculateUV(vec4(outPos, 1.0), _MainTexTransform); vec4 scaledPosition = upScalePoint(vec4(position, 1.0)); { vec3 vertexWorldPos = (modelMatrix * scaledPosition).xyz; vHazeColor = calculateHaze(vertexWorldPos, cameraPosition); } vec4 _position = projectionMatrix * modelViewMatrix * scaledPosition; vDepth = _position.w; vec2 worldPosition = (modelMatrix * vec4(position, 1.0)).xy; vTopoUv.xy = CalculateUV(vec4(outPos, 1.0), _TopoTransform); vTopoUv.zw = worldPosition; vWorldPosition = worldPosition; vGeneratedUv = CalculateUV(vec4(outPos, 1.0), _GeneratedTexTransform); vDistanceAlpha = getDistanceAlpha(_position.w); return _position; } void main() { gl_Position = calc_vertex_pos(uv); } 722 Terrain/DepthRGBAScaled.fs varying float vFragCoordW; uniform float nearPlane; uniform float farPlane; vec4 packDepth(const in float depth) { const vec4 bit_shift = vec4(256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0); const vec4 bit_mask = vec4(0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0); vec4 res = mod(depth * bit_shift * vec4(255), vec4(256)) / vec4(255); res -= res.xxyz * bit_mask; return res; } float inverseDepth(float d, float near, float far) { return -((far * near) / d - far) / (far - near); } void main() { float distance = gl_FragCoord.x < -1.0 ? vFragCoordW : gl_FragCoord.w; float depth = inverseDepth(1.0 / distance, nearPlane, farPlane); { gl_FragColor = packDepth(depth); } } 1932 Terrain/DepthRGBAScaled.vs mat3 mat4ToMat3(mat4 m) { return mat3(m[0].xyz, m[1].xyz, m[2].xyz); } const int kSC_SymbolCullingDistanceFactor = 4; const int kSC_OSMTileCullingDistanceFactor = 4; const float kSC_MapboxZoomLevelOffset = 0.7; const int kSC_UseOSMDataFromAncestorDiff = 1; const int kSC_MaxOSMLevelFromServer = 15; const float kSC_Skybox_MinVisibleDistance = 500000.0; const float kSC_Skybox_Height = 1000000.0; const float kSC_UserMarker_OuterCircleRadius = 12.0; const int kSC_MaxBoundingBoxesPerTopoLayer = 16; const float kSC_CameraFOV = 42.0; const float kSC_ElevationExaggerationMinHeightRange = 200.0; const float kSC_ElevationExaggerationMinHeightRangeFactor = 1.9; const float kSC_ElevationExaggerationMaxHeightRange = 2000.0; const float kSC_ElevationExaggerationMaxHeightRangeFactor = 1.15; const float kSC_FlatModeExaggeration = 0.1; uniform float mercatorScale; uniform float elevationExaggerationFactor; vec4 upScalePoint(vec4 point, mat4 modelMatrix) { vec4 scaledPoint = point; float offsetZ = modelMatrix[3][2]; scaledPoint.z = (scaledPoint.z + offsetZ) * mercatorScale * elevationExaggerationFactor - offsetZ; return scaledPoint; } vec4 upScalePoint(vec4 vec) { vec4 scaledVec = vec; scaledVec.z *= mercatorScale * elevationExaggerationFactor; return scaledVec; } vec3 _applyScaleOnNormal(vec3 vec, float scale) { vec3 scaledVec = vec; scaledVec.xy *= scale; return normalize(scaledVec); } vec3 applyElevationScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale * elevationExaggerationFactor); } vec3 applyMercatorScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale); } varying float vFragCoordW; void main() { vec4 scaledPosition = upScalePoint(vec4(position, 1.0)); vec4 mvPosition = modelViewMatrix * scaledPosition; gl_Position = projectionMatrix * mvPosition; vFragCoordW = 1.0 / gl_Position.w; } 5177 Terrain/Terrain-DEFAULT-NONE.fs const int kSC_SymbolCullingDistanceFactor = 4; const int kSC_OSMTileCullingDistanceFactor = 4; const float kSC_MapboxZoomLevelOffset = 0.7; const int kSC_UseOSMDataFromAncestorDiff = 1; const int kSC_MaxOSMLevelFromServer = 15; const float kSC_Skybox_MinVisibleDistance = 500000.0; const float kSC_Skybox_Height = 1000000.0; const float kSC_UserMarker_OuterCircleRadius = 12.0; const int kSC_MaxBoundingBoxesPerTopoLayer = 16; const float kSC_CameraFOV = 42.0; const float kSC_ElevationExaggerationMinHeightRange = 200.0; const float kSC_ElevationExaggerationMinHeightRangeFactor = 1.9; const float kSC_ElevationExaggerationMaxHeightRange = 2000.0; const float kSC_ElevationExaggerationMaxHeightRangeFactor = 1.15; const float kSC_FlatModeExaggeration = 0.1; mat3 mat4ToMat3(mat4 m) { return mat3(m[0].xyz, m[1].xyz, m[2].xyz); } uniform float mercatorScale; uniform float elevationExaggerationFactor; vec4 upScalePoint(vec4 point, mat4 modelMatrix) { vec4 scaledPoint = point; float offsetZ = modelMatrix[3][2]; scaledPoint.z = (scaledPoint.z + offsetZ) * mercatorScale * elevationExaggerationFactor - offsetZ; return scaledPoint; } vec4 upScalePoint(vec4 vec) { vec4 scaledVec = vec; scaledVec.z *= mercatorScale * elevationExaggerationFactor; return scaledVec; } vec3 _applyScaleOnNormal(vec3 vec, float scale) { vec3 scaledVec = vec; scaledVec.xy *= scale; return normalize(scaledVec); } vec3 applyElevationScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale * elevationExaggerationFactor); } vec3 applyMercatorScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale); } vec3 rgb2hsv(vec3 c) { vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); float d = q.x - min(q.w, q.y); float e = 1.0e-10; return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); } vec3 hsv2rgb(vec3 c) { vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); } const float PI = 3.14159265359; const float halfPI = PI * 0.5; const float doublePI = PI * 2.0; uniform int loadState; varying vec2 vUv; varying vec4 vHazeColor; varying vec2 vGeneratedUv; varying float vDistanceAlpha; varying vec2 vGradientUv; uniform sampler2D _MainTex; uniform sampler2D _Gradient; uniform sampler2D _SecondaryTex; uniform sampler2D _GeneratedTex; uniform sampler2D _TopoTex; uniform sampler2D _ColorMapTex; uniform float tileOutlineWidth; uniform float renderingParameters[6]; uniform float lightExaggerationFactor; uniform vec3 viewLightDirection; vec3 drawStates(vec3 c) { vec3 dc; if (loadState == 30) dc = vec3(0.0, 1.0, 0.0); if (loadState == 40) dc = vec3(1.0, 0.0, 0.0); if (loadState == 50) dc = vec3(1.0, 1.0, 1.0); if (loadState == 0) dc = vec3(1.0, 0.0, 0.0); if (loadState == 1) dc = vec3(0.0, 0.0, 1.0); if (loadState == 2) dc = vec3(0.5, 0.5, 1.0); if (loadState == 3) dc = vec3(1.0, 1.0, 0.0); if (loadState == 4) dc = vec3(0.0, 1.0, 0.0); return mix(c, dc, 0.3); } vec3 addAtmosphericHaze(vec3 color) { return mix(color, vHazeColor.rgb, vHazeColor.a); } vec4 adjustRenderingParameters(vec4 color, float brightness, float saturation) { vec3 c = color.rgb; c = rgb2hsv(c); c.y *= saturation; c = hsv2rgb(c); c = c * brightness; return vec4(c, color.a); } void main() { vec3 textureNormal = texture2D(_Gradient, vGradientUv).rgb; textureNormal.xy = textureNormal.xy * 2.0 - 1.0; textureNormal.y = -textureNormal.y; textureNormal = applyMercatorScaleOnNormal(textureNormal); vec2 gPos; vec3 terrainColor = texture2D(_MainTex, vUv).rgb; terrainColor = addAtmosphericHaze(terrainColor); { float litTerrain = clamp(-dot(textureNormal, viewLightDirection), 0.0, 1.0); litTerrain = litTerrain * 1.2; litTerrain = pow(litTerrain, 40.0); litTerrain = min(litTerrain + 0.4, 1.7); litTerrain = mix(1.0, litTerrain, lightExaggerationFactor); terrainColor *= litTerrain; } vec4 topoColor = vec4(0.0); vec4 overlayColor = vec4(0.0); vec4 generatedColor = texture2D(_GeneratedTex, vGeneratedUv); generatedColor.a = vDistanceAlpha * generatedColor.a; if (tileOutlineWidth > 0.0) { if (vUv.x < 0.05) terrainColor.r = 0.7; if (vUv.y < 0.05) terrainColor.r = 0.7; } vec4 c = adjustRenderingParameters(vec4(terrainColor, 1.0), renderingParameters[0], renderingParameters[1]); topoColor = adjustRenderingParameters(topoColor, renderingParameters[2], renderingParameters[3]); overlayColor = adjustRenderingParameters(overlayColor, renderingParameters[4], renderingParameters[5]); c.rgb = mix(c.rgb, topoColor.rgb, topoColor.a); c.rgb = mix(c.rgb, overlayColor.rgb, overlayColor.a); c.rgb = mix(c.rgb, generatedColor.rgb, generatedColor.a); gl_FragColor = c; } 7591 Terrain/Terrain-DEFAULT-ALTITUDE.fs const int kSC_SymbolCullingDistanceFactor = 4; const int kSC_OSMTileCullingDistanceFactor = 4; const float kSC_MapboxZoomLevelOffset = 0.7; const int kSC_UseOSMDataFromAncestorDiff = 1; const int kSC_MaxOSMLevelFromServer = 15; const float kSC_Skybox_MinVisibleDistance = 500000.0; const float kSC_Skybox_Height = 1000000.0; const float kSC_UserMarker_OuterCircleRadius = 12.0; const int kSC_MaxBoundingBoxesPerTopoLayer = 16; const float kSC_CameraFOV = 42.0; const float kSC_ElevationExaggerationMinHeightRange = 200.0; const float kSC_ElevationExaggerationMinHeightRangeFactor = 1.9; const float kSC_ElevationExaggerationMaxHeightRange = 2000.0; const float kSC_ElevationExaggerationMaxHeightRangeFactor = 1.15; const float kSC_FlatModeExaggeration = 0.1; mat3 mat4ToMat3(mat4 m) { return mat3(m[0].xyz, m[1].xyz, m[2].xyz); } uniform float mercatorScale; uniform float elevationExaggerationFactor; vec4 upScalePoint(vec4 point, mat4 modelMatrix) { vec4 scaledPoint = point; float offsetZ = modelMatrix[3][2]; scaledPoint.z = (scaledPoint.z + offsetZ) * mercatorScale * elevationExaggerationFactor - offsetZ; return scaledPoint; } vec4 upScalePoint(vec4 vec) { vec4 scaledVec = vec; scaledVec.z *= mercatorScale * elevationExaggerationFactor; return scaledVec; } vec3 _applyScaleOnNormal(vec3 vec, float scale) { vec3 scaledVec = vec; scaledVec.xy *= scale; return normalize(scaledVec); } vec3 applyElevationScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale * elevationExaggerationFactor); } vec3 applyMercatorScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale); } vec3 rgb2hsv(vec3 c) { vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); float d = q.x - min(q.w, q.y); float e = 1.0e-10; return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); } vec3 hsv2rgb(vec3 c) { vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); } const float PI = 3.14159265359; const float halfPI = PI * 0.5; const float doublePI = PI * 2.0; uniform int loadState; varying vec2 vUv; varying vec4 vHazeColor; varying vec2 vGeneratedUv; varying float vDistanceAlpha; varying float vDepth; varying vec3 vPosition; varying float vLineWidthFactor; varying vec2 vGradientUv; varying vec3 vScaledNormal; uniform sampler2D _MainTex; uniform sampler2D _Gradient; uniform sampler2D _SecondaryTex; uniform sampler2D _GeneratedTex; uniform sampler2D _TopoTex; uniform sampler2D _ColorMapTex; uniform float tileOutlineWidth; uniform float renderingParameters[6]; uniform float lightExaggerationFactor; uniform vec3 viewLightDirection; uniform float altitudeMin; uniform float altitudeBand; uniform float line1Repeat; uniform float line2Repeat; uniform vec4 line1Color; uniform vec4 line2Color; uniform float line1MaxDistance; uniform float line2MaxDistance; uniform float lineWidth; uniform float altitudeHighlightLevel; uniform float altitudeSnapInterval; uniform vec4 altitudeHighlightColor; uniform float altitudeHighlightAlpha; uniform float cameraAltitude; float altitudeLineFactor(float y, vec3 normal, float band, float maxLineDistance, float lineWidthFactor, out float alpha) { float h = lineWidth / lineWidthFactor; y = mod(y + band / 2.0, band); y = abs(y - band / 2.0) / h; y = clamp(1.0 - y, 0.0, 1.0); alpha = clamp((maxLineDistance - cameraAltitude) / (maxLineDistance / 3.0), 0.0, 1.0); float perPixelMaxLineDistance = maxLineDistance * 3.0; alpha *= clamp((perPixelMaxLineDistance - abs(vDepth)) / (perPixelMaxLineDistance / 3.0), 0.0, 1.0); return y; } vec3 drawStates(vec3 c) { vec3 dc; if (loadState == 30) dc = vec3(0.0, 1.0, 0.0); if (loadState == 40) dc = vec3(1.0, 0.0, 0.0); if (loadState == 50) dc = vec3(1.0, 1.0, 1.0); if (loadState == 0) dc = vec3(1.0, 0.0, 0.0); if (loadState == 1) dc = vec3(0.0, 0.0, 1.0); if (loadState == 2) dc = vec3(0.5, 0.5, 1.0); if (loadState == 3) dc = vec3(1.0, 1.0, 0.0); if (loadState == 4) dc = vec3(0.0, 1.0, 0.0); return mix(c, dc, 0.3); } vec3 addAtmosphericHaze(vec3 color) { return mix(color, vHazeColor.rgb, vHazeColor.a); } vec4 adjustRenderingParameters(vec4 color, float brightness, float saturation) { vec3 c = color.rgb; c = rgb2hsv(c); c.y *= saturation; c = hsv2rgb(c); c = c * brightness; return vec4(c, color.a); } void main() { vec3 textureNormal = texture2D(_Gradient, vGradientUv).rgb; textureNormal.xy = textureNormal.xy * 2.0 - 1.0; textureNormal.y = -textureNormal.y; textureNormal = applyMercatorScaleOnNormal(textureNormal); vec2 gPos; float oz = vPosition.z - altitudeMin; gPos = vec2(clamp(oz / altitudeBand * 5.0 / 128.0, 0.0, 1.0), 0.5); vec4 colMap = texture2D(_ColorMapTex, gPos); vec3 terrainColor = texture2D(_MainTex, vUv).rgb; terrainColor = addAtmosphericHaze(terrainColor); { float litTerrain = clamp(-dot(textureNormal, viewLightDirection), 0.0, 1.0); litTerrain = litTerrain * 1.2; litTerrain = pow(litTerrain, 40.0); litTerrain = min(litTerrain + 0.4, 1.7); litTerrain = mix(1.0, litTerrain, lightExaggerationFactor); terrainColor *= litTerrain; } vec4 topoColor = vec4(0.0); vec4 overlayColor = vec4(0.0); float lineAlpha = 0.0; float lineF; float hlLevel = altitudeHighlightLevel - floor(vPosition.z / altitudeSnapInterval + 0.5) * altitudeSnapInterval; bool isHighlighted = abs(hlLevel / altitudeSnapInterval) < 0.5; bool isLine2Highlighted = isHighlighted && abs(altitudeSnapInterval - altitudeBand / line2Repeat) < 0.01; lineF = altitudeLineFactor(oz, vScaledNormal, altitudeBand / line2Repeat, line2MaxDistance, vLineWidthFactor, lineAlpha); if (isLine2Highlighted) lineAlpha = altitudeHighlightAlpha; colMap = mix(colMap, !isLine2Highlighted ? line2Color : altitudeHighlightColor, lineAlpha * lineF); lineF = altitudeLineFactor(oz, vScaledNormal, altitudeBand / line1Repeat, line1MaxDistance, vLineWidthFactor, lineAlpha); if (isHighlighted) lineAlpha = altitudeHighlightAlpha; colMap = mix(colMap, !isHighlighted ? line1Color : altitudeHighlightColor, lineAlpha * lineF); overlayColor = vec4(vec3(colMap.rgb), colMap.a * vDistanceAlpha); vec4 generatedColor = texture2D(_GeneratedTex, vGeneratedUv); generatedColor.a = vDistanceAlpha * generatedColor.a; if (tileOutlineWidth > 0.0) { if (vUv.x < 0.05) terrainColor.r = 0.7; if (vUv.y < 0.05) terrainColor.r = 0.7; } vec4 c = adjustRenderingParameters(vec4(terrainColor, 1.0), renderingParameters[0], renderingParameters[1]); topoColor = adjustRenderingParameters(topoColor, renderingParameters[2], renderingParameters[3]); overlayColor = adjustRenderingParameters(overlayColor, renderingParameters[4], renderingParameters[5]); c.rgb = mix(c.rgb, topoColor.rgb, topoColor.a); c.rgb = mix(c.rgb, overlayColor.rgb, overlayColor.a); c.rgb = mix(c.rgb, generatedColor.rgb, generatedColor.a); gl_FragColor = c; } 5989 Terrain/Terrain-DEFAULT-ASPECT.fs const int kSC_SymbolCullingDistanceFactor = 4; const int kSC_OSMTileCullingDistanceFactor = 4; const float kSC_MapboxZoomLevelOffset = 0.7; const int kSC_UseOSMDataFromAncestorDiff = 1; const int kSC_MaxOSMLevelFromServer = 15; const float kSC_Skybox_MinVisibleDistance = 500000.0; const float kSC_Skybox_Height = 1000000.0; const float kSC_UserMarker_OuterCircleRadius = 12.0; const int kSC_MaxBoundingBoxesPerTopoLayer = 16; const float kSC_CameraFOV = 42.0; const float kSC_ElevationExaggerationMinHeightRange = 200.0; const float kSC_ElevationExaggerationMinHeightRangeFactor = 1.9; const float kSC_ElevationExaggerationMaxHeightRange = 2000.0; const float kSC_ElevationExaggerationMaxHeightRangeFactor = 1.15; const float kSC_FlatModeExaggeration = 0.1; mat3 mat4ToMat3(mat4 m) { return mat3(m[0].xyz, m[1].xyz, m[2].xyz); } uniform float mercatorScale; uniform float elevationExaggerationFactor; vec4 upScalePoint(vec4 point, mat4 modelMatrix) { vec4 scaledPoint = point; float offsetZ = modelMatrix[3][2]; scaledPoint.z = (scaledPoint.z + offsetZ) * mercatorScale * elevationExaggerationFactor - offsetZ; return scaledPoint; } vec4 upScalePoint(vec4 vec) { vec4 scaledVec = vec; scaledVec.z *= mercatorScale * elevationExaggerationFactor; return scaledVec; } vec3 _applyScaleOnNormal(vec3 vec, float scale) { vec3 scaledVec = vec; scaledVec.xy *= scale; return normalize(scaledVec); } vec3 applyElevationScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale * elevationExaggerationFactor); } vec3 applyMercatorScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale); } vec3 rgb2hsv(vec3 c) { vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); float d = q.x - min(q.w, q.y); float e = 1.0e-10; return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); } vec3 hsv2rgb(vec3 c) { vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); } const float PI = 3.14159265359; const float halfPI = PI * 0.5; const float doublePI = PI * 2.0; uniform int loadState; varying vec2 vUv; varying vec4 vHazeColor; varying vec2 vGeneratedUv; varying float vDistanceAlpha; varying vec2 vGradientUv; uniform sampler2D _MainTex; uniform sampler2D _Gradient; uniform sampler2D _SecondaryTex; uniform sampler2D _GeneratedTex; uniform sampler2D _TopoTex; uniform sampler2D _ColorMapTex; uniform float tileOutlineWidth; uniform float renderingParameters[6]; uniform float lightExaggerationFactor; uniform vec3 viewLightDirection; vec3 drawStates(vec3 c) { vec3 dc; if (loadState == 30) dc = vec3(0.0, 1.0, 0.0); if (loadState == 40) dc = vec3(1.0, 0.0, 0.0); if (loadState == 50) dc = vec3(1.0, 1.0, 1.0); if (loadState == 0) dc = vec3(1.0, 0.0, 0.0); if (loadState == 1) dc = vec3(0.0, 0.0, 1.0); if (loadState == 2) dc = vec3(0.5, 0.5, 1.0); if (loadState == 3) dc = vec3(1.0, 1.0, 0.0); if (loadState == 4) dc = vec3(0.0, 1.0, 0.0); return mix(c, dc, 0.3); } float getAngleBetweenAxisZ(vec3 vector) { float angle = acos(normalize(vector).z); return angle > halfPI ? halfPI : angle; } float getNormalizedAngleBetweenAxisZ(vec3 vector) { return getAngleBetweenAxisZ(vector) / halfPI; } float getProjectionOnXYPlaneDirection(vec3 vector) { return atan(-vector.x, -vector.y); } float getProjectionOnXYPlaneNormalizedDirection(vec3 vector) { return (getProjectionOnXYPlaneDirection(vector) + PI) / doublePI; } vec3 addAtmosphericHaze(vec3 color) { return mix(color, vHazeColor.rgb, vHazeColor.a); } vec4 adjustRenderingParameters(vec4 color, float brightness, float saturation) { vec3 c = color.rgb; c = rgb2hsv(c); c.y *= saturation; c = hsv2rgb(c); c = c * brightness; return vec4(c, color.a); } void main() { vec3 textureNormal = texture2D(_Gradient, vGradientUv).rgb; textureNormal.xy = textureNormal.xy * 2.0 - 1.0; textureNormal.y = -textureNormal.y; textureNormal = applyMercatorScaleOnNormal(textureNormal); vec2 gPos; float normalizedDirection = getProjectionOnXYPlaneNormalizedDirection(textureNormal); float normalizedAngle = getNormalizedAngleBetweenAxisZ(textureNormal); gPos = vec2(normalizedAngle / 128.0 * 90.0, normalizedDirection); vec4 colMap = texture2D(_ColorMapTex, gPos); vec3 terrainColor = texture2D(_MainTex, vUv).rgb; terrainColor = addAtmosphericHaze(terrainColor); { float litTerrain = clamp(-dot(textureNormal, viewLightDirection), 0.0, 1.0); litTerrain = litTerrain * 1.2; litTerrain = pow(litTerrain, 40.0); litTerrain = min(litTerrain + 0.4, 1.7); litTerrain = mix(1.0, litTerrain, lightExaggerationFactor); terrainColor *= litTerrain; } vec4 topoColor = vec4(0.0); vec4 overlayColor = vec4(0.0); overlayColor = vec4(vec3(colMap.rgb), colMap.a * vDistanceAlpha); vec4 generatedColor = texture2D(_GeneratedTex, vGeneratedUv); generatedColor.a = vDistanceAlpha * generatedColor.a; if (tileOutlineWidth > 0.0) { if (vUv.x < 0.05) terrainColor.r = 0.7; if (vUv.y < 0.05) terrainColor.r = 0.7; } vec4 c = adjustRenderingParameters(vec4(terrainColor, 1.0), renderingParameters[0], renderingParameters[1]); topoColor = adjustRenderingParameters(topoColor, renderingParameters[2], renderingParameters[3]); overlayColor = adjustRenderingParameters(overlayColor, renderingParameters[4], renderingParameters[5]); c.rgb = mix(c.rgb, topoColor.rgb, topoColor.a); c.rgb = mix(c.rgb, overlayColor.rgb, overlayColor.a); c.rgb = mix(c.rgb, generatedColor.rgb, generatedColor.a); gl_FragColor = c; } 6754 Terrain/Terrain-DEFAULT-CUSTOM.fs const int kSC_SymbolCullingDistanceFactor = 4; const int kSC_OSMTileCullingDistanceFactor = 4; const float kSC_MapboxZoomLevelOffset = 0.7; const int kSC_UseOSMDataFromAncestorDiff = 1; const int kSC_MaxOSMLevelFromServer = 15; const float kSC_Skybox_MinVisibleDistance = 500000.0; const float kSC_Skybox_Height = 1000000.0; const float kSC_UserMarker_OuterCircleRadius = 12.0; const int kSC_MaxBoundingBoxesPerTopoLayer = 16; const float kSC_CameraFOV = 42.0; const float kSC_ElevationExaggerationMinHeightRange = 200.0; const float kSC_ElevationExaggerationMinHeightRangeFactor = 1.9; const float kSC_ElevationExaggerationMaxHeightRange = 2000.0; const float kSC_ElevationExaggerationMaxHeightRangeFactor = 1.15; const float kSC_FlatModeExaggeration = 0.1; mat3 mat4ToMat3(mat4 m) { return mat3(m[0].xyz, m[1].xyz, m[2].xyz); } uniform float mercatorScale; uniform float elevationExaggerationFactor; vec4 upScalePoint(vec4 point, mat4 modelMatrix) { vec4 scaledPoint = point; float offsetZ = modelMatrix[3][2]; scaledPoint.z = (scaledPoint.z + offsetZ) * mercatorScale * elevationExaggerationFactor - offsetZ; return scaledPoint; } vec4 upScalePoint(vec4 vec) { vec4 scaledVec = vec; scaledVec.z *= mercatorScale * elevationExaggerationFactor; return scaledVec; } vec3 _applyScaleOnNormal(vec3 vec, float scale) { vec3 scaledVec = vec; scaledVec.xy *= scale; return normalize(scaledVec); } vec3 applyElevationScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale * elevationExaggerationFactor); } vec3 applyMercatorScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale); } vec3 rgb2hsv(vec3 c) { vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); float d = q.x - min(q.w, q.y); float e = 1.0e-10; return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); } vec3 hsv2rgb(vec3 c) { vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); } const float PI = 3.14159265359; const float halfPI = PI * 0.5; const float doublePI = PI * 2.0; uniform int loadState; varying vec2 vUv; varying vec4 vHazeColor; varying vec2 vGeneratedUv; varying float vDistanceAlpha; varying vec3 vPosition; varying vec2 vGradientUv; uniform sampler2D _MainTex; uniform sampler2D _Gradient; uniform sampler2D _SecondaryTex; uniform sampler2D _GeneratedTex; uniform sampler2D _TopoTex; uniform sampler2D _ColorMapTex; uniform float tileOutlineWidth; uniform float renderingParameters[6]; uniform float lightExaggerationFactor; uniform vec3 viewLightDirection; uniform float altitudeMin; uniform float elevationFrom; uniform float elevationTo; uniform float gradientFrom; uniform float gradientTo; vec3 drawStates(vec3 c) { vec3 dc; if (loadState == 30) dc = vec3(0.0, 1.0, 0.0); if (loadState == 40) dc = vec3(1.0, 0.0, 0.0); if (loadState == 50) dc = vec3(1.0, 1.0, 1.0); if (loadState == 0) dc = vec3(1.0, 0.0, 0.0); if (loadState == 1) dc = vec3(0.0, 0.0, 1.0); if (loadState == 2) dc = vec3(0.5, 0.5, 1.0); if (loadState == 3) dc = vec3(1.0, 1.0, 0.0); if (loadState == 4) dc = vec3(0.0, 1.0, 0.0); return mix(c, dc, 0.3); } float getAngleBetweenAxisZ(vec3 vector) { float angle = acos(normalize(vector).z); return angle > halfPI ? halfPI : angle; } float getProjectionOnXYPlaneDirection(vec3 vector) { return atan(-vector.x, -vector.y); } float getProjectionOnXYPlaneNormalizedDirection(vec3 vector) { return (getProjectionOnXYPlaneDirection(vector) + PI) / doublePI; } vec3 addAtmosphericHaze(vec3 color) { return mix(color, vHazeColor.rgb, vHazeColor.a); } vec4 adjustRenderingParameters(vec4 color, float brightness, float saturation) { vec3 c = color.rgb; c = rgb2hsv(c); c.y *= saturation; c = hsv2rgb(c); c = c * brightness; return vec4(c, color.a); } void main() { vec3 textureNormal = texture2D(_Gradient, vGradientUv).rgb; textureNormal.xy = textureNormal.xy * 2.0 - 1.0; textureNormal.y = -textureNormal.y; textureNormal = applyMercatorScaleOnNormal(textureNormal); vec2 gPos; bool isValidForRender = true; if (isValidForRender) { float actualHeight = vPosition.z - altitudeMin; isValidForRender = actualHeight >= elevationFrom && actualHeight <= elevationTo; } if (isValidForRender) { float angleUp = degrees(getAngleBetweenAxisZ(textureNormal)); isValidForRender = ((angleUp >= gradientFrom) && (angleUp <= gradientTo)); } if (isValidForRender && length(textureNormal.xy) >= 0.001) { float normalizedDirection = getProjectionOnXYPlaneNormalizedDirection(textureNormal); gPos = vec2(normalizedDirection / 512.0 * 360.0, 0.5); vec4 colMap = texture2D(_ColorMapTex, gPos); isValidForRender = colMap.g > 0.0; } vec4 colMap = vec4(0.024, 0.918, 0.506, isValidForRender ? 0.7 : 0.0); vec3 terrainColor = texture2D(_MainTex, vUv).rgb; terrainColor = addAtmosphericHaze(terrainColor); { float litTerrain = clamp(-dot(textureNormal, viewLightDirection), 0.0, 1.0); litTerrain = litTerrain * 1.2; litTerrain = pow(litTerrain, 40.0); litTerrain = min(litTerrain + 0.4, 1.7); litTerrain = mix(1.0, litTerrain, lightExaggerationFactor); terrainColor *= litTerrain; } vec4 topoColor = vec4(0.0); vec4 overlayColor = vec4(0.0); float litTerrain = clamp(-dot(textureNormal, viewLightDirection), 0.0, 1.0); litTerrain = pow(litTerrain, 2.0); litTerrain = mix(0.5, 1.0, litTerrain); overlayColor = vec4(vec3(colMap.rgb * litTerrain), colMap.a * vDistanceAlpha); vec4 generatedColor = texture2D(_GeneratedTex, vGeneratedUv); generatedColor.a = vDistanceAlpha * generatedColor.a; if (tileOutlineWidth > 0.0) { if (vUv.x < 0.05) terrainColor.r = 0.7; if (vUv.y < 0.05) terrainColor.r = 0.7; } vec4 c = adjustRenderingParameters(vec4(terrainColor, 1.0), renderingParameters[0], renderingParameters[1]); topoColor = adjustRenderingParameters(topoColor, renderingParameters[2], renderingParameters[3]); overlayColor = adjustRenderingParameters(overlayColor, renderingParameters[4], renderingParameters[5]); c.rgb = mix(c.rgb, topoColor.rgb, topoColor.a); c.rgb = mix(c.rgb, overlayColor.rgb, overlayColor.a); c.rgb = mix(c.rgb, generatedColor.rgb, generatedColor.a); gl_FragColor = c; } 5833 Terrain/Terrain-DEFAULT-GRADIENT.fs const int kSC_SymbolCullingDistanceFactor = 4; const int kSC_OSMTileCullingDistanceFactor = 4; const float kSC_MapboxZoomLevelOffset = 0.7; const int kSC_UseOSMDataFromAncestorDiff = 1; const int kSC_MaxOSMLevelFromServer = 15; const float kSC_Skybox_MinVisibleDistance = 500000.0; const float kSC_Skybox_Height = 1000000.0; const float kSC_UserMarker_OuterCircleRadius = 12.0; const int kSC_MaxBoundingBoxesPerTopoLayer = 16; const float kSC_CameraFOV = 42.0; const float kSC_ElevationExaggerationMinHeightRange = 200.0; const float kSC_ElevationExaggerationMinHeightRangeFactor = 1.9; const float kSC_ElevationExaggerationMaxHeightRange = 2000.0; const float kSC_ElevationExaggerationMaxHeightRangeFactor = 1.15; const float kSC_FlatModeExaggeration = 0.1; mat3 mat4ToMat3(mat4 m) { return mat3(m[0].xyz, m[1].xyz, m[2].xyz); } uniform float mercatorScale; uniform float elevationExaggerationFactor; vec4 upScalePoint(vec4 point, mat4 modelMatrix) { vec4 scaledPoint = point; float offsetZ = modelMatrix[3][2]; scaledPoint.z = (scaledPoint.z + offsetZ) * mercatorScale * elevationExaggerationFactor - offsetZ; return scaledPoint; } vec4 upScalePoint(vec4 vec) { vec4 scaledVec = vec; scaledVec.z *= mercatorScale * elevationExaggerationFactor; return scaledVec; } vec3 _applyScaleOnNormal(vec3 vec, float scale) { vec3 scaledVec = vec; scaledVec.xy *= scale; return normalize(scaledVec); } vec3 applyElevationScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale * elevationExaggerationFactor); } vec3 applyMercatorScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale); } vec3 rgb2hsv(vec3 c) { vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); float d = q.x - min(q.w, q.y); float e = 1.0e-10; return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); } vec3 hsv2rgb(vec3 c) { vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); } const float PI = 3.14159265359; const float halfPI = PI * 0.5; const float doublePI = PI * 2.0; uniform int loadState; varying vec2 vUv; varying vec4 vHazeColor; varying vec2 vGeneratedUv; varying float vDistanceAlpha; varying vec2 vGradientUv; uniform sampler2D _MainTex; uniform sampler2D _Gradient; uniform sampler2D _SecondaryTex; uniform sampler2D _GeneratedTex; uniform sampler2D _TopoTex; uniform sampler2D _ColorMapTex; uniform float tileOutlineWidth; uniform float renderingParameters[6]; uniform float lightExaggerationFactor; uniform vec3 viewLightDirection; vec3 drawStates(vec3 c) { vec3 dc; if (loadState == 30) dc = vec3(0.0, 1.0, 0.0); if (loadState == 40) dc = vec3(1.0, 0.0, 0.0); if (loadState == 50) dc = vec3(1.0, 1.0, 1.0); if (loadState == 0) dc = vec3(1.0, 0.0, 0.0); if (loadState == 1) dc = vec3(0.0, 0.0, 1.0); if (loadState == 2) dc = vec3(0.5, 0.5, 1.0); if (loadState == 3) dc = vec3(1.0, 1.0, 0.0); if (loadState == 4) dc = vec3(0.0, 1.0, 0.0); return mix(c, dc, 0.3); } float getAngleBetweenAxisZ(vec3 vector) { float angle = acos(normalize(vector).z); return angle > halfPI ? halfPI : angle; } float getNormalizedAngleBetweenAxisZ(vec3 vector) { return getAngleBetweenAxisZ(vector) / halfPI; } vec3 addAtmosphericHaze(vec3 color) { return mix(color, vHazeColor.rgb, vHazeColor.a); } vec4 adjustRenderingParameters(vec4 color, float brightness, float saturation) { vec3 c = color.rgb; c = rgb2hsv(c); c.y *= saturation; c = hsv2rgb(c); c = c * brightness; return vec4(c, color.a); } void main() { vec3 textureNormal = texture2D(_Gradient, vGradientUv).rgb; textureNormal.xy = textureNormal.xy * 2.0 - 1.0; textureNormal.y = -textureNormal.y; textureNormal = applyMercatorScaleOnNormal(textureNormal); vec2 gPos; float normalizedAngle = getNormalizedAngleBetweenAxisZ(textureNormal); gPos = vec2(normalizedAngle / 128.0 * 90.0, 0); vec4 colMap = texture2D(_ColorMapTex, gPos); vec3 terrainColor = texture2D(_MainTex, vUv).rgb; terrainColor = addAtmosphericHaze(terrainColor); { float litTerrain = clamp(-dot(textureNormal, viewLightDirection), 0.0, 1.0); litTerrain = litTerrain * 1.2; litTerrain = pow(litTerrain, 40.0); litTerrain = min(litTerrain + 0.4, 1.7); litTerrain = mix(1.0, litTerrain, lightExaggerationFactor); terrainColor *= litTerrain; } vec4 topoColor = vec4(0.0); vec4 overlayColor = vec4(0.0); float litTerrain = clamp(-dot(textureNormal, viewLightDirection), 0.0, 1.0); litTerrain = pow(litTerrain, 2.0); litTerrain = mix(0.5, 1.0, litTerrain); overlayColor = vec4(vec3(colMap.rgb * litTerrain), colMap.a * vDistanceAlpha); vec4 generatedColor = texture2D(_GeneratedTex, vGeneratedUv); generatedColor.a = vDistanceAlpha * generatedColor.a; if (tileOutlineWidth > 0.0) { if (vUv.x < 0.05) terrainColor.r = 0.7; if (vUv.y < 0.05) terrainColor.r = 0.7; } vec4 c = adjustRenderingParameters(vec4(terrainColor, 1.0), renderingParameters[0], renderingParameters[1]); topoColor = adjustRenderingParameters(topoColor, renderingParameters[2], renderingParameters[3]); overlayColor = adjustRenderingParameters(overlayColor, renderingParameters[4], renderingParameters[5]); c.rgb = mix(c.rgb, topoColor.rgb, topoColor.a); c.rgb = mix(c.rgb, overlayColor.rgb, overlayColor.a); c.rgb = mix(c.rgb, generatedColor.rgb, generatedColor.a); gl_FragColor = c; } 5656 Terrain/Terrain-DEFAULT-GRADIENT_FLAT.fs const int kSC_SymbolCullingDistanceFactor = 4; const int kSC_OSMTileCullingDistanceFactor = 4; const float kSC_MapboxZoomLevelOffset = 0.7; const int kSC_UseOSMDataFromAncestorDiff = 1; const int kSC_MaxOSMLevelFromServer = 15; const float kSC_Skybox_MinVisibleDistance = 500000.0; const float kSC_Skybox_Height = 1000000.0; const float kSC_UserMarker_OuterCircleRadius = 12.0; const int kSC_MaxBoundingBoxesPerTopoLayer = 16; const float kSC_CameraFOV = 42.0; const float kSC_ElevationExaggerationMinHeightRange = 200.0; const float kSC_ElevationExaggerationMinHeightRangeFactor = 1.9; const float kSC_ElevationExaggerationMaxHeightRange = 2000.0; const float kSC_ElevationExaggerationMaxHeightRangeFactor = 1.15; const float kSC_FlatModeExaggeration = 0.1; mat3 mat4ToMat3(mat4 m) { return mat3(m[0].xyz, m[1].xyz, m[2].xyz); } uniform float mercatorScale; uniform float elevationExaggerationFactor; vec4 upScalePoint(vec4 point, mat4 modelMatrix) { vec4 scaledPoint = point; float offsetZ = modelMatrix[3][2]; scaledPoint.z = (scaledPoint.z + offsetZ) * mercatorScale * elevationExaggerationFactor - offsetZ; return scaledPoint; } vec4 upScalePoint(vec4 vec) { vec4 scaledVec = vec; scaledVec.z *= mercatorScale * elevationExaggerationFactor; return scaledVec; } vec3 _applyScaleOnNormal(vec3 vec, float scale) { vec3 scaledVec = vec; scaledVec.xy *= scale; return normalize(scaledVec); } vec3 applyElevationScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale * elevationExaggerationFactor); } vec3 applyMercatorScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale); } vec3 rgb2hsv(vec3 c) { vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); float d = q.x - min(q.w, q.y); float e = 1.0e-10; return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); } vec3 hsv2rgb(vec3 c) { vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); } const float PI = 3.14159265359; const float halfPI = PI * 0.5; const float doublePI = PI * 2.0; uniform int loadState; varying vec2 vUv; varying vec4 vHazeColor; varying vec2 vGeneratedUv; varying float vDistanceAlpha; varying vec2 vGradientUv; uniform sampler2D _MainTex; uniform sampler2D _Gradient; uniform sampler2D _SecondaryTex; uniform sampler2D _GeneratedTex; uniform sampler2D _TopoTex; uniform sampler2D _ColorMapTex; uniform float tileOutlineWidth; uniform float renderingParameters[6]; uniform float lightExaggerationFactor; uniform vec3 viewLightDirection; vec3 drawStates(vec3 c) { vec3 dc; if (loadState == 30) dc = vec3(0.0, 1.0, 0.0); if (loadState == 40) dc = vec3(1.0, 0.0, 0.0); if (loadState == 50) dc = vec3(1.0, 1.0, 1.0); if (loadState == 0) dc = vec3(1.0, 0.0, 0.0); if (loadState == 1) dc = vec3(0.0, 0.0, 1.0); if (loadState == 2) dc = vec3(0.5, 0.5, 1.0); if (loadState == 3) dc = vec3(1.0, 1.0, 0.0); if (loadState == 4) dc = vec3(0.0, 1.0, 0.0); return mix(c, dc, 0.3); } float getAngleBetweenAxisZ(vec3 vector) { float angle = acos(normalize(vector).z); return angle > halfPI ? halfPI : angle; } float getNormalizedAngleBetweenAxisZ(vec3 vector) { return getAngleBetweenAxisZ(vector) / halfPI; } vec3 addAtmosphericHaze(vec3 color) { return mix(color, vHazeColor.rgb, vHazeColor.a); } vec4 adjustRenderingParameters(vec4 color, float brightness, float saturation) { vec3 c = color.rgb; c = rgb2hsv(c); c.y *= saturation; c = hsv2rgb(c); c = c * brightness; return vec4(c, color.a); } void main() { vec3 textureNormal = texture2D(_Gradient, vGradientUv).rgb; textureNormal.xy = textureNormal.xy * 2.0 - 1.0; textureNormal.y = -textureNormal.y; textureNormal = applyMercatorScaleOnNormal(textureNormal); vec2 gPos; float normalizedAngle = getNormalizedAngleBetweenAxisZ(textureNormal); gPos = vec2(normalizedAngle / 128.0 * 90.0, 0); vec4 colMap = texture2D(_ColorMapTex, gPos); vec3 terrainColor = texture2D(_MainTex, vUv).rgb; terrainColor = addAtmosphericHaze(terrainColor); { float litTerrain = clamp(-dot(textureNormal, viewLightDirection), 0.0, 1.0); litTerrain = litTerrain * 1.2; litTerrain = pow(litTerrain, 40.0); litTerrain = min(litTerrain + 0.4, 1.7); litTerrain = mix(1.0, litTerrain, lightExaggerationFactor); terrainColor *= litTerrain; } vec4 topoColor = vec4(0.0); vec4 overlayColor = vec4(0.0); overlayColor = vec4(vec3(colMap.rgb), colMap.a * vDistanceAlpha); vec4 generatedColor = texture2D(_GeneratedTex, vGeneratedUv); generatedColor.a = vDistanceAlpha * generatedColor.a; if (tileOutlineWidth > 0.0) { if (vUv.x < 0.05) terrainColor.r = 0.7; if (vUv.y < 0.05) terrainColor.r = 0.7; } vec4 c = adjustRenderingParameters(vec4(terrainColor, 1.0), renderingParameters[0], renderingParameters[1]); topoColor = adjustRenderingParameters(topoColor, renderingParameters[2], renderingParameters[3]); overlayColor = adjustRenderingParameters(overlayColor, renderingParameters[4], renderingParameters[5]); c.rgb = mix(c.rgb, topoColor.rgb, topoColor.a); c.rgb = mix(c.rgb, overlayColor.rgb, overlayColor.a); c.rgb = mix(c.rgb, generatedColor.rgb, generatedColor.a); gl_FragColor = c; } 6040 Terrain/Terrain-DEFAULT-GRID.fs const int kSC_SymbolCullingDistanceFactor = 4; const int kSC_OSMTileCullingDistanceFactor = 4; const float kSC_MapboxZoomLevelOffset = 0.7; const int kSC_UseOSMDataFromAncestorDiff = 1; const int kSC_MaxOSMLevelFromServer = 15; const float kSC_Skybox_MinVisibleDistance = 500000.0; const float kSC_Skybox_Height = 1000000.0; const float kSC_UserMarker_OuterCircleRadius = 12.0; const int kSC_MaxBoundingBoxesPerTopoLayer = 16; const float kSC_CameraFOV = 42.0; const float kSC_ElevationExaggerationMinHeightRange = 200.0; const float kSC_ElevationExaggerationMinHeightRangeFactor = 1.9; const float kSC_ElevationExaggerationMaxHeightRange = 2000.0; const float kSC_ElevationExaggerationMaxHeightRangeFactor = 1.15; const float kSC_FlatModeExaggeration = 0.1; mat3 mat4ToMat3(mat4 m) { return mat3(m[0].xyz, m[1].xyz, m[2].xyz); } uniform float mercatorScale; uniform float elevationExaggerationFactor; vec4 upScalePoint(vec4 point, mat4 modelMatrix) { vec4 scaledPoint = point; float offsetZ = modelMatrix[3][2]; scaledPoint.z = (scaledPoint.z + offsetZ) * mercatorScale * elevationExaggerationFactor - offsetZ; return scaledPoint; } vec4 upScalePoint(vec4 vec) { vec4 scaledVec = vec; scaledVec.z *= mercatorScale * elevationExaggerationFactor; return scaledVec; } vec3 _applyScaleOnNormal(vec3 vec, float scale) { vec3 scaledVec = vec; scaledVec.xy *= scale; return normalize(scaledVec); } vec3 applyElevationScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale * elevationExaggerationFactor); } vec3 applyMercatorScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale); } vec3 rgb2hsv(vec3 c) { vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); float d = q.x - min(q.w, q.y); float e = 1.0e-10; return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); } vec3 hsv2rgb(vec3 c) { vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); } const float PI = 3.14159265359; const float halfPI = PI * 0.5; const float doublePI = PI * 2.0; uniform int loadState; varying vec2 vUv; varying vec4 vHazeColor; varying vec2 vGeneratedUv; varying float vDistanceAlpha; varying float vDepth; varying vec3 vPosition; varying vec2 vGradientUv; uniform sampler2D _MainTex; uniform sampler2D _Gradient; uniform sampler2D _SecondaryTex; uniform sampler2D _GeneratedTex; uniform sampler2D _TopoTex; uniform sampler2D _ColorMapTex; uniform float tileOutlineWidth; uniform float renderingParameters[6]; uniform float lightExaggerationFactor; uniform vec3 viewLightDirection; uniform vec3 gridColor; uniform float gridScale; uniform float gridThickness; uniform vec2 gridSnapPoint; uniform float gridOpacity; uniform float gridSharpness; vec2 _round(vec2 value) { return floor(value + 0.5); } vec4 drawGrid(vec2 uv, float distanceAlpha) { vec2 pos = vPosition.xy - gridSnapPoint; vec2 _uv = abs(pos); _uv = abs(_uv - _round(_uv.xy / gridScale) * gridScale); float dist = min(_uv.x, _uv.y); float K = abs(vDepth) * gridThickness; if (dist < K) { float lineAlpha = 1.0 - dist / K; lineAlpha = mix(0.0, 1.0, clamp(lineAlpha * gridSharpness, 0.0, 1.0)); float alpha = clamp(lineAlpha * distanceAlpha, 0.0, 1.0); return vec4(gridColor, alpha * gridOpacity); } return vec4(0.0); } vec3 drawStates(vec3 c) { vec3 dc; if (loadState == 30) dc = vec3(0.0, 1.0, 0.0); if (loadState == 40) dc = vec3(1.0, 0.0, 0.0); if (loadState == 50) dc = vec3(1.0, 1.0, 1.0); if (loadState == 0) dc = vec3(1.0, 0.0, 0.0); if (loadState == 1) dc = vec3(0.0, 0.0, 1.0); if (loadState == 2) dc = vec3(0.5, 0.5, 1.0); if (loadState == 3) dc = vec3(1.0, 1.0, 0.0); if (loadState == 4) dc = vec3(0.0, 1.0, 0.0); return mix(c, dc, 0.3); } vec3 addAtmosphericHaze(vec3 color) { return mix(color, vHazeColor.rgb, vHazeColor.a); } vec4 adjustRenderingParameters(vec4 color, float brightness, float saturation) { vec3 c = color.rgb; c = rgb2hsv(c); c.y *= saturation; c = hsv2rgb(c); c = c * brightness; return vec4(c, color.a); } void main() { vec3 textureNormal = texture2D(_Gradient, vGradientUv).rgb; textureNormal.xy = textureNormal.xy * 2.0 - 1.0; textureNormal.y = -textureNormal.y; textureNormal = applyMercatorScaleOnNormal(textureNormal); vec2 gPos; vec3 terrainColor = texture2D(_MainTex, vUv).rgb; terrainColor = addAtmosphericHaze(terrainColor); { float litTerrain = clamp(-dot(textureNormal, viewLightDirection), 0.0, 1.0); litTerrain = litTerrain * 1.2; litTerrain = pow(litTerrain, 40.0); litTerrain = min(litTerrain + 0.4, 1.7); litTerrain = mix(1.0, litTerrain, lightExaggerationFactor); terrainColor *= litTerrain; } vec4 topoColor = vec4(0.0); vec4 overlayColor = vec4(0.0); overlayColor = drawGrid(vUv, vDistanceAlpha); vec4 generatedColor = texture2D(_GeneratedTex, vGeneratedUv); generatedColor.a = vDistanceAlpha * generatedColor.a; if (tileOutlineWidth > 0.0) { if (vUv.x < 0.05) terrainColor.r = 0.7; if (vUv.y < 0.05) terrainColor.r = 0.7; } vec4 c = adjustRenderingParameters(vec4(terrainColor, 1.0), renderingParameters[0], renderingParameters[1]); topoColor = adjustRenderingParameters(topoColor, renderingParameters[2], renderingParameters[3]); overlayColor = adjustRenderingParameters(overlayColor, renderingParameters[4], renderingParameters[5]); c.rgb = mix(c.rgb, topoColor.rgb, topoColor.a); c.rgb = mix(c.rgb, overlayColor.rgb, overlayColor.a); c.rgb = mix(c.rgb, generatedColor.rgb, generatedColor.a); gl_FragColor = c; } 5347 Terrain/Terrain-DEFAULT-SNOW_COVER.fs const int kSC_SymbolCullingDistanceFactor = 4; const int kSC_OSMTileCullingDistanceFactor = 4; const float kSC_MapboxZoomLevelOffset = 0.7; const int kSC_UseOSMDataFromAncestorDiff = 1; const int kSC_MaxOSMLevelFromServer = 15; const float kSC_Skybox_MinVisibleDistance = 500000.0; const float kSC_Skybox_Height = 1000000.0; const float kSC_UserMarker_OuterCircleRadius = 12.0; const int kSC_MaxBoundingBoxesPerTopoLayer = 16; const float kSC_CameraFOV = 42.0; const float kSC_ElevationExaggerationMinHeightRange = 200.0; const float kSC_ElevationExaggerationMinHeightRangeFactor = 1.9; const float kSC_ElevationExaggerationMaxHeightRange = 2000.0; const float kSC_ElevationExaggerationMaxHeightRangeFactor = 1.15; const float kSC_FlatModeExaggeration = 0.1; mat3 mat4ToMat3(mat4 m) { return mat3(m[0].xyz, m[1].xyz, m[2].xyz); } uniform float mercatorScale; uniform float elevationExaggerationFactor; vec4 upScalePoint(vec4 point, mat4 modelMatrix) { vec4 scaledPoint = point; float offsetZ = modelMatrix[3][2]; scaledPoint.z = (scaledPoint.z + offsetZ) * mercatorScale * elevationExaggerationFactor - offsetZ; return scaledPoint; } vec4 upScalePoint(vec4 vec) { vec4 scaledVec = vec; scaledVec.z *= mercatorScale * elevationExaggerationFactor; return scaledVec; } vec3 _applyScaleOnNormal(vec3 vec, float scale) { vec3 scaledVec = vec; scaledVec.xy *= scale; return normalize(scaledVec); } vec3 applyElevationScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale * elevationExaggerationFactor); } vec3 applyMercatorScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale); } vec3 rgb2hsv(vec3 c) { vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); float d = q.x - min(q.w, q.y); float e = 1.0e-10; return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); } vec3 hsv2rgb(vec3 c) { vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); } const float PI = 3.14159265359; const float halfPI = PI * 0.5; const float doublePI = PI * 2.0; uniform int loadState; varying vec2 vUv; varying vec4 vHazeColor; varying vec2 vGeneratedUv; varying float vDistanceAlpha; varying vec2 vSnowCoverUv; varying vec2 vGradientUv; uniform sampler2D _MainTex; uniform sampler2D _Gradient; uniform sampler2D _SecondaryTex; uniform sampler2D _GeneratedTex; uniform sampler2D _TopoTex; uniform sampler2D _ColorMapTex; uniform float tileOutlineWidth; uniform float renderingParameters[6]; uniform float lightExaggerationFactor; uniform vec3 viewLightDirection; vec3 drawStates(vec3 c) { vec3 dc; if (loadState == 30) dc = vec3(0.0, 1.0, 0.0); if (loadState == 40) dc = vec3(1.0, 0.0, 0.0); if (loadState == 50) dc = vec3(1.0, 1.0, 1.0); if (loadState == 0) dc = vec3(1.0, 0.0, 0.0); if (loadState == 1) dc = vec3(0.0, 0.0, 1.0); if (loadState == 2) dc = vec3(0.5, 0.5, 1.0); if (loadState == 3) dc = vec3(1.0, 1.0, 0.0); if (loadState == 4) dc = vec3(0.0, 1.0, 0.0); return mix(c, dc, 0.3); } vec3 addAtmosphericHaze(vec3 color) { return mix(color, vHazeColor.rgb, vHazeColor.a); } vec4 adjustRenderingParameters(vec4 color, float brightness, float saturation) { vec3 c = color.rgb; c = rgb2hsv(c); c.y *= saturation; c = hsv2rgb(c); c = c * brightness; return vec4(c, color.a); } void main() { vec3 textureNormal = texture2D(_Gradient, vGradientUv).rgb; textureNormal.xy = textureNormal.xy * 2.0 - 1.0; textureNormal.y = -textureNormal.y; textureNormal = applyMercatorScaleOnNormal(textureNormal); vec2 gPos; vec3 terrainColor = texture2D(_MainTex, vUv).rgb; terrainColor = addAtmosphericHaze(terrainColor); { float litTerrain = clamp(-dot(textureNormal, viewLightDirection), 0.0, 1.0); litTerrain = litTerrain * 1.2; litTerrain = pow(litTerrain, 40.0); litTerrain = min(litTerrain + 0.4, 1.7); litTerrain = mix(1.0, litTerrain, lightExaggerationFactor); terrainColor *= litTerrain; } vec4 topoColor = vec4(0.0); vec4 overlayColor = vec4(0.0); vec4 snowCover = texture2D(_SecondaryTex, vSnowCoverUv); overlayColor = vec4(vec3(snowCover.rgb), vDistanceAlpha * 0.4 * snowCover.a); vec4 generatedColor = texture2D(_GeneratedTex, vGeneratedUv); generatedColor.a = vDistanceAlpha * generatedColor.a; if (tileOutlineWidth > 0.0) { if (vUv.x < 0.05) terrainColor.r = 0.7; if (vUv.y < 0.05) terrainColor.r = 0.7; } vec4 c = adjustRenderingParameters(vec4(terrainColor, 1.0), renderingParameters[0], renderingParameters[1]); topoColor = adjustRenderingParameters(topoColor, renderingParameters[2], renderingParameters[3]); overlayColor = adjustRenderingParameters(overlayColor, renderingParameters[4], renderingParameters[5]); c.rgb = mix(c.rgb, topoColor.rgb, topoColor.a); c.rgb = mix(c.rgb, overlayColor.rgb, overlayColor.a); c.rgb = mix(c.rgb, generatedColor.rgb, generatedColor.a); gl_FragColor = c; } 7881 Terrain/Terrain-DEFAULT-TRAVEL_DISTANCE.fs const int kSC_SymbolCullingDistanceFactor = 4; const int kSC_OSMTileCullingDistanceFactor = 4; const float kSC_MapboxZoomLevelOffset = 0.7; const int kSC_UseOSMDataFromAncestorDiff = 1; const int kSC_MaxOSMLevelFromServer = 15; const float kSC_Skybox_MinVisibleDistance = 500000.0; const float kSC_Skybox_Height = 1000000.0; const float kSC_UserMarker_OuterCircleRadius = 12.0; const int kSC_MaxBoundingBoxesPerTopoLayer = 16; const float kSC_CameraFOV = 42.0; const float kSC_ElevationExaggerationMinHeightRange = 200.0; const float kSC_ElevationExaggerationMinHeightRangeFactor = 1.9; const float kSC_ElevationExaggerationMaxHeightRange = 2000.0; const float kSC_ElevationExaggerationMaxHeightRangeFactor = 1.15; const float kSC_FlatModeExaggeration = 0.1; mat3 mat4ToMat3(mat4 m) { return mat3(m[0].xyz, m[1].xyz, m[2].xyz); } uniform float mercatorScale; uniform float elevationExaggerationFactor; vec4 upScalePoint(vec4 point, mat4 modelMatrix) { vec4 scaledPoint = point; float offsetZ = modelMatrix[3][2]; scaledPoint.z = (scaledPoint.z + offsetZ) * mercatorScale * elevationExaggerationFactor - offsetZ; return scaledPoint; } vec4 upScalePoint(vec4 vec) { vec4 scaledVec = vec; scaledVec.z *= mercatorScale * elevationExaggerationFactor; return scaledVec; } vec3 _applyScaleOnNormal(vec3 vec, float scale) { vec3 scaledVec = vec; scaledVec.xy *= scale; return normalize(scaledVec); } vec3 applyElevationScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale * elevationExaggerationFactor); } vec3 applyMercatorScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale); } vec3 rgb2hsv(vec3 c) { vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); float d = q.x - min(q.w, q.y); float e = 1.0e-10; return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); } vec3 hsv2rgb(vec3 c) { vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); } const float PI = 3.14159265359; const float halfPI = PI * 0.5; const float doublePI = PI * 2.0; uniform int loadState; varying vec2 vUv; varying vec4 vHazeColor; varying vec2 vGeneratedUv; varying float vDistanceAlpha; varying float vDepth; varying vec2 vWorldPosition; varying vec2 vGradientUv; uniform sampler2D _MainTex; uniform sampler2D _Gradient; uniform sampler2D _SecondaryTex; uniform sampler2D _GeneratedTex; uniform sampler2D _TopoTex; uniform sampler2D _ColorMapTex; uniform float tileOutlineWidth; uniform float renderingParameters[6]; uniform float lightExaggerationFactor; uniform vec3 viewLightDirection; uniform float targetPositionX; uniform float targetPositionY; uniform float textureWorldExtents; uniform float timeRange; uniform float timeHighlight; uniform float timeInterval; uniform float calculationProgress; vec3 drawStates(vec3 c) { vec3 dc; if (loadState == 30) dc = vec3(0.0, 1.0, 0.0); if (loadState == 40) dc = vec3(1.0, 0.0, 0.0); if (loadState == 50) dc = vec3(1.0, 1.0, 1.0); if (loadState == 0) dc = vec3(1.0, 0.0, 0.0); if (loadState == 1) dc = vec3(0.0, 0.0, 1.0); if (loadState == 2) dc = vec3(0.5, 0.5, 1.0); if (loadState == 3) dc = vec3(1.0, 1.0, 0.0); if (loadState == 4) dc = vec3(0.0, 1.0, 0.0); return mix(c, dc, 0.3); } vec3 addAtmosphericHaze(vec3 color) { return mix(color, vHazeColor.rgb, vHazeColor.a); } void travelDistanceTimeHighlight(float travelDistanceValue, inout float opacity, inout vec3 color) { float highlightWidth = timeInterval / 60.0 / 2.0; float highlightDistance = (travelDistanceValue - timeHighlight) * min(15000.0 / vDepth, 3.0); const float kWidth1 = 0.5; const float kWidth2 = 0.8 + kWidth1; const float kWidth3 = 1.0 + kWidth2; if (highlightDistance >= 0.0) { } else if (highlightDistance > -highlightWidth * kWidth1) { color = vec3(0.33, 0.19, 0.69); opacity = 1.0; } else if (highlightDistance > -highlightWidth * kWidth2) { color = vec3(1.0, 0.44, 0.0); opacity = 1.0; } else if (highlightDistance > -highlightWidth * kWidth3) { color = vec3(1.0, 0.7, 0.0); opacity = 0.9; } } vec4 adjustRenderingParameters(vec4 color, float brightness, float saturation) { vec3 c = color.rgb; c = rgb2hsv(c); c.y *= saturation; c = hsv2rgb(c); c = c * brightness; return vec4(c, color.a); } void main() { vec3 textureNormal = texture2D(_Gradient, vGradientUv).rgb; textureNormal.xy = textureNormal.xy * 2.0 - 1.0; textureNormal.y = -textureNormal.y; textureNormal = applyMercatorScaleOnNormal(textureNormal); vec2 gPos; vec3 terrainColor = texture2D(_MainTex, vUv).rgb; terrainColor = addAtmosphericHaze(terrainColor); { float litTerrain = clamp(-dot(textureNormal, viewLightDirection), 0.0, 1.0); litTerrain = litTerrain * 1.2; litTerrain = pow(litTerrain, 40.0); litTerrain = min(litTerrain + 0.4, 1.7); litTerrain = mix(1.0, litTerrain, lightExaggerationFactor); terrainColor *= litTerrain; } vec4 topoColor = vec4(0.0); vec4 overlayColor = vec4(0.0); vec2 dir = vec2(vWorldPosition.x - targetPositionX, vWorldPosition.y - targetPositionY); float dist = length(dir); float distanceFromCenter = length(dir) / textureWorldExtents; float opacity = 0.0; vec3 color = vec3(0, 0, 0); if (calculationProgress >= 0.0) { opacity = distanceFromCenter < calculationProgress * timeRange ? 0.0 : 0.65; } else { vec2 colMapUV = dir / textureWorldExtents / 2.0 + 0.5; vec3 colMap = texture2D(_ColorMapTex, colMapUV).rgb; if (colMap.g >= timeRange || distanceFromCenter > 1.0) { opacity = 0.85; travelDistanceTimeHighlight(colMap.g, opacity, color); } else { if (distanceFromCenter > 0.98) { opacity = 0.8; color = vec3(0.2, 1.0, 0.0); } else { float interval = timeRange / timeInterval < 6.0 ? (timeRange / 2.0 / 3.0) : timeInterval; color = vec3(1.0, 0.7, 0.0); if (colMap.g >= timeRange - interval) { opacity = 0.6; } else if (colMap.g >= timeRange - interval * 2.0) { opacity = 0.4; } else if (colMap.g >= timeRange - interval * 3.0) { opacity = 0.2; } travelDistanceTimeHighlight(colMap.g, opacity, color); } } } overlayColor = vec4(vec3(color), opacity); vec4 generatedColor = texture2D(_GeneratedTex, vGeneratedUv); generatedColor.a = vDistanceAlpha * generatedColor.a; if (tileOutlineWidth > 0.0) { if (vUv.x < 0.05) terrainColor.r = 0.7; if (vUv.y < 0.05) terrainColor.r = 0.7; } vec4 c = adjustRenderingParameters(vec4(terrainColor, 1.0), renderingParameters[0], renderingParameters[1]); topoColor = adjustRenderingParameters(topoColor, renderingParameters[2], renderingParameters[3]); overlayColor = adjustRenderingParameters(overlayColor, renderingParameters[4], renderingParameters[5]); c.rgb = mix(c.rgb, topoColor.rgb, topoColor.a); c.rgb = mix(c.rgb, overlayColor.rgb, overlayColor.a); c.rgb = mix(c.rgb, generatedColor.rgb, generatedColor.a); gl_FragColor = c; } 4995 Terrain/Terrain-TOPO-NONE.fs const int kSC_SymbolCullingDistanceFactor = 4; const int kSC_OSMTileCullingDistanceFactor = 4; const float kSC_MapboxZoomLevelOffset = 0.7; const int kSC_UseOSMDataFromAncestorDiff = 1; const int kSC_MaxOSMLevelFromServer = 15; const float kSC_Skybox_MinVisibleDistance = 500000.0; const float kSC_Skybox_Height = 1000000.0; const float kSC_UserMarker_OuterCircleRadius = 12.0; const int kSC_MaxBoundingBoxesPerTopoLayer = 16; const float kSC_CameraFOV = 42.0; const float kSC_ElevationExaggerationMinHeightRange = 200.0; const float kSC_ElevationExaggerationMinHeightRangeFactor = 1.9; const float kSC_ElevationExaggerationMaxHeightRange = 2000.0; const float kSC_ElevationExaggerationMaxHeightRangeFactor = 1.15; const float kSC_FlatModeExaggeration = 0.1; mat3 mat4ToMat3(mat4 m) { return mat3(m[0].xyz, m[1].xyz, m[2].xyz); } uniform float mercatorScale; uniform float elevationExaggerationFactor; vec4 upScalePoint(vec4 point, mat4 modelMatrix) { vec4 scaledPoint = point; float offsetZ = modelMatrix[3][2]; scaledPoint.z = (scaledPoint.z + offsetZ) * mercatorScale * elevationExaggerationFactor - offsetZ; return scaledPoint; } vec4 upScalePoint(vec4 vec) { vec4 scaledVec = vec; scaledVec.z *= mercatorScale * elevationExaggerationFactor; return scaledVec; } vec3 _applyScaleOnNormal(vec3 vec, float scale) { vec3 scaledVec = vec; scaledVec.xy *= scale; return normalize(scaledVec); } vec3 applyElevationScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale * elevationExaggerationFactor); } vec3 applyMercatorScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale); } vec3 rgb2hsv(vec3 c) { vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); float d = q.x - min(q.w, q.y); float e = 1.0e-10; return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); } vec3 hsv2rgb(vec3 c) { vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); } const float PI = 3.14159265359; const float halfPI = PI * 0.5; const float doublePI = PI * 2.0; uniform int loadState; varying vec2 vUv; varying vec4 vHazeColor; varying vec2 vGeneratedUv; varying float vDistanceAlpha; varying vec4 vTopoUv; uniform sampler2D _MainTex; uniform sampler2D _Gradient; uniform sampler2D _SecondaryTex; uniform sampler2D _GeneratedTex; uniform sampler2D _TopoTex; uniform sampler2D _ColorMapTex; uniform float tileOutlineWidth; uniform float renderingParameters[6]; uniform vec4 topoBoundingBoxes[16]; uniform int numTopoBoundingBoxes; bool isInsideTopoArea(vec2 worldPos) { for (int i = 0; i < numTopoBoundingBoxes; ++i) { vec4 bounds = topoBoundingBoxes[i]; if (clamp(worldPos, bounds.xy, bounds.zw) == worldPos) { return true; } } return false; } vec3 drawStates(vec3 c) { vec3 dc; if (loadState == 30) dc = vec3(0.0, 1.0, 0.0); if (loadState == 40) dc = vec3(1.0, 0.0, 0.0); if (loadState == 50) dc = vec3(1.0, 1.0, 1.0); if (loadState == 0) dc = vec3(1.0, 0.0, 0.0); if (loadState == 1) dc = vec3(0.0, 0.0, 1.0); if (loadState == 2) dc = vec3(0.5, 0.5, 1.0); if (loadState == 3) dc = vec3(1.0, 1.0, 0.0); if (loadState == 4) dc = vec3(0.0, 1.0, 0.0); return mix(c, dc, 0.3); } vec3 addAtmosphericHaze(vec3 color) { return mix(color, vHazeColor.rgb, vHazeColor.a); } vec4 adjustRenderingParameters(vec4 color, float brightness, float saturation) { vec3 c = color.rgb; c = rgb2hsv(c); c.y *= saturation; c = hsv2rgb(c); c = c * brightness; return vec4(c, color.a); } void main() { vec2 gPos; vec3 terrainColor = texture2D(_MainTex, vUv).rgb; terrainColor = addAtmosphericHaze(terrainColor); vec4 topoColor = vec4(0.0); if (isInsideTopoArea(vTopoUv.zw)) { topoColor = texture2D(_TopoTex, vTopoUv.xy); } vec4 overlayColor = vec4(0.0); vec4 generatedColor = texture2D(_GeneratedTex, vGeneratedUv); generatedColor.a = vDistanceAlpha * generatedColor.a; if (tileOutlineWidth > 0.0) { if (vUv.x < 0.05) terrainColor.r = 0.7; if (vUv.y < 0.05) terrainColor.r = 0.7; } vec4 c = adjustRenderingParameters(vec4(terrainColor, 1.0), renderingParameters[0], renderingParameters[1]); topoColor = adjustRenderingParameters(topoColor, renderingParameters[2], renderingParameters[3]); overlayColor = adjustRenderingParameters(overlayColor, renderingParameters[4], renderingParameters[5]); c.rgb = mix(c.rgb, topoColor.rgb, topoColor.a); c.rgb = mix(c.rgb, overlayColor.rgb, overlayColor.a); c.rgb = mix(c.rgb, generatedColor.rgb, generatedColor.a); gl_FragColor = c; } 7409 Terrain/Terrain-TOPO-ALTITUDE.fs const int kSC_SymbolCullingDistanceFactor = 4; const int kSC_OSMTileCullingDistanceFactor = 4; const float kSC_MapboxZoomLevelOffset = 0.7; const int kSC_UseOSMDataFromAncestorDiff = 1; const int kSC_MaxOSMLevelFromServer = 15; const float kSC_Skybox_MinVisibleDistance = 500000.0; const float kSC_Skybox_Height = 1000000.0; const float kSC_UserMarker_OuterCircleRadius = 12.0; const int kSC_MaxBoundingBoxesPerTopoLayer = 16; const float kSC_CameraFOV = 42.0; const float kSC_ElevationExaggerationMinHeightRange = 200.0; const float kSC_ElevationExaggerationMinHeightRangeFactor = 1.9; const float kSC_ElevationExaggerationMaxHeightRange = 2000.0; const float kSC_ElevationExaggerationMaxHeightRangeFactor = 1.15; const float kSC_FlatModeExaggeration = 0.1; mat3 mat4ToMat3(mat4 m) { return mat3(m[0].xyz, m[1].xyz, m[2].xyz); } uniform float mercatorScale; uniform float elevationExaggerationFactor; vec4 upScalePoint(vec4 point, mat4 modelMatrix) { vec4 scaledPoint = point; float offsetZ = modelMatrix[3][2]; scaledPoint.z = (scaledPoint.z + offsetZ) * mercatorScale * elevationExaggerationFactor - offsetZ; return scaledPoint; } vec4 upScalePoint(vec4 vec) { vec4 scaledVec = vec; scaledVec.z *= mercatorScale * elevationExaggerationFactor; return scaledVec; } vec3 _applyScaleOnNormal(vec3 vec, float scale) { vec3 scaledVec = vec; scaledVec.xy *= scale; return normalize(scaledVec); } vec3 applyElevationScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale * elevationExaggerationFactor); } vec3 applyMercatorScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale); } vec3 rgb2hsv(vec3 c) { vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); float d = q.x - min(q.w, q.y); float e = 1.0e-10; return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); } vec3 hsv2rgb(vec3 c) { vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); } const float PI = 3.14159265359; const float halfPI = PI * 0.5; const float doublePI = PI * 2.0; uniform int loadState; varying vec2 vUv; varying vec4 vHazeColor; varying vec2 vGeneratedUv; varying float vDistanceAlpha; varying float vDepth; varying vec3 vPosition; varying vec4 vTopoUv; varying float vLineWidthFactor; varying vec3 vScaledNormal; uniform sampler2D _MainTex; uniform sampler2D _Gradient; uniform sampler2D _SecondaryTex; uniform sampler2D _GeneratedTex; uniform sampler2D _TopoTex; uniform sampler2D _ColorMapTex; uniform float tileOutlineWidth; uniform float renderingParameters[6]; uniform float altitudeMin; uniform float altitudeBand; uniform float line1Repeat; uniform float line2Repeat; uniform vec4 line1Color; uniform vec4 line2Color; uniform float line1MaxDistance; uniform float line2MaxDistance; uniform float lineWidth; uniform float altitudeHighlightLevel; uniform float altitudeSnapInterval; uniform vec4 altitudeHighlightColor; uniform float altitudeHighlightAlpha; uniform float cameraAltitude; uniform vec4 topoBoundingBoxes[16]; uniform int numTopoBoundingBoxes; bool isInsideTopoArea(vec2 worldPos) { for (int i = 0; i < numTopoBoundingBoxes; ++i) { vec4 bounds = topoBoundingBoxes[i]; if (clamp(worldPos, bounds.xy, bounds.zw) == worldPos) { return true; } } return false; } float altitudeLineFactor(float y, vec3 normal, float band, float maxLineDistance, float lineWidthFactor, out float alpha) { float h = lineWidth / lineWidthFactor; y = mod(y + band / 2.0, band); y = abs(y - band / 2.0) / h; y = clamp(1.0 - y, 0.0, 1.0); alpha = clamp((maxLineDistance - cameraAltitude) / (maxLineDistance / 3.0), 0.0, 1.0); float perPixelMaxLineDistance = maxLineDistance * 3.0; alpha *= clamp((perPixelMaxLineDistance - abs(vDepth)) / (perPixelMaxLineDistance / 3.0), 0.0, 1.0); return y; } vec3 drawStates(vec3 c) { vec3 dc; if (loadState == 30) dc = vec3(0.0, 1.0, 0.0); if (loadState == 40) dc = vec3(1.0, 0.0, 0.0); if (loadState == 50) dc = vec3(1.0, 1.0, 1.0); if (loadState == 0) dc = vec3(1.0, 0.0, 0.0); if (loadState == 1) dc = vec3(0.0, 0.0, 1.0); if (loadState == 2) dc = vec3(0.5, 0.5, 1.0); if (loadState == 3) dc = vec3(1.0, 1.0, 0.0); if (loadState == 4) dc = vec3(0.0, 1.0, 0.0); return mix(c, dc, 0.3); } vec3 addAtmosphericHaze(vec3 color) { return mix(color, vHazeColor.rgb, vHazeColor.a); } vec4 adjustRenderingParameters(vec4 color, float brightness, float saturation) { vec3 c = color.rgb; c = rgb2hsv(c); c.y *= saturation; c = hsv2rgb(c); c = c * brightness; return vec4(c, color.a); } void main() { vec2 gPos; float oz = vPosition.z - altitudeMin; gPos = vec2(clamp(oz / altitudeBand * 5.0 / 128.0, 0.0, 1.0), 0.5); vec4 colMap = texture2D(_ColorMapTex, gPos); vec3 terrainColor = texture2D(_MainTex, vUv).rgb; terrainColor = addAtmosphericHaze(terrainColor); vec4 topoColor = vec4(0.0); if (isInsideTopoArea(vTopoUv.zw)) { topoColor = texture2D(_TopoTex, vTopoUv.xy); } vec4 overlayColor = vec4(0.0); float lineAlpha = 0.0; float lineF; float hlLevel = altitudeHighlightLevel - floor(vPosition.z / altitudeSnapInterval + 0.5) * altitudeSnapInterval; bool isHighlighted = abs(hlLevel / altitudeSnapInterval) < 0.5; bool isLine2Highlighted = isHighlighted && abs(altitudeSnapInterval - altitudeBand / line2Repeat) < 0.01; lineF = altitudeLineFactor(oz, vScaledNormal, altitudeBand / line2Repeat, line2MaxDistance, vLineWidthFactor, lineAlpha); if (isLine2Highlighted) lineAlpha = altitudeHighlightAlpha; colMap = mix(colMap, !isLine2Highlighted ? line2Color : altitudeHighlightColor, lineAlpha * lineF); lineF = altitudeLineFactor(oz, vScaledNormal, altitudeBand / line1Repeat, line1MaxDistance, vLineWidthFactor, lineAlpha); if (isHighlighted) lineAlpha = altitudeHighlightAlpha; colMap = mix(colMap, !isHighlighted ? line1Color : altitudeHighlightColor, lineAlpha * lineF); overlayColor = vec4(vec3(colMap.rgb), colMap.a * vDistanceAlpha); vec4 generatedColor = texture2D(_GeneratedTex, vGeneratedUv); generatedColor.a = vDistanceAlpha * generatedColor.a; if (tileOutlineWidth > 0.0) { if (vUv.x < 0.05) terrainColor.r = 0.7; if (vUv.y < 0.05) terrainColor.r = 0.7; } vec4 c = adjustRenderingParameters(vec4(terrainColor, 1.0), renderingParameters[0], renderingParameters[1]); topoColor = adjustRenderingParameters(topoColor, renderingParameters[2], renderingParameters[3]); overlayColor = adjustRenderingParameters(overlayColor, renderingParameters[4], renderingParameters[5]); c.rgb = mix(c.rgb, topoColor.rgb, topoColor.a); c.rgb = mix(c.rgb, overlayColor.rgb, overlayColor.a); c.rgb = mix(c.rgb, generatedColor.rgb, generatedColor.a); gl_FragColor = c; } 6053 Terrain/Terrain-TOPO-ASPECT.fs const int kSC_SymbolCullingDistanceFactor = 4; const int kSC_OSMTileCullingDistanceFactor = 4; const float kSC_MapboxZoomLevelOffset = 0.7; const int kSC_UseOSMDataFromAncestorDiff = 1; const int kSC_MaxOSMLevelFromServer = 15; const float kSC_Skybox_MinVisibleDistance = 500000.0; const float kSC_Skybox_Height = 1000000.0; const float kSC_UserMarker_OuterCircleRadius = 12.0; const int kSC_MaxBoundingBoxesPerTopoLayer = 16; const float kSC_CameraFOV = 42.0; const float kSC_ElevationExaggerationMinHeightRange = 200.0; const float kSC_ElevationExaggerationMinHeightRangeFactor = 1.9; const float kSC_ElevationExaggerationMaxHeightRange = 2000.0; const float kSC_ElevationExaggerationMaxHeightRangeFactor = 1.15; const float kSC_FlatModeExaggeration = 0.1; mat3 mat4ToMat3(mat4 m) { return mat3(m[0].xyz, m[1].xyz, m[2].xyz); } uniform float mercatorScale; uniform float elevationExaggerationFactor; vec4 upScalePoint(vec4 point, mat4 modelMatrix) { vec4 scaledPoint = point; float offsetZ = modelMatrix[3][2]; scaledPoint.z = (scaledPoint.z + offsetZ) * mercatorScale * elevationExaggerationFactor - offsetZ; return scaledPoint; } vec4 upScalePoint(vec4 vec) { vec4 scaledVec = vec; scaledVec.z *= mercatorScale * elevationExaggerationFactor; return scaledVec; } vec3 _applyScaleOnNormal(vec3 vec, float scale) { vec3 scaledVec = vec; scaledVec.xy *= scale; return normalize(scaledVec); } vec3 applyElevationScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale * elevationExaggerationFactor); } vec3 applyMercatorScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale); } vec3 rgb2hsv(vec3 c) { vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); float d = q.x - min(q.w, q.y); float e = 1.0e-10; return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); } vec3 hsv2rgb(vec3 c) { vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); } const float PI = 3.14159265359; const float halfPI = PI * 0.5; const float doublePI = PI * 2.0; uniform int loadState; varying vec2 vUv; varying vec4 vHazeColor; varying vec2 vGeneratedUv; varying float vDistanceAlpha; varying vec4 vTopoUv; varying vec2 vGradientUv; uniform sampler2D _MainTex; uniform sampler2D _Gradient; uniform sampler2D _SecondaryTex; uniform sampler2D _GeneratedTex; uniform sampler2D _TopoTex; uniform sampler2D _ColorMapTex; uniform float tileOutlineWidth; uniform float renderingParameters[6]; uniform vec4 topoBoundingBoxes[16]; uniform int numTopoBoundingBoxes; bool isInsideTopoArea(vec2 worldPos) { for (int i = 0; i < numTopoBoundingBoxes; ++i) { vec4 bounds = topoBoundingBoxes[i]; if (clamp(worldPos, bounds.xy, bounds.zw) == worldPos) { return true; } } return false; } vec3 drawStates(vec3 c) { vec3 dc; if (loadState == 30) dc = vec3(0.0, 1.0, 0.0); if (loadState == 40) dc = vec3(1.0, 0.0, 0.0); if (loadState == 50) dc = vec3(1.0, 1.0, 1.0); if (loadState == 0) dc = vec3(1.0, 0.0, 0.0); if (loadState == 1) dc = vec3(0.0, 0.0, 1.0); if (loadState == 2) dc = vec3(0.5, 0.5, 1.0); if (loadState == 3) dc = vec3(1.0, 1.0, 0.0); if (loadState == 4) dc = vec3(0.0, 1.0, 0.0); return mix(c, dc, 0.3); } float getAngleBetweenAxisZ(vec3 vector) { float angle = acos(normalize(vector).z); return angle > halfPI ? halfPI : angle; } float getNormalizedAngleBetweenAxisZ(vec3 vector) { return getAngleBetweenAxisZ(vector) / halfPI; } float getProjectionOnXYPlaneDirection(vec3 vector) { return atan(-vector.x, -vector.y); } float getProjectionOnXYPlaneNormalizedDirection(vec3 vector) { return (getProjectionOnXYPlaneDirection(vector) + PI) / doublePI; } vec3 addAtmosphericHaze(vec3 color) { return mix(color, vHazeColor.rgb, vHazeColor.a); } vec4 adjustRenderingParameters(vec4 color, float brightness, float saturation) { vec3 c = color.rgb; c = rgb2hsv(c); c.y *= saturation; c = hsv2rgb(c); c = c * brightness; return vec4(c, color.a); } void main() { vec3 textureNormal = texture2D(_Gradient, vGradientUv).rgb; textureNormal.xy = textureNormal.xy * 2.0 - 1.0; textureNormal.y = -textureNormal.y; textureNormal = applyMercatorScaleOnNormal(textureNormal); vec2 gPos; float normalizedDirection = getProjectionOnXYPlaneNormalizedDirection(textureNormal); float normalizedAngle = getNormalizedAngleBetweenAxisZ(textureNormal); gPos = vec2(normalizedAngle / 128.0 * 90.0, normalizedDirection); vec4 colMap = texture2D(_ColorMapTex, gPos); vec3 terrainColor = texture2D(_MainTex, vUv).rgb; terrainColor = addAtmosphericHaze(terrainColor); vec4 topoColor = vec4(0.0); if (isInsideTopoArea(vTopoUv.zw)) { topoColor = texture2D(_TopoTex, vTopoUv.xy); } vec4 overlayColor = vec4(0.0); overlayColor = vec4(vec3(colMap.rgb), colMap.a * vDistanceAlpha); vec4 generatedColor = texture2D(_GeneratedTex, vGeneratedUv); generatedColor.a = vDistanceAlpha * generatedColor.a; if (tileOutlineWidth > 0.0) { if (vUv.x < 0.05) terrainColor.r = 0.7; if (vUv.y < 0.05) terrainColor.r = 0.7; } vec4 c = adjustRenderingParameters(vec4(terrainColor, 1.0), renderingParameters[0], renderingParameters[1]); topoColor = adjustRenderingParameters(topoColor, renderingParameters[2], renderingParameters[3]); overlayColor = adjustRenderingParameters(overlayColor, renderingParameters[4], renderingParameters[5]); c.rgb = mix(c.rgb, topoColor.rgb, topoColor.a); c.rgb = mix(c.rgb, overlayColor.rgb, overlayColor.a); c.rgb = mix(c.rgb, generatedColor.rgb, generatedColor.a); gl_FragColor = c; } 6851 Terrain/Terrain-TOPO-CUSTOM.fs const int kSC_SymbolCullingDistanceFactor = 4; const int kSC_OSMTileCullingDistanceFactor = 4; const float kSC_MapboxZoomLevelOffset = 0.7; const int kSC_UseOSMDataFromAncestorDiff = 1; const int kSC_MaxOSMLevelFromServer = 15; const float kSC_Skybox_MinVisibleDistance = 500000.0; const float kSC_Skybox_Height = 1000000.0; const float kSC_UserMarker_OuterCircleRadius = 12.0; const int kSC_MaxBoundingBoxesPerTopoLayer = 16; const float kSC_CameraFOV = 42.0; const float kSC_ElevationExaggerationMinHeightRange = 200.0; const float kSC_ElevationExaggerationMinHeightRangeFactor = 1.9; const float kSC_ElevationExaggerationMaxHeightRange = 2000.0; const float kSC_ElevationExaggerationMaxHeightRangeFactor = 1.15; const float kSC_FlatModeExaggeration = 0.1; mat3 mat4ToMat3(mat4 m) { return mat3(m[0].xyz, m[1].xyz, m[2].xyz); } uniform float mercatorScale; uniform float elevationExaggerationFactor; vec4 upScalePoint(vec4 point, mat4 modelMatrix) { vec4 scaledPoint = point; float offsetZ = modelMatrix[3][2]; scaledPoint.z = (scaledPoint.z + offsetZ) * mercatorScale * elevationExaggerationFactor - offsetZ; return scaledPoint; } vec4 upScalePoint(vec4 vec) { vec4 scaledVec = vec; scaledVec.z *= mercatorScale * elevationExaggerationFactor; return scaledVec; } vec3 _applyScaleOnNormal(vec3 vec, float scale) { vec3 scaledVec = vec; scaledVec.xy *= scale; return normalize(scaledVec); } vec3 applyElevationScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale * elevationExaggerationFactor); } vec3 applyMercatorScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale); } vec3 rgb2hsv(vec3 c) { vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); float d = q.x - min(q.w, q.y); float e = 1.0e-10; return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); } vec3 hsv2rgb(vec3 c) { vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); } const float PI = 3.14159265359; const float halfPI = PI * 0.5; const float doublePI = PI * 2.0; uniform int loadState; varying vec2 vUv; varying vec4 vHazeColor; varying vec2 vGeneratedUv; varying float vDistanceAlpha; varying vec3 vPosition; varying vec4 vTopoUv; varying vec2 vGradientUv; uniform sampler2D _MainTex; uniform sampler2D _Gradient; uniform sampler2D _SecondaryTex; uniform sampler2D _GeneratedTex; uniform sampler2D _TopoTex; uniform sampler2D _ColorMapTex; uniform float tileOutlineWidth; uniform float renderingParameters[6]; uniform vec3 viewLightDirection; uniform float altitudeMin; uniform float elevationFrom; uniform float elevationTo; uniform float gradientFrom; uniform float gradientTo; uniform vec4 topoBoundingBoxes[16]; uniform int numTopoBoundingBoxes; bool isInsideTopoArea(vec2 worldPos) { for (int i = 0; i < numTopoBoundingBoxes; ++i) { vec4 bounds = topoBoundingBoxes[i]; if (clamp(worldPos, bounds.xy, bounds.zw) == worldPos) { return true; } } return false; } vec3 drawStates(vec3 c) { vec3 dc; if (loadState == 30) dc = vec3(0.0, 1.0, 0.0); if (loadState == 40) dc = vec3(1.0, 0.0, 0.0); if (loadState == 50) dc = vec3(1.0, 1.0, 1.0); if (loadState == 0) dc = vec3(1.0, 0.0, 0.0); if (loadState == 1) dc = vec3(0.0, 0.0, 1.0); if (loadState == 2) dc = vec3(0.5, 0.5, 1.0); if (loadState == 3) dc = vec3(1.0, 1.0, 0.0); if (loadState == 4) dc = vec3(0.0, 1.0, 0.0); return mix(c, dc, 0.3); } float getAngleBetweenAxisZ(vec3 vector) { float angle = acos(normalize(vector).z); return angle > halfPI ? halfPI : angle; } float getProjectionOnXYPlaneDirection(vec3 vector) { return atan(-vector.x, -vector.y); } float getProjectionOnXYPlaneNormalizedDirection(vec3 vector) { return (getProjectionOnXYPlaneDirection(vector) + PI) / doublePI; } vec3 addAtmosphericHaze(vec3 color) { return mix(color, vHazeColor.rgb, vHazeColor.a); } vec4 adjustRenderingParameters(vec4 color, float brightness, float saturation) { vec3 c = color.rgb; c = rgb2hsv(c); c.y *= saturation; c = hsv2rgb(c); c = c * brightness; return vec4(c, color.a); } void main() { vec3 textureNormal = texture2D(_Gradient, vGradientUv).rgb; textureNormal.xy = textureNormal.xy * 2.0 - 1.0; textureNormal.y = -textureNormal.y; textureNormal = applyMercatorScaleOnNormal(textureNormal); vec2 gPos; bool isValidForRender = true; if (isValidForRender) { float actualHeight = vPosition.z - altitudeMin; isValidForRender = actualHeight >= elevationFrom && actualHeight <= elevationTo; } if (isValidForRender) { float angleUp = degrees(getAngleBetweenAxisZ(textureNormal)); isValidForRender = ((angleUp >= gradientFrom) && (angleUp <= gradientTo)); } if (isValidForRender && length(textureNormal.xy) >= 0.001) { float normalizedDirection = getProjectionOnXYPlaneNormalizedDirection(textureNormal); gPos = vec2(normalizedDirection / 512.0 * 360.0, 0.5); vec4 colMap = texture2D(_ColorMapTex, gPos); isValidForRender = colMap.g > 0.0; } vec4 colMap = vec4(0.024, 0.918, 0.506, isValidForRender ? 0.7 : 0.0); vec3 terrainColor = texture2D(_MainTex, vUv).rgb; terrainColor = addAtmosphericHaze(terrainColor); vec4 topoColor = vec4(0.0); if (isInsideTopoArea(vTopoUv.zw)) { topoColor = texture2D(_TopoTex, vTopoUv.xy); } vec4 overlayColor = vec4(0.0); float litTerrain = clamp(-dot(textureNormal, viewLightDirection), 0.0, 1.0); litTerrain = pow(litTerrain, 2.0); litTerrain = mix(0.5, 1.0, litTerrain); overlayColor = vec4(vec3(colMap.rgb * litTerrain), colMap.a * vDistanceAlpha); vec4 generatedColor = texture2D(_GeneratedTex, vGeneratedUv); generatedColor.a = vDistanceAlpha * generatedColor.a; if (tileOutlineWidth > 0.0) { if (vUv.x < 0.05) terrainColor.r = 0.7; if (vUv.y < 0.05) terrainColor.r = 0.7; } vec4 c = adjustRenderingParameters(vec4(terrainColor, 1.0), renderingParameters[0], renderingParameters[1]); topoColor = adjustRenderingParameters(topoColor, renderingParameters[2], renderingParameters[3]); overlayColor = adjustRenderingParameters(overlayColor, renderingParameters[4], renderingParameters[5]); c.rgb = mix(c.rgb, topoColor.rgb, topoColor.a); c.rgb = mix(c.rgb, overlayColor.rgb, overlayColor.a); c.rgb = mix(c.rgb, generatedColor.rgb, generatedColor.a); gl_FragColor = c; } 5930 Terrain/Terrain-TOPO-GRADIENT.fs const int kSC_SymbolCullingDistanceFactor = 4; const int kSC_OSMTileCullingDistanceFactor = 4; const float kSC_MapboxZoomLevelOffset = 0.7; const int kSC_UseOSMDataFromAncestorDiff = 1; const int kSC_MaxOSMLevelFromServer = 15; const float kSC_Skybox_MinVisibleDistance = 500000.0; const float kSC_Skybox_Height = 1000000.0; const float kSC_UserMarker_OuterCircleRadius = 12.0; const int kSC_MaxBoundingBoxesPerTopoLayer = 16; const float kSC_CameraFOV = 42.0; const float kSC_ElevationExaggerationMinHeightRange = 200.0; const float kSC_ElevationExaggerationMinHeightRangeFactor = 1.9; const float kSC_ElevationExaggerationMaxHeightRange = 2000.0; const float kSC_ElevationExaggerationMaxHeightRangeFactor = 1.15; const float kSC_FlatModeExaggeration = 0.1; mat3 mat4ToMat3(mat4 m) { return mat3(m[0].xyz, m[1].xyz, m[2].xyz); } uniform float mercatorScale; uniform float elevationExaggerationFactor; vec4 upScalePoint(vec4 point, mat4 modelMatrix) { vec4 scaledPoint = point; float offsetZ = modelMatrix[3][2]; scaledPoint.z = (scaledPoint.z + offsetZ) * mercatorScale * elevationExaggerationFactor - offsetZ; return scaledPoint; } vec4 upScalePoint(vec4 vec) { vec4 scaledVec = vec; scaledVec.z *= mercatorScale * elevationExaggerationFactor; return scaledVec; } vec3 _applyScaleOnNormal(vec3 vec, float scale) { vec3 scaledVec = vec; scaledVec.xy *= scale; return normalize(scaledVec); } vec3 applyElevationScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale * elevationExaggerationFactor); } vec3 applyMercatorScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale); } vec3 rgb2hsv(vec3 c) { vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); float d = q.x - min(q.w, q.y); float e = 1.0e-10; return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); } vec3 hsv2rgb(vec3 c) { vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); } const float PI = 3.14159265359; const float halfPI = PI * 0.5; const float doublePI = PI * 2.0; uniform int loadState; varying vec2 vUv; varying vec4 vHazeColor; varying vec2 vGeneratedUv; varying float vDistanceAlpha; varying vec4 vTopoUv; varying vec2 vGradientUv; uniform sampler2D _MainTex; uniform sampler2D _Gradient; uniform sampler2D _SecondaryTex; uniform sampler2D _GeneratedTex; uniform sampler2D _TopoTex; uniform sampler2D _ColorMapTex; uniform float tileOutlineWidth; uniform float renderingParameters[6]; uniform vec3 viewLightDirection; uniform vec4 topoBoundingBoxes[16]; uniform int numTopoBoundingBoxes; bool isInsideTopoArea(vec2 worldPos) { for (int i = 0; i < numTopoBoundingBoxes; ++i) { vec4 bounds = topoBoundingBoxes[i]; if (clamp(worldPos, bounds.xy, bounds.zw) == worldPos) { return true; } } return false; } vec3 drawStates(vec3 c) { vec3 dc; if (loadState == 30) dc = vec3(0.0, 1.0, 0.0); if (loadState == 40) dc = vec3(1.0, 0.0, 0.0); if (loadState == 50) dc = vec3(1.0, 1.0, 1.0); if (loadState == 0) dc = vec3(1.0, 0.0, 0.0); if (loadState == 1) dc = vec3(0.0, 0.0, 1.0); if (loadState == 2) dc = vec3(0.5, 0.5, 1.0); if (loadState == 3) dc = vec3(1.0, 1.0, 0.0); if (loadState == 4) dc = vec3(0.0, 1.0, 0.0); return mix(c, dc, 0.3); } float getAngleBetweenAxisZ(vec3 vector) { float angle = acos(normalize(vector).z); return angle > halfPI ? halfPI : angle; } float getNormalizedAngleBetweenAxisZ(vec3 vector) { return getAngleBetweenAxisZ(vector) / halfPI; } vec3 addAtmosphericHaze(vec3 color) { return mix(color, vHazeColor.rgb, vHazeColor.a); } vec4 adjustRenderingParameters(vec4 color, float brightness, float saturation) { vec3 c = color.rgb; c = rgb2hsv(c); c.y *= saturation; c = hsv2rgb(c); c = c * brightness; return vec4(c, color.a); } void main() { vec3 textureNormal = texture2D(_Gradient, vGradientUv).rgb; textureNormal.xy = textureNormal.xy * 2.0 - 1.0; textureNormal.y = -textureNormal.y; textureNormal = applyMercatorScaleOnNormal(textureNormal); vec2 gPos; float normalizedAngle = getNormalizedAngleBetweenAxisZ(textureNormal); gPos = vec2(normalizedAngle / 128.0 * 90.0, 0); vec4 colMap = texture2D(_ColorMapTex, gPos); vec3 terrainColor = texture2D(_MainTex, vUv).rgb; terrainColor = addAtmosphericHaze(terrainColor); vec4 topoColor = vec4(0.0); if (isInsideTopoArea(vTopoUv.zw)) { topoColor = texture2D(_TopoTex, vTopoUv.xy); } vec4 overlayColor = vec4(0.0); float litTerrain = clamp(-dot(textureNormal, viewLightDirection), 0.0, 1.0); litTerrain = pow(litTerrain, 2.0); litTerrain = mix(0.5, 1.0, litTerrain); overlayColor = vec4(vec3(colMap.rgb * litTerrain), colMap.a * vDistanceAlpha); vec4 generatedColor = texture2D(_GeneratedTex, vGeneratedUv); generatedColor.a = vDistanceAlpha * generatedColor.a; if (tileOutlineWidth > 0.0) { if (vUv.x < 0.05) terrainColor.r = 0.7; if (vUv.y < 0.05) terrainColor.r = 0.7; } vec4 c = adjustRenderingParameters(vec4(terrainColor, 1.0), renderingParameters[0], renderingParameters[1]); topoColor = adjustRenderingParameters(topoColor, renderingParameters[2], renderingParameters[3]); overlayColor = adjustRenderingParameters(overlayColor, renderingParameters[4], renderingParameters[5]); c.rgb = mix(c.rgb, topoColor.rgb, topoColor.a); c.rgb = mix(c.rgb, overlayColor.rgb, overlayColor.a); c.rgb = mix(c.rgb, generatedColor.rgb, generatedColor.a); gl_FragColor = c; } 5720 Terrain/Terrain-TOPO-GRADIENT_FLAT.fs const int kSC_SymbolCullingDistanceFactor = 4; const int kSC_OSMTileCullingDistanceFactor = 4; const float kSC_MapboxZoomLevelOffset = 0.7; const int kSC_UseOSMDataFromAncestorDiff = 1; const int kSC_MaxOSMLevelFromServer = 15; const float kSC_Skybox_MinVisibleDistance = 500000.0; const float kSC_Skybox_Height = 1000000.0; const float kSC_UserMarker_OuterCircleRadius = 12.0; const int kSC_MaxBoundingBoxesPerTopoLayer = 16; const float kSC_CameraFOV = 42.0; const float kSC_ElevationExaggerationMinHeightRange = 200.0; const float kSC_ElevationExaggerationMinHeightRangeFactor = 1.9; const float kSC_ElevationExaggerationMaxHeightRange = 2000.0; const float kSC_ElevationExaggerationMaxHeightRangeFactor = 1.15; const float kSC_FlatModeExaggeration = 0.1; mat3 mat4ToMat3(mat4 m) { return mat3(m[0].xyz, m[1].xyz, m[2].xyz); } uniform float mercatorScale; uniform float elevationExaggerationFactor; vec4 upScalePoint(vec4 point, mat4 modelMatrix) { vec4 scaledPoint = point; float offsetZ = modelMatrix[3][2]; scaledPoint.z = (scaledPoint.z + offsetZ) * mercatorScale * elevationExaggerationFactor - offsetZ; return scaledPoint; } vec4 upScalePoint(vec4 vec) { vec4 scaledVec = vec; scaledVec.z *= mercatorScale * elevationExaggerationFactor; return scaledVec; } vec3 _applyScaleOnNormal(vec3 vec, float scale) { vec3 scaledVec = vec; scaledVec.xy *= scale; return normalize(scaledVec); } vec3 applyElevationScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale * elevationExaggerationFactor); } vec3 applyMercatorScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale); } vec3 rgb2hsv(vec3 c) { vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); float d = q.x - min(q.w, q.y); float e = 1.0e-10; return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); } vec3 hsv2rgb(vec3 c) { vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); } const float PI = 3.14159265359; const float halfPI = PI * 0.5; const float doublePI = PI * 2.0; uniform int loadState; varying vec2 vUv; varying vec4 vHazeColor; varying vec2 vGeneratedUv; varying float vDistanceAlpha; varying vec4 vTopoUv; varying vec2 vGradientUv; uniform sampler2D _MainTex; uniform sampler2D _Gradient; uniform sampler2D _SecondaryTex; uniform sampler2D _GeneratedTex; uniform sampler2D _TopoTex; uniform sampler2D _ColorMapTex; uniform float tileOutlineWidth; uniform float renderingParameters[6]; uniform vec4 topoBoundingBoxes[16]; uniform int numTopoBoundingBoxes; bool isInsideTopoArea(vec2 worldPos) { for (int i = 0; i < numTopoBoundingBoxes; ++i) { vec4 bounds = topoBoundingBoxes[i]; if (clamp(worldPos, bounds.xy, bounds.zw) == worldPos) { return true; } } return false; } vec3 drawStates(vec3 c) { vec3 dc; if (loadState == 30) dc = vec3(0.0, 1.0, 0.0); if (loadState == 40) dc = vec3(1.0, 0.0, 0.0); if (loadState == 50) dc = vec3(1.0, 1.0, 1.0); if (loadState == 0) dc = vec3(1.0, 0.0, 0.0); if (loadState == 1) dc = vec3(0.0, 0.0, 1.0); if (loadState == 2) dc = vec3(0.5, 0.5, 1.0); if (loadState == 3) dc = vec3(1.0, 1.0, 0.0); if (loadState == 4) dc = vec3(0.0, 1.0, 0.0); return mix(c, dc, 0.3); } float getAngleBetweenAxisZ(vec3 vector) { float angle = acos(normalize(vector).z); return angle > halfPI ? halfPI : angle; } float getNormalizedAngleBetweenAxisZ(vec3 vector) { return getAngleBetweenAxisZ(vector) / halfPI; } vec3 addAtmosphericHaze(vec3 color) { return mix(color, vHazeColor.rgb, vHazeColor.a); } vec4 adjustRenderingParameters(vec4 color, float brightness, float saturation) { vec3 c = color.rgb; c = rgb2hsv(c); c.y *= saturation; c = hsv2rgb(c); c = c * brightness; return vec4(c, color.a); } void main() { vec3 textureNormal = texture2D(_Gradient, vGradientUv).rgb; textureNormal.xy = textureNormal.xy * 2.0 - 1.0; textureNormal.y = -textureNormal.y; textureNormal = applyMercatorScaleOnNormal(textureNormal); vec2 gPos; float normalizedAngle = getNormalizedAngleBetweenAxisZ(textureNormal); gPos = vec2(normalizedAngle / 128.0 * 90.0, 0); vec4 colMap = texture2D(_ColorMapTex, gPos); vec3 terrainColor = texture2D(_MainTex, vUv).rgb; terrainColor = addAtmosphericHaze(terrainColor); vec4 topoColor = vec4(0.0); if (isInsideTopoArea(vTopoUv.zw)) { topoColor = texture2D(_TopoTex, vTopoUv.xy); } vec4 overlayColor = vec4(0.0); overlayColor = vec4(vec3(colMap.rgb), colMap.a * vDistanceAlpha); vec4 generatedColor = texture2D(_GeneratedTex, vGeneratedUv); generatedColor.a = vDistanceAlpha * generatedColor.a; if (tileOutlineWidth > 0.0) { if (vUv.x < 0.05) terrainColor.r = 0.7; if (vUv.y < 0.05) terrainColor.r = 0.7; } vec4 c = adjustRenderingParameters(vec4(terrainColor, 1.0), renderingParameters[0], renderingParameters[1]); topoColor = adjustRenderingParameters(topoColor, renderingParameters[2], renderingParameters[3]); overlayColor = adjustRenderingParameters(overlayColor, renderingParameters[4], renderingParameters[5]); c.rgb = mix(c.rgb, topoColor.rgb, topoColor.a); c.rgb = mix(c.rgb, overlayColor.rgb, overlayColor.a); c.rgb = mix(c.rgb, generatedColor.rgb, generatedColor.a); gl_FragColor = c; } 5858 Terrain/Terrain-TOPO-GRID.fs const int kSC_SymbolCullingDistanceFactor = 4; const int kSC_OSMTileCullingDistanceFactor = 4; const float kSC_MapboxZoomLevelOffset = 0.7; const int kSC_UseOSMDataFromAncestorDiff = 1; const int kSC_MaxOSMLevelFromServer = 15; const float kSC_Skybox_MinVisibleDistance = 500000.0; const float kSC_Skybox_Height = 1000000.0; const float kSC_UserMarker_OuterCircleRadius = 12.0; const int kSC_MaxBoundingBoxesPerTopoLayer = 16; const float kSC_CameraFOV = 42.0; const float kSC_ElevationExaggerationMinHeightRange = 200.0; const float kSC_ElevationExaggerationMinHeightRangeFactor = 1.9; const float kSC_ElevationExaggerationMaxHeightRange = 2000.0; const float kSC_ElevationExaggerationMaxHeightRangeFactor = 1.15; const float kSC_FlatModeExaggeration = 0.1; mat3 mat4ToMat3(mat4 m) { return mat3(m[0].xyz, m[1].xyz, m[2].xyz); } uniform float mercatorScale; uniform float elevationExaggerationFactor; vec4 upScalePoint(vec4 point, mat4 modelMatrix) { vec4 scaledPoint = point; float offsetZ = modelMatrix[3][2]; scaledPoint.z = (scaledPoint.z + offsetZ) * mercatorScale * elevationExaggerationFactor - offsetZ; return scaledPoint; } vec4 upScalePoint(vec4 vec) { vec4 scaledVec = vec; scaledVec.z *= mercatorScale * elevationExaggerationFactor; return scaledVec; } vec3 _applyScaleOnNormal(vec3 vec, float scale) { vec3 scaledVec = vec; scaledVec.xy *= scale; return normalize(scaledVec); } vec3 applyElevationScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale * elevationExaggerationFactor); } vec3 applyMercatorScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale); } vec3 rgb2hsv(vec3 c) { vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); float d = q.x - min(q.w, q.y); float e = 1.0e-10; return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); } vec3 hsv2rgb(vec3 c) { vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); } const float PI = 3.14159265359; const float halfPI = PI * 0.5; const float doublePI = PI * 2.0; uniform int loadState; varying vec2 vUv; varying vec4 vHazeColor; varying vec2 vGeneratedUv; varying float vDistanceAlpha; varying float vDepth; varying vec3 vPosition; varying vec4 vTopoUv; uniform sampler2D _MainTex; uniform sampler2D _Gradient; uniform sampler2D _SecondaryTex; uniform sampler2D _GeneratedTex; uniform sampler2D _TopoTex; uniform sampler2D _ColorMapTex; uniform float tileOutlineWidth; uniform float renderingParameters[6]; uniform vec3 gridColor; uniform float gridScale; uniform float gridThickness; uniform vec2 gridSnapPoint; uniform float gridOpacity; uniform float gridSharpness; uniform vec4 topoBoundingBoxes[16]; uniform int numTopoBoundingBoxes; bool isInsideTopoArea(vec2 worldPos) { for (int i = 0; i < numTopoBoundingBoxes; ++i) { vec4 bounds = topoBoundingBoxes[i]; if (clamp(worldPos, bounds.xy, bounds.zw) == worldPos) { return true; } } return false; } vec2 _round(vec2 value) { return floor(value + 0.5); } vec4 drawGrid(vec2 uv, float distanceAlpha) { vec2 pos = vPosition.xy - gridSnapPoint; vec2 _uv = abs(pos); _uv = abs(_uv - _round(_uv.xy / gridScale) * gridScale); float dist = min(_uv.x, _uv.y); float K = abs(vDepth) * gridThickness; if (dist < K) { float lineAlpha = 1.0 - dist / K; lineAlpha = mix(0.0, 1.0, clamp(lineAlpha * gridSharpness, 0.0, 1.0)); float alpha = clamp(lineAlpha * distanceAlpha, 0.0, 1.0); return vec4(gridColor, alpha * gridOpacity); } return vec4(0.0); } vec3 drawStates(vec3 c) { vec3 dc; if (loadState == 30) dc = vec3(0.0, 1.0, 0.0); if (loadState == 40) dc = vec3(1.0, 0.0, 0.0); if (loadState == 50) dc = vec3(1.0, 1.0, 1.0); if (loadState == 0) dc = vec3(1.0, 0.0, 0.0); if (loadState == 1) dc = vec3(0.0, 0.0, 1.0); if (loadState == 2) dc = vec3(0.5, 0.5, 1.0); if (loadState == 3) dc = vec3(1.0, 1.0, 0.0); if (loadState == 4) dc = vec3(0.0, 1.0, 0.0); return mix(c, dc, 0.3); } vec3 addAtmosphericHaze(vec3 color) { return mix(color, vHazeColor.rgb, vHazeColor.a); } vec4 adjustRenderingParameters(vec4 color, float brightness, float saturation) { vec3 c = color.rgb; c = rgb2hsv(c); c.y *= saturation; c = hsv2rgb(c); c = c * brightness; return vec4(c, color.a); } void main() { vec2 gPos; vec3 terrainColor = texture2D(_MainTex, vUv).rgb; terrainColor = addAtmosphericHaze(terrainColor); vec4 topoColor = vec4(0.0); if (isInsideTopoArea(vTopoUv.zw)) { topoColor = texture2D(_TopoTex, vTopoUv.xy); } vec4 overlayColor = vec4(0.0); overlayColor = drawGrid(vUv, vDistanceAlpha); vec4 generatedColor = texture2D(_GeneratedTex, vGeneratedUv); generatedColor.a = vDistanceAlpha * generatedColor.a; if (tileOutlineWidth > 0.0) { if (vUv.x < 0.05) terrainColor.r = 0.7; if (vUv.y < 0.05) terrainColor.r = 0.7; } vec4 c = adjustRenderingParameters(vec4(terrainColor, 1.0), renderingParameters[0], renderingParameters[1]); topoColor = adjustRenderingParameters(topoColor, renderingParameters[2], renderingParameters[3]); overlayColor = adjustRenderingParameters(overlayColor, renderingParameters[4], renderingParameters[5]); c.rgb = mix(c.rgb, topoColor.rgb, topoColor.a); c.rgb = mix(c.rgb, overlayColor.rgb, overlayColor.a); c.rgb = mix(c.rgb, generatedColor.rgb, generatedColor.a); gl_FragColor = c; } 5165 Terrain/Terrain-TOPO-SNOW_COVER.fs const int kSC_SymbolCullingDistanceFactor = 4; const int kSC_OSMTileCullingDistanceFactor = 4; const float kSC_MapboxZoomLevelOffset = 0.7; const int kSC_UseOSMDataFromAncestorDiff = 1; const int kSC_MaxOSMLevelFromServer = 15; const float kSC_Skybox_MinVisibleDistance = 500000.0; const float kSC_Skybox_Height = 1000000.0; const float kSC_UserMarker_OuterCircleRadius = 12.0; const int kSC_MaxBoundingBoxesPerTopoLayer = 16; const float kSC_CameraFOV = 42.0; const float kSC_ElevationExaggerationMinHeightRange = 200.0; const float kSC_ElevationExaggerationMinHeightRangeFactor = 1.9; const float kSC_ElevationExaggerationMaxHeightRange = 2000.0; const float kSC_ElevationExaggerationMaxHeightRangeFactor = 1.15; const float kSC_FlatModeExaggeration = 0.1; mat3 mat4ToMat3(mat4 m) { return mat3(m[0].xyz, m[1].xyz, m[2].xyz); } uniform float mercatorScale; uniform float elevationExaggerationFactor; vec4 upScalePoint(vec4 point, mat4 modelMatrix) { vec4 scaledPoint = point; float offsetZ = modelMatrix[3][2]; scaledPoint.z = (scaledPoint.z + offsetZ) * mercatorScale * elevationExaggerationFactor - offsetZ; return scaledPoint; } vec4 upScalePoint(vec4 vec) { vec4 scaledVec = vec; scaledVec.z *= mercatorScale * elevationExaggerationFactor; return scaledVec; } vec3 _applyScaleOnNormal(vec3 vec, float scale) { vec3 scaledVec = vec; scaledVec.xy *= scale; return normalize(scaledVec); } vec3 applyElevationScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale * elevationExaggerationFactor); } vec3 applyMercatorScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale); } vec3 rgb2hsv(vec3 c) { vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); float d = q.x - min(q.w, q.y); float e = 1.0e-10; return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); } vec3 hsv2rgb(vec3 c) { vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); } const float PI = 3.14159265359; const float halfPI = PI * 0.5; const float doublePI = PI * 2.0; uniform int loadState; varying vec2 vUv; varying vec4 vHazeColor; varying vec2 vGeneratedUv; varying float vDistanceAlpha; varying vec2 vSnowCoverUv; varying vec4 vTopoUv; uniform sampler2D _MainTex; uniform sampler2D _Gradient; uniform sampler2D _SecondaryTex; uniform sampler2D _GeneratedTex; uniform sampler2D _TopoTex; uniform sampler2D _ColorMapTex; uniform float tileOutlineWidth; uniform float renderingParameters[6]; uniform vec4 topoBoundingBoxes[16]; uniform int numTopoBoundingBoxes; bool isInsideTopoArea(vec2 worldPos) { for (int i = 0; i < numTopoBoundingBoxes; ++i) { vec4 bounds = topoBoundingBoxes[i]; if (clamp(worldPos, bounds.xy, bounds.zw) == worldPos) { return true; } } return false; } vec3 drawStates(vec3 c) { vec3 dc; if (loadState == 30) dc = vec3(0.0, 1.0, 0.0); if (loadState == 40) dc = vec3(1.0, 0.0, 0.0); if (loadState == 50) dc = vec3(1.0, 1.0, 1.0); if (loadState == 0) dc = vec3(1.0, 0.0, 0.0); if (loadState == 1) dc = vec3(0.0, 0.0, 1.0); if (loadState == 2) dc = vec3(0.5, 0.5, 1.0); if (loadState == 3) dc = vec3(1.0, 1.0, 0.0); if (loadState == 4) dc = vec3(0.0, 1.0, 0.0); return mix(c, dc, 0.3); } vec3 addAtmosphericHaze(vec3 color) { return mix(color, vHazeColor.rgb, vHazeColor.a); } vec4 adjustRenderingParameters(vec4 color, float brightness, float saturation) { vec3 c = color.rgb; c = rgb2hsv(c); c.y *= saturation; c = hsv2rgb(c); c = c * brightness; return vec4(c, color.a); } void main() { vec2 gPos; vec3 terrainColor = texture2D(_MainTex, vUv).rgb; terrainColor = addAtmosphericHaze(terrainColor); vec4 topoColor = vec4(0.0); if (isInsideTopoArea(vTopoUv.zw)) { topoColor = texture2D(_TopoTex, vTopoUv.xy); } vec4 overlayColor = vec4(0.0); vec4 snowCover = texture2D(_SecondaryTex, vSnowCoverUv); overlayColor = vec4(vec3(snowCover.rgb), vDistanceAlpha * 0.4 * snowCover.a); vec4 generatedColor = texture2D(_GeneratedTex, vGeneratedUv); generatedColor.a = vDistanceAlpha * generatedColor.a; if (tileOutlineWidth > 0.0) { if (vUv.x < 0.05) terrainColor.r = 0.7; if (vUv.y < 0.05) terrainColor.r = 0.7; } vec4 c = adjustRenderingParameters(vec4(terrainColor, 1.0), renderingParameters[0], renderingParameters[1]); topoColor = adjustRenderingParameters(topoColor, renderingParameters[2], renderingParameters[3]); overlayColor = adjustRenderingParameters(overlayColor, renderingParameters[4], renderingParameters[5]); c.rgb = mix(c.rgb, topoColor.rgb, topoColor.a); c.rgb = mix(c.rgb, overlayColor.rgb, overlayColor.a); c.rgb = mix(c.rgb, generatedColor.rgb, generatedColor.a); gl_FragColor = c; } 7699 Terrain/Terrain-TOPO-TRAVEL_DISTANCE.fs const int kSC_SymbolCullingDistanceFactor = 4; const int kSC_OSMTileCullingDistanceFactor = 4; const float kSC_MapboxZoomLevelOffset = 0.7; const int kSC_UseOSMDataFromAncestorDiff = 1; const int kSC_MaxOSMLevelFromServer = 15; const float kSC_Skybox_MinVisibleDistance = 500000.0; const float kSC_Skybox_Height = 1000000.0; const float kSC_UserMarker_OuterCircleRadius = 12.0; const int kSC_MaxBoundingBoxesPerTopoLayer = 16; const float kSC_CameraFOV = 42.0; const float kSC_ElevationExaggerationMinHeightRange = 200.0; const float kSC_ElevationExaggerationMinHeightRangeFactor = 1.9; const float kSC_ElevationExaggerationMaxHeightRange = 2000.0; const float kSC_ElevationExaggerationMaxHeightRangeFactor = 1.15; const float kSC_FlatModeExaggeration = 0.1; mat3 mat4ToMat3(mat4 m) { return mat3(m[0].xyz, m[1].xyz, m[2].xyz); } uniform float mercatorScale; uniform float elevationExaggerationFactor; vec4 upScalePoint(vec4 point, mat4 modelMatrix) { vec4 scaledPoint = point; float offsetZ = modelMatrix[3][2]; scaledPoint.z = (scaledPoint.z + offsetZ) * mercatorScale * elevationExaggerationFactor - offsetZ; return scaledPoint; } vec4 upScalePoint(vec4 vec) { vec4 scaledVec = vec; scaledVec.z *= mercatorScale * elevationExaggerationFactor; return scaledVec; } vec3 _applyScaleOnNormal(vec3 vec, float scale) { vec3 scaledVec = vec; scaledVec.xy *= scale; return normalize(scaledVec); } vec3 applyElevationScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale * elevationExaggerationFactor); } vec3 applyMercatorScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale); } vec3 rgb2hsv(vec3 c) { vec4 K = vec4(0.0, -1.0 / 3.0, 2.0 / 3.0, -1.0); vec4 p = mix(vec4(c.bg, K.wz), vec4(c.gb, K.xy), step(c.b, c.g)); vec4 q = mix(vec4(p.xyw, c.r), vec4(c.r, p.yzx), step(p.x, c.r)); float d = q.x - min(q.w, q.y); float e = 1.0e-10; return vec3(abs(q.z + (q.w - q.y) / (6.0 * d + e)), d / (q.x + e), q.x); } vec3 hsv2rgb(vec3 c) { vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www); return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y); } const float PI = 3.14159265359; const float halfPI = PI * 0.5; const float doublePI = PI * 2.0; uniform int loadState; varying vec2 vUv; varying vec4 vHazeColor; varying vec2 vGeneratedUv; varying float vDistanceAlpha; varying float vDepth; varying vec4 vTopoUv; varying vec2 vWorldPosition; uniform sampler2D _MainTex; uniform sampler2D _Gradient; uniform sampler2D _SecondaryTex; uniform sampler2D _GeneratedTex; uniform sampler2D _TopoTex; uniform sampler2D _ColorMapTex; uniform float tileOutlineWidth; uniform float renderingParameters[6]; uniform float targetPositionX; uniform float targetPositionY; uniform float textureWorldExtents; uniform float timeRange; uniform float timeHighlight; uniform float timeInterval; uniform float calculationProgress; uniform vec4 topoBoundingBoxes[16]; uniform int numTopoBoundingBoxes; bool isInsideTopoArea(vec2 worldPos) { for (int i = 0; i < numTopoBoundingBoxes; ++i) { vec4 bounds = topoBoundingBoxes[i]; if (clamp(worldPos, bounds.xy, bounds.zw) == worldPos) { return true; } } return false; } vec3 drawStates(vec3 c) { vec3 dc; if (loadState == 30) dc = vec3(0.0, 1.0, 0.0); if (loadState == 40) dc = vec3(1.0, 0.0, 0.0); if (loadState == 50) dc = vec3(1.0, 1.0, 1.0); if (loadState == 0) dc = vec3(1.0, 0.0, 0.0); if (loadState == 1) dc = vec3(0.0, 0.0, 1.0); if (loadState == 2) dc = vec3(0.5, 0.5, 1.0); if (loadState == 3) dc = vec3(1.0, 1.0, 0.0); if (loadState == 4) dc = vec3(0.0, 1.0, 0.0); return mix(c, dc, 0.3); } vec3 addAtmosphericHaze(vec3 color) { return mix(color, vHazeColor.rgb, vHazeColor.a); } void travelDistanceTimeHighlight(float travelDistanceValue, inout float opacity, inout vec3 color) { float highlightWidth = timeInterval / 60.0 / 2.0; float highlightDistance = (travelDistanceValue - timeHighlight) * min(15000.0 / vDepth, 3.0); const float kWidth1 = 0.5; const float kWidth2 = 0.8 + kWidth1; const float kWidth3 = 1.0 + kWidth2; if (highlightDistance >= 0.0) { } else if (highlightDistance > -highlightWidth * kWidth1) { color = vec3(0.33, 0.19, 0.69); opacity = 1.0; } else if (highlightDistance > -highlightWidth * kWidth2) { color = vec3(1.0, 0.44, 0.0); opacity = 1.0; } else if (highlightDistance > -highlightWidth * kWidth3) { color = vec3(1.0, 0.7, 0.0); opacity = 0.9; } } vec4 adjustRenderingParameters(vec4 color, float brightness, float saturation) { vec3 c = color.rgb; c = rgb2hsv(c); c.y *= saturation; c = hsv2rgb(c); c = c * brightness; return vec4(c, color.a); } void main() { vec2 gPos; vec3 terrainColor = texture2D(_MainTex, vUv).rgb; terrainColor = addAtmosphericHaze(terrainColor); vec4 topoColor = vec4(0.0); if (isInsideTopoArea(vTopoUv.zw)) { topoColor = texture2D(_TopoTex, vTopoUv.xy); } vec4 overlayColor = vec4(0.0); vec2 dir = vec2(vWorldPosition.x - targetPositionX, vWorldPosition.y - targetPositionY); float dist = length(dir); float distanceFromCenter = length(dir) / textureWorldExtents; float opacity = 0.0; vec3 color = vec3(0, 0, 0); if (calculationProgress >= 0.0) { opacity = distanceFromCenter < calculationProgress * timeRange ? 0.0 : 0.65; } else { vec2 colMapUV = dir / textureWorldExtents / 2.0 + 0.5; vec3 colMap = texture2D(_ColorMapTex, colMapUV).rgb; if (colMap.g >= timeRange || distanceFromCenter > 1.0) { opacity = 0.85; travelDistanceTimeHighlight(colMap.g, opacity, color); } else { if (distanceFromCenter > 0.98) { opacity = 0.8; color = vec3(0.2, 1.0, 0.0); } else { float interval = timeRange / timeInterval < 6.0 ? (timeRange / 2.0 / 3.0) : timeInterval; color = vec3(1.0, 0.7, 0.0); if (colMap.g >= timeRange - interval) { opacity = 0.6; } else if (colMap.g >= timeRange - interval * 2.0) { opacity = 0.4; } else if (colMap.g >= timeRange - interval * 3.0) { opacity = 0.2; } travelDistanceTimeHighlight(colMap.g, opacity, color); } } } overlayColor = vec4(vec3(color), opacity); vec4 generatedColor = texture2D(_GeneratedTex, vGeneratedUv); generatedColor.a = vDistanceAlpha * generatedColor.a; if (tileOutlineWidth > 0.0) { if (vUv.x < 0.05) terrainColor.r = 0.7; if (vUv.y < 0.05) terrainColor.r = 0.7; } vec4 c = adjustRenderingParameters(vec4(terrainColor, 1.0), renderingParameters[0], renderingParameters[1]); topoColor = adjustRenderingParameters(topoColor, renderingParameters[2], renderingParameters[3]); overlayColor = adjustRenderingParameters(overlayColor, renderingParameters[4], renderingParameters[5]); c.rgb = mix(c.rgb, topoColor.rgb, topoColor.a); c.rgb = mix(c.rgb, overlayColor.rgb, overlayColor.a); c.rgb = mix(c.rgb, generatedColor.rgb, generatedColor.a); gl_FragColor = c; } 871 Terrain/TerrainVectormap.vs attribute vec4 position; attribute vec3 normal; attribute vec2 uv0; uniform float mercatorScale; uniform float elevationExaggerationFactor; uniform mat4 modelMatrix; uniform mat4 modelViewMatrix; uniform mat4 projectionMatrix; uniform vec3 cameraPosition; uniform vec4 _TopoTransform; varying vec2 vUv; vec4 upScalePoint(vec4 vec) { vec4 scaledVec = vec; scaledVec.z *= mercatorScale * elevationExaggerationFactor; return scaledVec; } vec2 CalculateUV(vec4 ipos, vec4 texTransform) { return (ipos.xy - texTransform.xy) / texTransform.zw; } vec4 calc_vertex_pos() { vec3 outPos = position.xyz; vUv = CalculateUV(vec4(outPos, 1.0), _TopoTransform); vec4 scaledPosition = upScalePoint(position); vec4 _position = projectionMatrix * modelViewMatrix * scaledPosition; return _position; } void main() { gl_Position = calc_vertex_pos(); } 1689 Content/UserMarker.fs float calculatePixelToMeterFactor(vec4 scaledCenterPos, float screenHeight, mat4 viewMatrix, mat4 projectionMatrix) { vec4 screenPos1 = projectionMatrix * viewMatrix * scaledCenterPos; screenPos1.xy /= abs(screenPos1.w); float distance = abs(screenPos1.w) / 20.0; vec4 position2 = viewMatrix * scaledCenterPos; position2.y += distance; vec4 screenPos2 = projectionMatrix * position2; screenPos2.xy /= abs(screenPos2.w); vec2 screenDiff = screenPos1.xy - screenPos2.xy; float screenDistance = length(screenDiff); float screenToView = 2.0 / screenHeight; float pixelDistance = screenDistance / screenToView; return distance / pixelDistance; } float edgeAntiAliasing(float distance, float edge) { float halfPixel = 0.5; return smoothstep(edge - halfPixel, edge + halfPixel, distance); } vec4 antiAliasedBorder(float distance, float borderStart, float borderEnd, vec4 mainColor, vec4 borderColor) { float alphaBorder = edgeAntiAliasing(distance, borderStart); float alphaOutside = edgeAntiAliasing(distance, borderEnd); vec4 col = mix(mainColor, borderColor, alphaBorder); col = mix(col, vec4(borderColor.rgb, 0), alphaOutside); return col; } vec4 unitBoxVertex(vec4 pos) { pos.xyz = normalize(pos.xyz) * 1.4142; return pos; } uniform vec4 mainColor; uniform vec4 borderColor; uniform float borderWidth; uniform float radius; varying vec3 vertexPosition; void main() { float distanceFromCenter = length(vertexPosition.xy); gl_FragColor = antiAliasedBorder(distanceFromCenter, radius - borderWidth, radius, mainColor, borderColor); } 2803 Content/Icon-DEFAULT.vs mat3 mat4ToMat3(mat4 m) { return mat3(m[0].xyz, m[1].xyz, m[2].xyz); } const int kSC_SymbolCullingDistanceFactor = 4; const int kSC_OSMTileCullingDistanceFactor = 4; const float kSC_MapboxZoomLevelOffset = 0.7; const int kSC_UseOSMDataFromAncestorDiff = 1; const int kSC_MaxOSMLevelFromServer = 15; const float kSC_Skybox_MinVisibleDistance = 500000.0; const float kSC_Skybox_Height = 1000000.0; const float kSC_UserMarker_OuterCircleRadius = 12.0; const int kSC_MaxBoundingBoxesPerTopoLayer = 16; const float kSC_CameraFOV = 42.0; const float kSC_ElevationExaggerationMinHeightRange = 200.0; const float kSC_ElevationExaggerationMinHeightRangeFactor = 1.9; const float kSC_ElevationExaggerationMaxHeightRange = 2000.0; const float kSC_ElevationExaggerationMaxHeightRangeFactor = 1.15; const float kSC_FlatModeExaggeration = 0.1; uniform float mercatorScale; uniform float elevationExaggerationFactor; vec4 upScalePoint(vec4 point, mat4 modelMatrix) { vec4 scaledPoint = point; float offsetZ = modelMatrix[3][2]; scaledPoint.z = (scaledPoint.z + offsetZ) * mercatorScale * elevationExaggerationFactor - offsetZ; return scaledPoint; } vec4 upScalePoint(vec4 vec) { vec4 scaledVec = vec; scaledVec.z *= mercatorScale * elevationExaggerationFactor; return scaledVec; } vec3 _applyScaleOnNormal(vec3 vec, float scale) { vec3 scaledVec = vec; scaledVec.xy *= scale; return normalize(scaledVec); } vec3 applyElevationScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale * elevationExaggerationFactor); } vec3 applyMercatorScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale); } uniform float width; uniform float height; uniform float widthUV; uniform float heightUV; uniform float scale; uniform float bufferWidth; uniform float bufferHeight; uniform float offsetX; uniform float offsetY; uniform float pixelRatio; uniform vec2 pixelSize; varying vec2 vUv; void main() { vec4 scaledPosition = upScalePoint(vec4(position, 1.0), modelMatrix); vec4 sPosition = projectionMatrix * modelViewMatrix * scaledPosition; vec2 screenSize = vec2(bufferWidth, bufferHeight) / 2.0; sPosition.xy = floor(sPosition.xy * screenSize / sPosition.w) / screenSize * sPosition.w; vec2 screenToView = 2.0 * pixelSize; float sizeToScreen = 1.0 / 2.0; sPosition.xy += ((( uv) * vec2(width * widthUV, height * heightUV) + 2.0 * vec2(offsetX, -offsetY)) * (sPosition.w * scale * sizeToScreen * screenToView)); gl_Position = sPosition; vUv.x = uv.x > 0.0 ? 1.0 : 0.0; vUv.y = uv.y < 0.0 ? 1.0 : 0.0; vUv.x = (vUv.x - 0.5) * widthUV + 0.5; vUv.y = (vUv.y - 0.5) * heightUV + 0.5; } 4750 Content/Icon-PERSPECTIVE.vs mat3 mat4ToMat3(mat4 m) { return mat3(m[0].xyz, m[1].xyz, m[2].xyz); } const int kSC_SymbolCullingDistanceFactor = 4; const int kSC_OSMTileCullingDistanceFactor = 4; const float kSC_MapboxZoomLevelOffset = 0.7; const int kSC_UseOSMDataFromAncestorDiff = 1; const int kSC_MaxOSMLevelFromServer = 15; const float kSC_Skybox_MinVisibleDistance = 500000.0; const float kSC_Skybox_Height = 1000000.0; const float kSC_UserMarker_OuterCircleRadius = 12.0; const int kSC_MaxBoundingBoxesPerTopoLayer = 16; const float kSC_CameraFOV = 42.0; const float kSC_ElevationExaggerationMinHeightRange = 200.0; const float kSC_ElevationExaggerationMinHeightRangeFactor = 1.9; const float kSC_ElevationExaggerationMaxHeightRange = 2000.0; const float kSC_ElevationExaggerationMaxHeightRangeFactor = 1.15; const float kSC_FlatModeExaggeration = 0.1; uniform float mercatorScale; uniform float elevationExaggerationFactor; vec4 upScalePoint(vec4 point, mat4 modelMatrix) { vec4 scaledPoint = point; float offsetZ = modelMatrix[3][2]; scaledPoint.z = (scaledPoint.z + offsetZ) * mercatorScale * elevationExaggerationFactor - offsetZ; return scaledPoint; } vec4 upScalePoint(vec4 vec) { vec4 scaledVec = vec; scaledVec.z *= mercatorScale * elevationExaggerationFactor; return scaledVec; } vec3 _applyScaleOnNormal(vec3 vec, float scale) { vec3 scaledVec = vec; scaledVec.xy *= scale; return normalize(scaledVec); } vec3 applyElevationScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale * elevationExaggerationFactor); } vec3 applyMercatorScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale); } float inverseLerp(float min, float max, float value) { return (value - min) / (max - min); } float sampleMapboxCurve(float zoomLevel, float keys[2], float values[2], float base) { if (zoomLevel <= keys[0]) return values[0]; else if (zoomLevel >= keys[1]) return values[1]; else { float t = base == 1.0 ? inverseLerp(keys[0], keys[1], zoomLevel) : (pow(base, zoomLevel - keys[0]) - 1.0) / (pow(base, keys[1] - keys[0]) - 1.0); return mix(values[0], values[1], t); } } float sampleMapboxLinearCurve(float zoomLevel, float keys[4], float values[4]) { if (zoomLevel <= keys[0]) return values[0]; else if (zoomLevel <= keys[1]) return mix(values[1 - 1], values[1], inverseLerp(keys[1 - 1], keys[1], zoomLevel)); else if (zoomLevel <= keys[2]) return mix(values[2 - 1], values[2], inverseLerp(keys[2 - 1], keys[2], zoomLevel)); else if (zoomLevel <= keys[3]) return mix(values[3 - 1], values[3], inverseLerp(keys[3 - 1], keys[3], zoomLevel)); else return values[3]; } float calculateZoomLevel(float distance) { const float kDegreesToRadians = 3.1415 / 180.0; float viewSizeFactor = tan(kSC_CameraFOV / 2.0 * kDegreesToRadians) * 2.0; const float kEarthTileSize = 40075016.0; return log2(kEarthTileSize / (distance * viewSizeFactor)) + kSC_MapboxZoomLevelOffset; } uniform float width; uniform float height; uniform float widthUV; uniform float heightUV; uniform float bufferWidth; uniform float bufferHeight; uniform float offsetX; uniform float offsetY; uniform float pixelRatio; uniform vec2 pixelSize; uniform float up; uniform float sizeMCKeys[2]; uniform float sizeMCValues[2]; uniform float sizeMCBase; uniform float opacityMCKeys[4]; uniform float opacityMCValues[4]; varying float vOpacity; varying vec2 vUv; void main() { vec4 scaledPosition = upScalePoint(vec4(position, 1.0), modelMatrix); vec4 pos = modelViewMatrix * scaledPosition; float depth = abs(pos.z); float zoomLevel = calculateZoomLevel(depth); float scale = sampleMapboxCurve(zoomLevel, sizeMCKeys, sizeMCValues, sizeMCBase); vOpacity = sampleMapboxLinearCurve(zoomLevel, opacityMCKeys, opacityMCValues); vec4 sPosition = projectionMatrix * modelViewMatrix * scaledPosition; vec2 screenSize = vec2(bufferWidth, bufferHeight) / 2.0; sPosition.xy = floor(sPosition.xy * screenSize / sPosition.w) / screenSize * sPosition.w; vec2 screenToView = 2.0 * pixelSize; float sizeToScreen = 1.0 / 2.0; sPosition.xy += ((( uv) * vec2(width * widthUV, height * heightUV) + 2.0 * vec2(offsetX, -offsetY)) * (sPosition.w * scale * sizeToScreen * screenToView)); gl_Position = sPosition; gl_Position.z -= up; vUv.x = uv.x > 0.0 ? 1.0 : 0.0; vUv.y = uv.y < 0.0 ? 1.0 : 0.0; vUv.x = (vUv.x - 0.5) * widthUV + 0.5; vUv.y = (vUv.y - 0.5) * heightUV + 0.5; } 5142 Content/Icon-PERSPECTIVE_ROTATING.vs mat3 mat4ToMat3(mat4 m) { return mat3(m[0].xyz, m[1].xyz, m[2].xyz); } const int kSC_SymbolCullingDistanceFactor = 4; const int kSC_OSMTileCullingDistanceFactor = 4; const float kSC_MapboxZoomLevelOffset = 0.7; const int kSC_UseOSMDataFromAncestorDiff = 1; const int kSC_MaxOSMLevelFromServer = 15; const float kSC_Skybox_MinVisibleDistance = 500000.0; const float kSC_Skybox_Height = 1000000.0; const float kSC_UserMarker_OuterCircleRadius = 12.0; const int kSC_MaxBoundingBoxesPerTopoLayer = 16; const float kSC_CameraFOV = 42.0; const float kSC_ElevationExaggerationMinHeightRange = 200.0; const float kSC_ElevationExaggerationMinHeightRangeFactor = 1.9; const float kSC_ElevationExaggerationMaxHeightRange = 2000.0; const float kSC_ElevationExaggerationMaxHeightRangeFactor = 1.15; const float kSC_FlatModeExaggeration = 0.1; uniform float mercatorScale; uniform float elevationExaggerationFactor; vec4 upScalePoint(vec4 point, mat4 modelMatrix) { vec4 scaledPoint = point; float offsetZ = modelMatrix[3][2]; scaledPoint.z = (scaledPoint.z + offsetZ) * mercatorScale * elevationExaggerationFactor - offsetZ; return scaledPoint; } vec4 upScalePoint(vec4 vec) { vec4 scaledVec = vec; scaledVec.z *= mercatorScale * elevationExaggerationFactor; return scaledVec; } vec3 _applyScaleOnNormal(vec3 vec, float scale) { vec3 scaledVec = vec; scaledVec.xy *= scale; return normalize(scaledVec); } vec3 applyElevationScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale * elevationExaggerationFactor); } vec3 applyMercatorScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale); } float inverseLerp(float min, float max, float value) { return (value - min) / (max - min); } float sampleMapboxCurve(float zoomLevel, float keys[2], float values[2], float base) { if (zoomLevel <= keys[0]) return values[0]; else if (zoomLevel >= keys[1]) return values[1]; else { float t = base == 1.0 ? inverseLerp(keys[0], keys[1], zoomLevel) : (pow(base, zoomLevel - keys[0]) - 1.0) / (pow(base, keys[1] - keys[0]) - 1.0); return mix(values[0], values[1], t); } } float sampleMapboxLinearCurve(float zoomLevel, float keys[4], float values[4]) { if (zoomLevel <= keys[0]) return values[0]; else if (zoomLevel <= keys[1]) return mix(values[1 - 1], values[1], inverseLerp(keys[1 - 1], keys[1], zoomLevel)); else if (zoomLevel <= keys[2]) return mix(values[2 - 1], values[2], inverseLerp(keys[2 - 1], keys[2], zoomLevel)); else if (zoomLevel <= keys[3]) return mix(values[3 - 1], values[3], inverseLerp(keys[3 - 1], keys[3], zoomLevel)); else return values[3]; } float calculateZoomLevel(float distance) { const float kDegreesToRadians = 3.1415 / 180.0; float viewSizeFactor = tan(kSC_CameraFOV / 2.0 * kDegreesToRadians) * 2.0; const float kEarthTileSize = 40075016.0; return log2(kEarthTileSize / (distance * viewSizeFactor)) + kSC_MapboxZoomLevelOffset; } uniform float width; uniform float height; uniform float widthUV; uniform float heightUV; uniform float bufferWidth; uniform float bufferHeight; uniform float offsetX; uniform float offsetY; uniform float pixelRatio; uniform vec2 pixelSize; attribute vec3 tangent; uniform float up; uniform float sizeMCKeys[2]; uniform float sizeMCValues[2]; uniform float sizeMCBase; uniform float opacityMCKeys[4]; uniform float opacityMCValues[4]; varying float vOpacity; varying vec2 vUv; void main() { vec4 scaledPosition = upScalePoint(vec4(position, 1.0), modelMatrix); vec4 pos = modelViewMatrix * scaledPosition; float depth = abs(pos.z); float zoomLevel = calculateZoomLevel(depth); float scale = sampleMapboxCurve(zoomLevel, sizeMCKeys, sizeMCValues, sizeMCBase); vOpacity = sampleMapboxLinearCurve(zoomLevel, opacityMCKeys, opacityMCValues); vec4 sPosition = projectionMatrix * modelViewMatrix * scaledPosition; vec2 screenSize = vec2(bufferWidth, bufferHeight) / 2.0; sPosition.xy = floor(sPosition.xy * screenSize / sPosition.w) / screenSize * sPosition.w; vec2 screenToView = 2.0 * pixelSize; float sizeToScreen = 1.0 / 2.0; vec4 tanPoint = projectionMatrix * modelViewMatrix * upScalePoint(vec4(position, 1.0) + abs(sPosition.w / 10.0) * vec4(vec3(tangent), 0.0), modelMatrix); vec2 pTangent = normalize(sPosition.xy / sPosition.w - tanPoint.xy / tanPoint.w); mat2 rotate = mat2(pTangent.x, pTangent.y, -pTangent.y, pTangent.x); sPosition.xy += ((( rotate * uv) * vec2(width * widthUV, height * heightUV) + 2.0 * vec2(offsetX, -offsetY)) * (sPosition.w * scale * sizeToScreen * screenToView)); gl_Position = sPosition; gl_Position.z -= up; vUv.x = uv.x > 0.0 ? 1.0 : 0.0; vUv.y = uv.y < 0.0 ? 1.0 : 0.0; vUv.x = (vUv.x - 0.5) * widthUV + 0.5; vUv.y = (vUv.y - 0.5) * heightUV + 0.5; } 5859 Content/Icon-PERSPECTIVE_ROTATING_CUSTOM.vs uniform int iconsZoomLevel; mat3 mat4ToMat3(mat4 m) { return mat3(m[0].xyz, m[1].xyz, m[2].xyz); } const int kSC_SymbolCullingDistanceFactor = 4; const int kSC_OSMTileCullingDistanceFactor = 4; const float kSC_MapboxZoomLevelOffset = 0.7; const int kSC_UseOSMDataFromAncestorDiff = 1; const int kSC_MaxOSMLevelFromServer = 15; const float kSC_Skybox_MinVisibleDistance = 500000.0; const float kSC_Skybox_Height = 1000000.0; const float kSC_UserMarker_OuterCircleRadius = 12.0; const int kSC_MaxBoundingBoxesPerTopoLayer = 16; const float kSC_CameraFOV = 42.0; const float kSC_ElevationExaggerationMinHeightRange = 200.0; const float kSC_ElevationExaggerationMinHeightRangeFactor = 1.9; const float kSC_ElevationExaggerationMaxHeightRange = 2000.0; const float kSC_ElevationExaggerationMaxHeightRangeFactor = 1.15; const float kSC_FlatModeExaggeration = 0.1; uniform float mercatorScale; uniform float elevationExaggerationFactor; vec4 upScalePoint(vec4 point, mat4 modelMatrix) { vec4 scaledPoint = point; float offsetZ = modelMatrix[3][2]; scaledPoint.z = (scaledPoint.z + offsetZ) * mercatorScale * elevationExaggerationFactor - offsetZ; return scaledPoint; } vec4 upScalePoint(vec4 vec) { vec4 scaledVec = vec; scaledVec.z *= mercatorScale * elevationExaggerationFactor; return scaledVec; } vec3 _applyScaleOnNormal(vec3 vec, float scale) { vec3 scaledVec = vec; scaledVec.xy *= scale; return normalize(scaledVec); } vec3 applyElevationScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale * elevationExaggerationFactor); } vec3 applyMercatorScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale); } float inverseLerp(float min, float max, float value) { return (value - min) / (max - min); } float sampleMapboxCurve(float zoomLevel, float keys[2], float values[2], float base) { if (zoomLevel <= keys[0]) return values[0]; else if (zoomLevel >= keys[1]) return values[1]; else { float t = base == 1.0 ? inverseLerp(keys[0], keys[1], zoomLevel) : (pow(base, zoomLevel - keys[0]) - 1.0) / (pow(base, keys[1] - keys[0]) - 1.0); return mix(values[0], values[1], t); } } float sampleMapboxLinearCurve(float zoomLevel, float keys[4], float values[4]) { if (zoomLevel <= keys[0]) return values[0]; else if (zoomLevel <= keys[1]) return mix(values[1 - 1], values[1], inverseLerp(keys[1 - 1], keys[1], zoomLevel)); else if (zoomLevel <= keys[2]) return mix(values[2 - 1], values[2], inverseLerp(keys[2 - 1], keys[2], zoomLevel)); else if (zoomLevel <= keys[3]) return mix(values[3 - 1], values[3], inverseLerp(keys[3 - 1], keys[3], zoomLevel)); else return values[3]; } float calculateZoomLevel(float distance) { const float kDegreesToRadians = 3.1415 / 180.0; float viewSizeFactor = tan(kSC_CameraFOV / 2.0 * kDegreesToRadians) * 2.0; const float kEarthTileSize = 40075016.0; return log2(kEarthTileSize / (distance * viewSizeFactor)) + kSC_MapboxZoomLevelOffset; } uniform float width; uniform float height; uniform float widthUV; uniform float heightUV; uniform float bufferWidth; uniform float bufferHeight; uniform float offsetX; uniform float offsetY; uniform float pixelRatio; uniform vec2 pixelSize; attribute vec3 tangent; uniform float up; uniform float sizeMCKeys[2]; uniform float sizeMCValues[2]; uniform float sizeMCBase; uniform float opacityMCKeys[4]; uniform float opacityMCValues[4]; varying float vOpacity; varying vec2 vUv; void main() { vec4 scaledPosition = upScalePoint(vec4(position, 1.0), modelMatrix); vec4 pos = modelViewMatrix * scaledPosition; float depth = abs(pos.z); float zoomLevel = calculateZoomLevel(depth); float scale = sampleMapboxCurve(zoomLevel, sizeMCKeys, sizeMCValues, sizeMCBase); vOpacity = sampleMapboxLinearCurve(zoomLevel, opacityMCKeys, opacityMCValues); vec4 sPosition = projectionMatrix * modelViewMatrix * scaledPosition; vec2 screenSize = vec2(bufferWidth, bufferHeight) / 2.0; sPosition.xy = floor(sPosition.xy * screenSize / sPosition.w) / screenSize * sPosition.w; vec2 screenToView = 2.0 * pixelSize; float sizeToScreen = 1.0 / 2.0; vec4 tanPoint = projectionMatrix * modelViewMatrix * upScalePoint(vec4(position, 1.0) + abs(sPosition.w / 10.0) * vec4(vec3(tangent), 0.0), modelMatrix); vec2 pTangent = normalize(sPosition.xy / sPosition.w - tanPoint.xy / tanPoint.w); mat2 rotate = mat2(pTangent.x, pTangent.y, -pTangent.y, pTangent.x); vec4 vTan = modelViewMatrix * normalize(vec4(vec3(tangent), 0.0)); vec4 vPos = modelViewMatrix * scaledPosition; vec3 vTanDir = normalize(vTan.xyz); vec3 vPosDir = normalize(vPos.xyz); float vProjection = dot(vTanDir, vPosDir); float coef = sqrt(1.0 - vProjection * vProjection); zoomLevel = calculateZoomLevel(depth / coef); float instanceId = secondary_colour; int zoomLevelI = int(zoomLevel); float levelDiff = float(iconsZoomLevel - zoomLevelI); levelDiff = clamp(levelDiff, 0.0, float(iconsZoomLevel)); float N = pow(2.0, levelDiff); bool shouldDisplay = int(mod(instanceId, N)) == 0; vOpacity = shouldDisplay ? vOpacity : 0.0; sPosition.xy += ((( rotate * uv) * vec2(width * widthUV, height * heightUV) + 2.0 * vec2(offsetX, -offsetY)) * (sPosition.w * scale * sizeToScreen * screenToView)); gl_Position = sPosition; gl_Position.z -= up; vUv.x = uv.x > 0.0 ? 1.0 : 0.0; vUv.y = uv.y < 0.0 ? 1.0 : 0.0; vUv.x = (vUv.x - 0.5) * widthUV + 0.5; vUv.y = (vUv.y - 0.5) * heightUV + 0.5; } 2412 Content/Label2Pass.vs varying vec2 vUv; mat3 mat4ToMat3(mat4 m) { return mat3(m[0].xyz, m[1].xyz, m[2].xyz); } const int kSC_SymbolCullingDistanceFactor = 4; const int kSC_OSMTileCullingDistanceFactor = 4; const float kSC_MapboxZoomLevelOffset = 0.7; const int kSC_UseOSMDataFromAncestorDiff = 1; const int kSC_MaxOSMLevelFromServer = 15; const float kSC_Skybox_MinVisibleDistance = 500000.0; const float kSC_Skybox_Height = 1000000.0; const float kSC_UserMarker_OuterCircleRadius = 12.0; const int kSC_MaxBoundingBoxesPerTopoLayer = 16; const float kSC_CameraFOV = 42.0; const float kSC_ElevationExaggerationMinHeightRange = 200.0; const float kSC_ElevationExaggerationMinHeightRangeFactor = 1.9; const float kSC_ElevationExaggerationMaxHeightRange = 2000.0; const float kSC_ElevationExaggerationMaxHeightRangeFactor = 1.15; const float kSC_FlatModeExaggeration = 0.1; uniform float mercatorScale; uniform float elevationExaggerationFactor; vec4 upScalePoint(vec4 point, mat4 modelMatrix) { vec4 scaledPoint = point; float offsetZ = modelMatrix[3][2]; scaledPoint.z = (scaledPoint.z + offsetZ) * mercatorScale * elevationExaggerationFactor - offsetZ; return scaledPoint; } vec4 upScalePoint(vec4 vec) { vec4 scaledVec = vec; scaledVec.z *= mercatorScale * elevationExaggerationFactor; return scaledVec; } vec3 _applyScaleOnNormal(vec3 vec, float scale) { vec3 scaledVec = vec; scaledVec.xy *= scale; return normalize(scaledVec); } vec3 applyElevationScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale * elevationExaggerationFactor); } vec3 applyMercatorScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale); } uniform vec2 pixelSize; uniform float fontSizeCur; uniform float fontSizeMax; uniform float offsetX; uniform float offsetY; uniform float pixelRatio; void main() { vUv = uv; float q = fontSizeCur / fontSizeMax; vec2 offset = vec2(offsetX, offsetY) * fontSizeMax; vec4 scaledPosition = upScalePoint(vec4(position, 1.0), modelMatrix); vec4 sPosition = projectionMatrix * modelViewMatrix * scaledPosition; vec2 screenToView = 2.0 * pixelSize; float aspect = projectionMatrix[1][1] / projectionMatrix[0][0]; vec2 totalOffset = (normal.xy + offset) * q; totalOffset.y = -totalOffset.y; sPosition.xy += totalOffset * screenToView * sPosition.w; gl_Position = sPosition; } 242 Content/Icon-DEFAULT.fs uniform sampler2D tex; uniform float opacity; uniform float opacityMultiplier; varying vec2 vUv; void main() { vec4 c = texture2D(tex, vUv); float alpha = opacity; gl_FragColor = vec4(c.rgb, c.a * alpha * opacityMultiplier); } 244 Content/Icon-PERSPECTIVE.fs uniform sampler2D tex; varying float vOpacity; uniform float opacityMultiplier; varying vec2 vUv; void main() { vec4 c = texture2D(tex, vUv); float alpha = vOpacity; gl_FragColor = vec4(c.rgb, c.a * alpha * opacityMultiplier); } 697 Content/Label2Pass.fs varying vec2 vUv; uniform sampler2D tex; uniform float opacity; uniform float opacityMultiplier; uniform float fontSizeCur; uniform vec3 color; uniform float threshold; uniform float softness; const float G_fontSizePixels = 64.0; const float G_distFieldWidth = 32.0; const float G_distanceOffset = 0.0; void main() { float _sample = texture2D(tex, vUv).r; float distValue = G_distFieldWidth * (_sample - 0.5); float q = G_fontSizePixels / fontSizeCur; float alpha = smoothstep(q * (-threshold - softness * 0.5), q * (-threshold + softness * 0.5), distValue + G_distanceOffset); gl_FragColor = vec4(color, alpha * opacity * opacityMultiplier); } 584 Content/Label2PassScreenSpace.vs mat3 mat4ToMat3(mat4 m) { return mat3(m[0].xyz, m[1].xyz, m[2].xyz); } varying vec2 vUv; uniform vec2 pixelSize; uniform float bufferWidth; uniform float bufferHeight; uniform float offsetX; uniform float offsetY; uniform float width; uniform float height; uniform float widthUV; uniform float heightUV; uniform float scale; uniform float fontSizeCur; uniform float fontSizeMax; uniform float mercatorScale; uniform float elevationExaggerationFactor; void main() { vUv = uv; vec2 pos = position.xy * pixelSize * 2.0 - 1.0; gl_Position = vec4(pos.x, pos.y, 1.0, 1.0); } 3765 Content/UserMarkerDirection.vs mat3 mat4ToMat3(mat4 m) { return mat3(m[0].xyz, m[1].xyz, m[2].xyz); } const int kSC_SymbolCullingDistanceFactor = 4; const int kSC_OSMTileCullingDistanceFactor = 4; const float kSC_MapboxZoomLevelOffset = 0.7; const int kSC_UseOSMDataFromAncestorDiff = 1; const int kSC_MaxOSMLevelFromServer = 15; const float kSC_Skybox_MinVisibleDistance = 500000.0; const float kSC_Skybox_Height = 1000000.0; const float kSC_UserMarker_OuterCircleRadius = 12.0; const int kSC_MaxBoundingBoxesPerTopoLayer = 16; const float kSC_CameraFOV = 42.0; const float kSC_ElevationExaggerationMinHeightRange = 200.0; const float kSC_ElevationExaggerationMinHeightRangeFactor = 1.9; const float kSC_ElevationExaggerationMaxHeightRange = 2000.0; const float kSC_ElevationExaggerationMaxHeightRangeFactor = 1.15; const float kSC_FlatModeExaggeration = 0.1; uniform float mercatorScale; uniform float elevationExaggerationFactor; vec4 upScalePoint(vec4 point, mat4 modelMatrix) { vec4 scaledPoint = point; float offsetZ = modelMatrix[3][2]; scaledPoint.z = (scaledPoint.z + offsetZ) * mercatorScale * elevationExaggerationFactor - offsetZ; return scaledPoint; } vec4 upScalePoint(vec4 vec) { vec4 scaledVec = vec; scaledVec.z *= mercatorScale * elevationExaggerationFactor; return scaledVec; } vec3 _applyScaleOnNormal(vec3 vec, float scale) { vec3 scaledVec = vec; scaledVec.xy *= scale; return normalize(scaledVec); } vec3 applyElevationScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale * elevationExaggerationFactor); } vec3 applyMercatorScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale); } float calculatePixelToMeterFactor(vec4 scaledCenterPos, float screenHeight, mat4 viewMatrix, mat4 projectionMatrix) { vec4 screenPos1 = projectionMatrix * viewMatrix * scaledCenterPos; screenPos1.xy /= abs(screenPos1.w); float distance = abs(screenPos1.w) / 20.0; vec4 position2 = viewMatrix * scaledCenterPos; position2.y += distance; vec4 screenPos2 = projectionMatrix * position2; screenPos2.xy /= abs(screenPos2.w); vec2 screenDiff = screenPos1.xy - screenPos2.xy; float screenDistance = length(screenDiff); float screenToView = 2.0 / screenHeight; float pixelDistance = screenDistance / screenToView; return distance / pixelDistance; } float edgeAntiAliasing(float distance, float edge) { float halfPixel = 0.5; return smoothstep(edge - halfPixel, edge + halfPixel, distance); } vec4 antiAliasedBorder(float distance, float borderStart, float borderEnd, vec4 mainColor, vec4 borderColor) { float alphaBorder = edgeAntiAliasing(distance, borderStart); float alphaOutside = edgeAntiAliasing(distance, borderEnd); vec4 col = mix(mainColor, borderColor, alphaBorder); col = mix(col, vec4(borderColor.rgb, 0), alphaOutside); return col; } vec4 unitBoxVertex(vec4 pos) { pos.xyz = normalize(pos.xyz) * 1.4142; return pos; } uniform float screenHeight; varying vec3 vVertex; void main() { float sizeInPixels = 48.0; vec4 centerPos = vec4(modelMatrix[3][0], modelMatrix[3][1], modelMatrix[3][2], 1.0); vec4 scaledCenterPos = upScalePoint(centerPos); float pixelToMeterFactor = calculatePixelToMeterFactor(scaledCenterPos, screenHeight, viewMatrix, projectionMatrix); vec3 normalizedVertex = unitBoxVertex(vec4(position, 1.0)).xyz; vec3 rotatedVertex = mat4ToMat3(modelMatrix) * normalizedVertex; vec4 pos = scaledCenterPos; vec3 offset = rotatedVertex * (sizeInPixels * pixelToMeterFactor); pos.xyz += offset; vVertex = normalizedVertex; gl_Position = projectionMatrix * viewMatrix * pos; } 2476 Content/UserMarker.vs mat3 mat4ToMat3(mat4 m) { return mat3(m[0].xyz, m[1].xyz, m[2].xyz); } const int kSC_SymbolCullingDistanceFactor = 4; const int kSC_OSMTileCullingDistanceFactor = 4; const float kSC_MapboxZoomLevelOffset = 0.7; const int kSC_UseOSMDataFromAncestorDiff = 1; const int kSC_MaxOSMLevelFromServer = 15; const float kSC_Skybox_MinVisibleDistance = 500000.0; const float kSC_Skybox_Height = 1000000.0; const float kSC_UserMarker_OuterCircleRadius = 12.0; const int kSC_MaxBoundingBoxesPerTopoLayer = 16; const float kSC_CameraFOV = 42.0; const float kSC_ElevationExaggerationMinHeightRange = 200.0; const float kSC_ElevationExaggerationMinHeightRangeFactor = 1.9; const float kSC_ElevationExaggerationMaxHeightRange = 2000.0; const float kSC_ElevationExaggerationMaxHeightRangeFactor = 1.15; const float kSC_FlatModeExaggeration = 0.1; uniform float mercatorScale; uniform float elevationExaggerationFactor; vec4 upScalePoint(vec4 point, mat4 modelMatrix) { vec4 scaledPoint = point; float offsetZ = modelMatrix[3][2]; scaledPoint.z = (scaledPoint.z + offsetZ) * mercatorScale * elevationExaggerationFactor - offsetZ; return scaledPoint; } vec4 upScalePoint(vec4 vec) { vec4 scaledVec = vec; scaledVec.z *= mercatorScale * elevationExaggerationFactor; return scaledVec; } vec3 _applyScaleOnNormal(vec3 vec, float scale) { vec3 scaledVec = vec; scaledVec.xy *= scale; return normalize(scaledVec); } vec3 applyElevationScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale * elevationExaggerationFactor); } vec3 applyMercatorScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale); } uniform float screenHeight; uniform float radius; varying vec3 vertexPosition; void main() { vec3 centerPos = vec3(modelMatrix[3][0], modelMatrix[3][1], modelMatrix[3][2]); vec4 scaledCenterPos = upScalePoint(vec4(centerPos, 1.0)); float offsetCenterZ = scaledCenterPos.z - centerPos.z; vec4 sVertexPosition = projectionMatrix * viewMatrix * scaledCenterPos; float screenToView = 2.0 / screenHeight; float extraRadius = 1.0; vertexPosition = normalize(vec4(position, 1.0).xyz) * (radius + extraRadius); float aspect = projectionMatrix[1][1] / projectionMatrix[0][0]; vec3 offset = vertexPosition * vec3(1.0 / aspect, 1.0, 1.0); offset.xy *= abs(sVertexPosition.w) * screenToView; sVertexPosition.xyz += offset; gl_Position = sVertexPosition; } 1753 Content/UserMarkerAccuracy.fs float calculatePixelToMeterFactor(vec4 scaledCenterPos, float screenHeight, mat4 viewMatrix, mat4 projectionMatrix) { vec4 screenPos1 = projectionMatrix * viewMatrix * scaledCenterPos; screenPos1.xy /= abs(screenPos1.w); float distance = abs(screenPos1.w) / 20.0; vec4 position2 = viewMatrix * scaledCenterPos; position2.y += distance; vec4 screenPos2 = projectionMatrix * position2; screenPos2.xy /= abs(screenPos2.w); vec2 screenDiff = screenPos1.xy - screenPos2.xy; float screenDistance = length(screenDiff); float screenToView = 2.0 / screenHeight; float pixelDistance = screenDistance / screenToView; return distance / pixelDistance; } float edgeAntiAliasing(float distance, float edge) { float halfPixel = 0.5; return smoothstep(edge - halfPixel, edge + halfPixel, distance); } vec4 antiAliasedBorder(float distance, float borderStart, float borderEnd, vec4 mainColor, vec4 borderColor) { float alphaBorder = edgeAntiAliasing(distance, borderStart); float alphaOutside = edgeAntiAliasing(distance, borderEnd); vec4 col = mix(mainColor, borderColor, alphaBorder); col = mix(col, vec4(borderColor.rgb, 0), alphaOutside); return col; } vec4 unitBoxVertex(vec4 pos) { pos.xyz = normalize(pos.xyz) * 1.4142; return pos; } uniform vec4 mainColor; uniform vec4 borderColor; varying vec3 vertexPosition; varying float pixelToMeterFactor; varying float radius; void main() { float distanceToEdge = length(vertexPosition.xy) - 1.0; float distanceToEdgePixels = distanceToEdge * radius / pixelToMeterFactor; gl_FragColor = antiAliasedBorder(distanceToEdgePixels, -1.5, -0.5, mainColor, borderColor); } 2075 Content/Line.fs float calculateHalfWidth_(float lineWidth, float lineGapWidth) { return lineGapWidth == 0.0 ? lineWidth / 2.0 : lineGapWidth / 2.0 + lineWidth; } float calculateHalfWidth(float lineWidth, float lineGapWidth) { return 1.0 + calculateHalfWidth_(lineWidth, lineGapWidth); } varying vec3 vUv; varying float vDistanceAlpha; varying vec3 vLineData; varying float vHalfWidth; varying vec4 vHazeColor; float antialiasedBorder(float value, float border) { float epsilon = 0.2; float f = (value - border + epsilon) / (epsilon * 2.0); f = clamp(f, 0.0, 1.0); return f; } float calculateFactor(float distanceFromCenter, float lineGapWidth, float lineWidth) { return lineGapWidth == 0.0 ? antialiasedBorder(lineWidth / 2.0, distanceFromCenter) : antialiasedBorder(distanceFromCenter, lineGapWidth / 2.0) * antialiasedBorder(lineGapWidth / 2.0 + lineWidth, distanceFromCenter); } vec4 calculateColor(float distanceFromCenter, vec3 lineData, vec4 lineColor, float lineDash, float lineDashGap, float opacityMultiplier) { float lineWidth = lineData[0]; float lineGapWidth = lineData[1]; float lineOpacity = lineData[2]; vec4 color = lineColor; color.a *= lineOpacity * opacityMultiplier; float lineFactor = calculateFactor(distanceFromCenter, lineGapWidth, lineWidth); color.a *= lineFactor; return color; } uniform vec4 lineColor; uniform float lineDash; uniform float lineDashGap; uniform float opacityMultiplier; void main() { float distanceFromCenter = abs(vUv.x - 0.5) / 0.5 * vHalfWidth; vec4 color = calculateColor(distanceFromCenter, vLineData, lineColor, lineDash, lineDashGap, opacityMultiplier); color.rgb = mix(color.rgb, vHazeColor.rgb, vHazeColor.a); vec4 caseColor = vec4(0.0); float dstAlpha = (1.0 - caseColor.a) * (1.0 - color.a); vec4 res = caseColor * caseColor.a * (1.0 - color.a) + color * color.a; res.a = 1.0 - dstAlpha; res *= vDistanceAlpha; gl_FragColor = res; } 2644 Content/Line-DASHED.fs float calculateHalfWidth_(float lineWidth, float lineGapWidth) { return lineGapWidth == 0.0 ? lineWidth / 2.0 : lineGapWidth / 2.0 + lineWidth; } float calculateHalfWidth(float lineWidth, float lineGapWidth) { return 1.0 + calculateHalfWidth_(lineWidth, lineGapWidth); } varying vec3 vUv; varying float vDistanceAlpha; varying vec3 vLineData; varying float vHalfWidth; varying vec4 vHazeColor; float antialiasedBorder(float value, float border) { float epsilon = 0.2; float f = (value - border + epsilon) / (epsilon * 2.0); f = clamp(f, 0.0, 1.0); return f; } float calculateFactor(float distanceFromCenter, float lineGapWidth, float lineWidth) { return lineGapWidth == 0.0 ? antialiasedBorder(lineWidth / 2.0, distanceFromCenter) : antialiasedBorder(distanceFromCenter, lineGapWidth / 2.0) * antialiasedBorder(lineGapWidth / 2.0 + lineWidth, distanceFromCenter); } float calculateDashFactor(float lineDash, float lineDashGap, float lineWidth) { float dashPatternLength = (lineDash + lineDashGap); float depth = log2(max(1e-6, vUv.z * lineWidth)); float logDepth = pow(2.0, floor(depth)); float uvy = vUv.y / logDepth; uvy += (dashPatternLength * 0.5); float normalizedPatternPosition = fract(uvy / dashPatternLength); return step(lineDashGap / dashPatternLength, normalizedPatternPosition); } vec4 calculateColor(float distanceFromCenter, vec3 lineData, vec4 lineColor, float lineDash, float lineDashGap, float opacityMultiplier) { float lineWidth = lineData[0]; float lineGapWidth = lineData[1]; float lineOpacity = lineData[2]; vec4 color = lineColor; color.a *= lineOpacity * opacityMultiplier; float lineFactor = calculateFactor(distanceFromCenter, lineGapWidth, lineWidth); color.a *= lineFactor; float lineDashFactor = calculateDashFactor(lineDash, lineDashGap, lineWidth); color.a *= lineDashFactor; return color; } uniform vec4 lineColor; uniform float lineDash; uniform float lineDashGap; uniform float opacityMultiplier; void main() { float distanceFromCenter = abs(vUv.x - 0.5) / 0.5 * vHalfWidth; vec4 color = calculateColor(distanceFromCenter, vLineData, lineColor, lineDash, lineDashGap, opacityMultiplier); color.rgb = mix(color.rgb, vHazeColor.rgb, vHazeColor.a); vec4 caseColor = vec4(0.0); float dstAlpha = (1.0 - caseColor.a) * (1.0 - color.a); vec4 res = caseColor * caseColor.a * (1.0 - color.a) + color * color.a; res.a = 1.0 - dstAlpha; res *= vDistanceAlpha; gl_FragColor = res; } 3596 Content/UserMarkerAccuracy.vs mat3 mat4ToMat3(mat4 m) { return mat3(m[0].xyz, m[1].xyz, m[2].xyz); } const int kSC_SymbolCullingDistanceFactor = 4; const int kSC_OSMTileCullingDistanceFactor = 4; const float kSC_MapboxZoomLevelOffset = 0.7; const int kSC_UseOSMDataFromAncestorDiff = 1; const int kSC_MaxOSMLevelFromServer = 15; const float kSC_Skybox_MinVisibleDistance = 500000.0; const float kSC_Skybox_Height = 1000000.0; const float kSC_UserMarker_OuterCircleRadius = 12.0; const int kSC_MaxBoundingBoxesPerTopoLayer = 16; const float kSC_CameraFOV = 42.0; const float kSC_ElevationExaggerationMinHeightRange = 200.0; const float kSC_ElevationExaggerationMinHeightRangeFactor = 1.9; const float kSC_ElevationExaggerationMaxHeightRange = 2000.0; const float kSC_ElevationExaggerationMaxHeightRangeFactor = 1.15; const float kSC_FlatModeExaggeration = 0.1; uniform float mercatorScale; uniform float elevationExaggerationFactor; vec4 upScalePoint(vec4 point, mat4 modelMatrix) { vec4 scaledPoint = point; float offsetZ = modelMatrix[3][2]; scaledPoint.z = (scaledPoint.z + offsetZ) * mercatorScale * elevationExaggerationFactor - offsetZ; return scaledPoint; } vec4 upScalePoint(vec4 vec) { vec4 scaledVec = vec; scaledVec.z *= mercatorScale * elevationExaggerationFactor; return scaledVec; } vec3 _applyScaleOnNormal(vec3 vec, float scale) { vec3 scaledVec = vec; scaledVec.xy *= scale; return normalize(scaledVec); } vec3 applyElevationScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale * elevationExaggerationFactor); } vec3 applyMercatorScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale); } float calculatePixelToMeterFactor(vec4 scaledCenterPos, float screenHeight, mat4 viewMatrix, mat4 projectionMatrix) { vec4 screenPos1 = projectionMatrix * viewMatrix * scaledCenterPos; screenPos1.xy /= abs(screenPos1.w); float distance = abs(screenPos1.w) / 20.0; vec4 position2 = viewMatrix * scaledCenterPos; position2.y += distance; vec4 screenPos2 = projectionMatrix * position2; screenPos2.xy /= abs(screenPos2.w); vec2 screenDiff = screenPos1.xy - screenPos2.xy; float screenDistance = length(screenDiff); float screenToView = 2.0 / screenHeight; float pixelDistance = screenDistance / screenToView; return distance / pixelDistance; } float edgeAntiAliasing(float distance, float edge) { float halfPixel = 0.5; return smoothstep(edge - halfPixel, edge + halfPixel, distance); } vec4 antiAliasedBorder(float distance, float borderStart, float borderEnd, vec4 mainColor, vec4 borderColor) { float alphaBorder = edgeAntiAliasing(distance, borderStart); float alphaOutside = edgeAntiAliasing(distance, borderEnd); vec4 col = mix(mainColor, borderColor, alphaBorder); col = mix(col, vec4(borderColor.rgb, 0), alphaOutside); return col; } vec4 unitBoxVertex(vec4 pos) { pos.xyz = normalize(pos.xyz) * 1.4142; return pos; } uniform float screenHeight; varying vec3 vertexPosition; varying float pixelToMeterFactor; varying float radius; void main() { vec4 pos = unitBoxVertex(vec4(position, 1.0)); vec4 scaledVertex = upScalePoint(pos, modelMatrix); gl_Position = projectionMatrix * modelViewMatrix * scaledVertex; vec4 scaledPosition = upScalePoint(modelMatrix * pos); pixelToMeterFactor = calculatePixelToMeterFactor(scaledPosition, screenHeight, viewMatrix, projectionMatrix); radius = modelMatrix[0][0]; vertexPosition = pos.xyz; } 7574 Content/Line.vs const int kSC_SymbolCullingDistanceFactor = 4; const int kSC_OSMTileCullingDistanceFactor = 4; const float kSC_MapboxZoomLevelOffset = 0.7; const int kSC_UseOSMDataFromAncestorDiff = 1; const int kSC_MaxOSMLevelFromServer = 15; const float kSC_Skybox_MinVisibleDistance = 500000.0; const float kSC_Skybox_Height = 1000000.0; const float kSC_UserMarker_OuterCircleRadius = 12.0; const int kSC_MaxBoundingBoxesPerTopoLayer = 16; const float kSC_CameraFOV = 42.0; const float kSC_ElevationExaggerationMinHeightRange = 200.0; const float kSC_ElevationExaggerationMinHeightRangeFactor = 1.9; const float kSC_ElevationExaggerationMaxHeightRange = 2000.0; const float kSC_ElevationExaggerationMaxHeightRangeFactor = 1.15; const float kSC_FlatModeExaggeration = 0.1; const float kHazeAltitudeFadeoff = 100000.0; const float kHazeDistancePowerLow = 0.8; const float kHazeDistancePowerHigh = 0.8; vec4 kHazeColorLow0 = vec4(0.67, 0.80, 0.94, 0.95); vec4 kHazeColorLow1 = vec4(0.77, 0.87, 0.94, 0.0); vec4 kHazeColorHigh0 = vec4(0.81, 0.79, 0.80, 0.95); vec4 kHazeColorHigh1 = vec4(0.64, 0.75, 0.82, 0.0); float calculateVisibleDistance(float cameraPositionZ) { float cameraAltitude = max(1.0, cameraPositionZ); float radius = 6367444.65712; float visibleDistance = sqrt((radius + cameraAltitude) * (radius + cameraAltitude) - radius * radius); visibleDistance = max(kSC_Skybox_MinVisibleDistance, visibleDistance); visibleDistance += max(0.0, (cameraPositionZ - kSC_Skybox_Height / 2.0) * 10.0); return visibleDistance; } float calculateHazeAltitudeFactor(float altitude) { return exp(-altitude / kHazeAltitudeFadeoff); } float calculateHazeDistanceFactor(float vertexDistance, float visibleDistance, float powerFactor) { vertexDistance = min(vertexDistance, visibleDistance); return smoothstep(0.0, 1.0, pow(vertexDistance / visibleDistance, powerFactor)); } vec4 calculateHaze(vec3 vertexWorldPos, vec3 cameraPosition) { vec3 dir = vertexWorldPos - cameraPosition; float visibleDistance = calculateVisibleDistance(cameraPosition.z); float vertexDistance = length(dir.xy); float altitudeFactor = calculateHazeAltitudeFactor(cameraPosition.z); float vertexDistanceLow = visibleDistance / mix(1.0, 2.5, altitudeFactor); vec4 hazeColor = mix( mix(kHazeColorHigh1, kHazeColorHigh0, calculateHazeDistanceFactor(vertexDistance, visibleDistance, kHazeDistancePowerHigh)), mix(kHazeColorLow1, kHazeColorLow0, calculateHazeDistanceFactor(vertexDistance, vertexDistanceLow, kHazeDistancePowerLow)), altitudeFactor ); return hazeColor; } uniform float averageDepth; float getDistanceAlpha(float vertexDistance) { float fadeStart = averageDepth * 1.0; float fadeEnd = averageDepth * 10.0; float distanceAlpha = 1.0 - (vertexDistance - fadeStart) / (fadeEnd - fadeStart); distanceAlpha = clamp(distanceAlpha, 0.0, 1.0); return distanceAlpha; } mat3 mat4ToMat3(mat4 m) { return mat3(m[0].xyz, m[1].xyz, m[2].xyz); } uniform float mercatorScale; uniform float elevationExaggerationFactor; vec4 upScalePoint(vec4 point, mat4 modelMatrix) { vec4 scaledPoint = point; float offsetZ = modelMatrix[3][2]; scaledPoint.z = (scaledPoint.z + offsetZ) * mercatorScale * elevationExaggerationFactor - offsetZ; return scaledPoint; } vec4 upScalePoint(vec4 vec) { vec4 scaledVec = vec; scaledVec.z *= mercatorScale * elevationExaggerationFactor; return scaledVec; } vec3 _applyScaleOnNormal(vec3 vec, float scale) { vec3 scaledVec = vec; scaledVec.xy *= scale; return normalize(scaledVec); } vec3 applyElevationScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale * elevationExaggerationFactor); } vec3 applyMercatorScaleOnNormal(vec3 vec) { return _applyScaleOnNormal(vec, mercatorScale); } float calculateHalfWidth_(float lineWidth, float lineGapWidth) { return lineGapWidth == 0.0 ? lineWidth / 2.0 : lineGapWidth / 2.0 + lineWidth; } float calculateHalfWidth(float lineWidth, float lineGapWidth) { return 1.0 + calculateHalfWidth_(lineWidth, lineGapWidth); } varying vec3 vUv; varying float vDistanceAlpha; varying vec3 vLineData; varying float vHalfWidth; varying vec4 vHazeColor; float inverseLerp(float min, float max, float value) { return (value - min) / (max - min); } float sampleMapboxCurve(float zoomLevel, float keys[2], float values[2], float base) { if (zoomLevel <= keys[0]) return values[0]; else if (zoomLevel >= keys[1]) return values[1]; else { float t = base == 1.0 ? inverseLerp(keys[0], keys[1], zoomLevel) : (pow(base, zoomLevel - keys[0]) - 1.0) / (pow(base, keys[1] - keys[0]) - 1.0); return mix(values[0], values[1], t); } } float sampleMapboxLinearCurve(float zoomLevel, float keys[4], float values[4]) { if (zoomLevel <= keys[0]) return values[0]; else if (zoomLevel <= keys[1]) return mix(values[1 - 1], values[1], inverseLerp(keys[1 - 1], keys[1], zoomLevel)); else if (zoomLevel <= keys[2]) return mix(values[2 - 1], values[2], inverseLerp(keys[2 - 1], keys[2], zoomLevel)); else if (zoomLevel <= keys[3]) return mix(values[3 - 1], values[3], inverseLerp(keys[3 - 1], keys[3], zoomLevel)); else return values[3]; } float calculateZoomLevel(float distance) { const float kDegreesToRadians = 3.1415 / 180.0; float viewSizeFactor = tan(kSC_CameraFOV / 2.0 * kDegreesToRadians) * 2.0; const float kEarthTileSize = 40075016.0; return log2(kEarthTileSize / (distance * viewSizeFactor)) + kSC_MapboxZoomLevelOffset; } uniform vec2 pixelSize; uniform float lineWidthMCKeys[2]; uniform float lineWidthMCValues[2]; uniform float lineWidthMCBase; uniform float lineGapWidthMCKeys[2]; uniform float lineGapWidthMCValues[2]; uniform float lineGapWidthMCBase; uniform float lineOpacityMCKeys[4]; uniform float lineOpacityMCValues[4]; uniform float up; void main() { vec4 scaledPosition = upScalePoint(vec4(position, 1.0), modelMatrix); float normalScale = length(normal); vec3 scaledNormal = applyElevationScaleOnNormal(normal); vec4 sPosition = modelViewMatrix * scaledPosition; float depth = abs(sPosition.z); float aspect = projectionMatrix[1][1] / projectionMatrix[0][0]; mat4 mvp = projectionMatrix * modelViewMatrix; vec4 pos = mvp * scaledPosition; vec4 pos2 = mvp * (scaledPosition + vec4(scaledNormal, 0.0)); vec2 lineNormal = pos2.xy / abs(pos2.w) - pos.xy / abs(pos.w); lineNormal = normalScale > 0.0 ? normalize(vec2(-lineNormal.y / aspect, lineNormal.x)) * normalScale : vec2(0.0, 0.0); float zoomLevel = calculateZoomLevel(depth); vLineData = vec3(sampleMapboxCurve(zoomLevel, lineWidthMCKeys, lineWidthMCValues, lineWidthMCBase), sampleMapboxCurve(zoomLevel, lineGapWidthMCKeys, lineGapWidthMCValues, lineGapWidthMCBase), sampleMapboxLinearCurve(zoomLevel, lineOpacityMCKeys, lineOpacityMCValues)); vHalfWidth = calculateHalfWidth(vLineData[0], vLineData[1]); vec2 screenToView = 2.0 * pixelSize; pos.xy += lineNormal.xy * depth * vHalfWidth * screenToView; gl_Position = pos; gl_Position.z -= up; vUv = vec3(uv.x, uv.y / screenToView.y, depth); vDistanceAlpha = getDistanceAlpha(depth); vHazeColor = calculateHaze((modelMatrix * vec4(position, 1.0)).xyz, cameraPosition); } 444 Content/UserMarkerDirection.fs uniform vec4 mainColor; varying vec3 vVertex; void main() { float tan30 = 0.577; bool isDirectionPixel = vVertex.y > 0.0 && (abs(vVertex.x) / vVertex.y < tan30); float d = length(vVertex.xy); bool isInRadius = d <= 1.0; float radialGradient = mix(0.6, 0.2, smoothstep(0.5, 1.0, d)); float alpha = (isDirectionPixel && isInRadius) ? mainColor.a * radialGradient : 0.0; gl_FragColor = vec4(mainColor.rgb, alpha); }