2026-10-19 07:27:48 +08:00
var Nx = Object . create , k_ = Object . defineProperty , Ux = Object . getOwnPropertyDescriptor , $x = Object . getOwnPropertyNames , Gx = Object . getPrototypeOf , Zx = Object . prototype . hasOwnProperty , hd = ( e , t )=>()=>( t || ( e (( t = { exports : {}}). exports , t ), e = null ), t . exports ), qx = ( e , t , i , r )=>{ if ( t && typeof t == "object" || typeof t == "function" ) for ( var a = $x ( t ), n = 0 , o = a . length , s ; n < o ; n ++ ) s = a [ n ], ! Zx . call ( e , s ) && s !== i && k_ ( e , s ,{ get : ( l => t [ l ]). bind ( null , s ), enumerable :! ( r = Ux ( t , s )) || r . enumerable }); return e }, Wx = ( e , t , i )=>( i = e == null ? {} : Nx ( Gx ( e )), qx ( k_ ( i , "default" ,{ value : e , enumerable :! 0 }), e )), R_ = "6.15.0" ; function M ( e , t ){ this . x = e , this . y = t } M . prototype = { clone (){ return new M ( this . x , this . y )}, add ( e ){ return this . clone (). _add ( e )}, sub ( e ){ return this . clone (). _sub ( e )}, multByPoint ( e ){ return this . clone (). _multByPoint ( e )}, divByPoint ( e ){ return this . clone (). _divByPoint ( e )}, mult ( e ){ return this . clone (). _mult ( e )}, div ( e ){ return this . clone (). _div ( e )}, rotate ( e ){ return this . clone (). _rotate ( e )}, rotateAround ( e , t ){ return this . clone (). _rotateAround ( e , t )}, matMult ( e ){ return this . clone (). _matMult ( e )}, unit (){ return this . clone (). _unit ()}, perp (){ return this . clone (). _perp ()}, round (){ return this . clone (). _round ()}, mag (){ return Math . sqrt ( this . x * this . x + this . y * this . y )}, equals ( e ){ return this . x === e . x && this . y === e . y }, dist ( e ){ return Math . sqrt ( this . distSqr ( e ))}, distSqr ( e ){ let t = e . x - this . x , i = e . y - this . y ; return t * t + i * i }, angle (){ return Math . atan2 ( this . y , this . x )}, angleTo ( e ){ return Math . atan2 ( this . y - e . y , this . x - e . x )}, angleWith ( e ){ return this . angleWithSep ( e . x , e . y )}, angleWithSep ( e , t ){ return Math . atan2 ( this . x * t - this . y * e , this . x * e + this . y * t )}, _matMult ( e ){ let t = e [ 0 ] * this . x + e [ 1 ] * this . y , i = e [ 2 ] * this . x + e [ 3 ] * this . y ; return this . x = t , this . y = i , this }, _add ( e ){ return this . x += e . x , this . y += e . y , this }, _sub ( e ){ return this . x -= e . x , this . y -= e . y , this }, _mult ( e ){ return this . x *= e , this . y *= e , this }, _div ( e ){ return this . x /= e , this . y /= e , this }, _multByPoint ( e ){ return this . x *= e . x , this . y *= e . y , this }, _divByPoint ( e ){ return this . x /= e . x , this . y /= e . y , this }, _unit (){ return this . _div ( this . mag ()), this }, _perp (){ let e = this . y ; return this . y = this . x , this . x =- e , this }, _rotate ( e ){ let t = Math . cos ( e ), i = Math . sin ( e ), r = t * this . x - i * this . y , a = i * this . x + t * this . y ; return this . x = r , this . y = a , this }, _rotateAround ( e , t ){ let i = Math . cos ( e ), r = Math . sin ( e ), a = t . x + i * ( this . x - t . x ) - r * ( this . y - t . y ), n = t . y + r * ( this . x - t . x ) + i * ( this . y - t . y ); return this . x = a , this . y = n , this }, _round (){ return this . x = Math . round ( this . x ), this . y = Math . round ( this . y ), this }, constructor : M }, M . convert = function ( e ){ if ( e instanceof M ) return e ; if ( Array . isArray ( e )) return new M ( + e [ 0 ], + e [ 1 ]); if ( e . x !== void 0 && e . y !== void 0 ) return new M ( + e . x , + e . y ); throw Error ( "Expected [x, y] or {x, y} point format" )}; function Hx ( e , t , i , r ){ let a = 3 * e , n = 3 * ( i - e ) - a , o = 1 - a - n , s = 3 * t , l = 3 * ( r - t ) - s , u = 1 - s - l ; return function ( h , c = 1e-6 ){ if ( h <= 0 ) return 0 ; if ( h >= 1 ) return 1 ; let d = h ; for ( let m = 0 ; m < 8 ; m ++ ){ let g = (( o * d + n ) * d + a ) * d - h ; if ( Math . abs ( g ) < c ) return (( u * d + l ) * d + s ) * d ; let _ = ( 3 * o * d + 2 * n ) * d + a ; if ( Math . abs ( _ ) < 1e-6 ) break ; d -= g / _ } let p = 0 , f = 1 ; d = h ; for ( let m = 0 ; m < 20 ; m ++ ){ let g = (( o * d + n ) * d + a ) * d ; if ( Math . abs ( g - h ) < c ) break ; h > g ? p = d : f = d , d = ( p + f ) * . 5 } return (( u * d + l ) * d + s ) * d }} let bn ; function cd (){ return bn != null || ( bn = typeof OffscreenCanvas < "u" &&!! new OffscreenCanvas ( 1 , 1 ). getContext ( "2d" ) && typeof createImageBitmap == "function" ), bn } let rs ; function L_ (){ if ( rs == null && ( rs =! 1 , cd ())){ let e = new OffscreenCanvas ( 5 , 5 ). getContext ( "2d" ,{ willReadFrequently :! 0 }); if ( e ){ for ( let i = 0 ; i < 25 ; i ++ ){ let r = i * 4 ; e . fillStyle = `rgb( ${ r } , ${ r + 1 } , ${ r + 2 } )` , e . fillRect ( i % 5 , Math . floor ( i / 5 ), 1 , 1 )} let t = e . getImageData ( 0 , 0 , 5 , 5 ). data ; for ( let i = 0 ; i < 100 ; i ++ ) if ( i % 4 != 3 && t [ i ] !== i ){ rs =! 0 ; break }}} return rs ||! 1 } var Tt = typeof Float32Array < "u" ? Float32Array : Array ; function B_ (){ var e = new Tt ( 4 ); return Tt != Float32Array && ( e [ 1 ] = 0 , e [ 2 ] = 0 ), e [ 0 ] = 1 , e [ 3 ] = 1 , e } function Xx ( e , t ){ var i = t [ 0 ], r = t [ 1 ], a = t [ 2 ], n = t [ 3 ], o = i * n - a * r ; return o ? ( o = 1 / o , e [ 0 ] = n * o , e [ 1 ] =- r * o , e [ 2 ] =- a * o , e [ 3 ] = i * o , e ) : null } function Yx ( e ){ return e [ 0 ] * e [ 3 ] - e [ 2 ] * e [ 1 ]} function Kx ( e , t , i ){ var r = t [ 0 ], a = t [ 1 ], n = t [ 2 ], o = t [ 3 ], s = Math . sin ( i ), l = Math . cos ( i ); return e [ 0 ] = r * l + n * s , e [ 1 ] = a * l + o * s , e [ 2 ] = r *- s + n * l , e [ 3 ] = a *- s + o * l , e } function O_ (){ var e = new Tt ( 9 ); return Tt != Float32Array && ( e [ 1 ] = 0 , e [ 2 ] = 0 , e [ 3 ] = 0 , e [ 5 ] = 0 , e [ 6 ] = 0 , e [ 7 ] = 0 ), e [ 0 ] = 1 , e [ 4 ] = 1 , e [ 8 ] = 1 , e } function Jx ( e ){ var t = e [ 0 ], i = e [ 1
Use an identity property function instead : \ `{ "type": "identity", "property": ${ JSON . stringify ( c [ 1 ]) } }\`.` )]; let d = []; return e . layerType === "symbol" && s === "text-font" && ql ( ia ( o )) && rt ( o . type ) === "identity" && d . push ( new j ( i , o , '"text-font" does not support identity functions' )), d . concat ( r ({ key : e . key , value : o , valueSpec : h , style : a , styleSpec : n , expressionContext : "property" , propertyType : t , propertyKey : s }))} function o0 ( e ){ return n0 ( e , "paint" )} function s0 ( e ){ return n0 ( e , "layout" )} function l0 ( e ){ var l , u ; let t = [], i = e . value , r = e . key , a = e . style , n = e . styleSpec ; if ( fe ( i ) !== "object" ) return [ new j ( r , i , `object expected, ${ fe ( i ) } found` )]; ! i . type &&! i . ref && t . push ( new j ( r , i , 'either "type" or "ref" is required' )); let o = rt ( i . type ), s = rt ( i . ref ); if ( i . id ){ let h = rt ( i . id ); for ( let c = 0 ; c < e . arrayIndex ; c ++ ){ let d = a . layers [ c ]; rt ( d . id ) === h && t . push ( new j ( r , i . id , `duplicate layer id " ${ i . id } ", previously used at line ${ d . id . __line__ } ` ))}} if ( "ref" in i ){[ "type" , "source" , "source-layer" , "filter" , "layout" ]. forEach ( c =>{ c in i && t . push ( new j ( r , i [ c ], `" ${ c } " is prohibited for ref layers` ))}); let h ; a . layers . forEach ( c =>{ rt ( c . id ) === s && ( h = c )}), h ? h . ref ? t . push ( new j ( r , i . ref , "ref cannot reference another ref layer" )) : o = rt ( h . type ) : t . push ( new j ( r , i . ref , `ref layer " ${ s } " not found` ))} else if ( o !== "background" ) if ( ! i . source ) t . push ( new j ( r , i , 'missing required property "source"' )); else { let h = a . sources && a . sources [ i . source ], c = h && rt ( h . type ); h ? c === "vector" && o === "raster" ? t . push ( new j ( r , i . source , `layer " ${ i . id } " requires a raster source` )) : c !== "raster-dem" && o === "hillshade" || c !== "raster-dem" && o === "color-relief" ? t . push ( new j ( r , i . source , `layer " ${ i . id } " requires a raster-dem source` )) : c === "raster" && o !== "raster" ? t . push ( new j ( r , i . source , `layer " ${ i . id } " requires a vector source` )) : c === "vector" &&! i [ "source-layer" ] ? t . push ( new j ( r , i , `layer " ${ i . id } " must specify a "source-layer"` )) : c === "raster-dem" && o !== "hillshade" && o !== "color-relief" ? t . push ( new j ( r , i . source , "raster-dem source can only be used with layer type 'hillshade' or 'color-relief'." )) : o === "line" && i . paint && i . paint [ "line-gradient" ] && ( c !== "geojson" ||! h . lineMetrics ) && t . push ( new j ( r , i , `layer " ${ i . id } " specifies a line-gradient, which requires a GeoJSON source with \`lineMetrics\` enabled.` )) : t . push ( new j ( r , i . source , `source " ${ i . source } " not found` ))} return o === "raster" && (( l = i . paint ) != null && l . resampling ) && (( u = i . paint ) != null && u [ "raster-resampling" ]) && t . push ( new j ( r , i . paint , `layer " ${ i . id } " redundantly specifies "resampling" and "raster-resampling" paint properties, but only one is allowed. It is advised to use "resampling".` )), t = t . concat ( ai ({ key : r , value : i , valueSpec : n . layer , style : e . style , styleSpec : e . styleSpec , validateSpec : e . validateSpec , objectElementValidators : { "*" (){ return []}, type (){ return e . validateSpec ({ key : ` ${ r } .type` , value : i . type , valueSpec : n . layer . type , style : e . style , styleSpec : e . styleSpec , validateSpec : e . validateSpec , object : i , objectKey : "type" })}, filter : Ld , layout ( h ){ return ai ({ layer : i , key : h . key , value : h . value , style : h . style , styleSpec : h . styleSpec , validateSpec : h . validateSpec , objectElementValidators : { "*" ( c ){ return s0 ( oo ({ layerType : o }, c ))}}})}, paint ( h ){ return ai ({ layer : i , key : h . key , value : h . value , style : h . style , styleSpec : h . styleSpec , validateSpec : h . validateSpec , objectElementValidators : { "*" ( c ){ return o0 ( oo ({ layerType : o }, c ))}}})}}})), t } function zr ( e ){ let t = e . value , i = e . key , r = fe ( t ); return r === "string" ? [] : [ new j ( i , t , `string expected, ${ r } found` )]} function Ww ( e ){ var c ; let t = ( c = e . sourceName ) != null ? c : "" , i = e . value , r = e . styleSpec , a = r . source_raster_dem , n = e . style , o = [], s = fe ( i ); if ( i === void 0 ) return o ; if ( s !== "object" ) return o . push ( new j ( "source_raster_dem" , i , `object expected, ${ s } found` )), o ; let l = rt ( i . encoding ) === "custom" , u = [ "redFactor" , "greenFactor" , "blueFactor" , "baseShift" ], h = e . value . encoding ? `" ${ e . value . encoding } "` : "Default" ; for ( let d in i ) ! l && u . includes ( d ) ? o . push ( new j ( d , i [ d ], `In " ${ t } ": " ${ d } " is only valid when "encoding" is set to "custom". ${ h } encoding found` )) : a [ d ] ? o = o . concat ( e . validateSpec ({ key : d , value : i [ d ], valueSpec : a [ d ], validateSpec : e . validateSpec , style : n , styleSpec : r })) : o . push ( new j ( d , i [ d ], `unknown property " ${ d } "` )); return o } const Uf = { promoteId : Hw }; function u0 ( e ){ l
2026-10-19 00:00:12 +08:00
precision mediump float ;
# else
# if ! defined ( lowp )
# define lowp
# endif
# if ! defined ( mediump )
# define mediump
# endif
# if ! defined ( highp )
# define highp
# endif
# endif
out highp vec4 fragColor ; layout ( std140 ) uniform ProjectionUBO { highp mat4 u_projection_matrix ; highp mat4 u_projection_fallback_matrix ; highp vec4 u_projection_tile_mercator_coords ; highp vec4 u_projection_clipping_plane ; highp float u_projection_transition ; highp int u_projection_clip_antimeridian ;}; layout ( std140 ) uniform FrameUBO { highp vec2 u_units_to_pixels ; highp vec2 u_world_size ; highp float u_camera_to_center_distance ; highp float u_symbol_fade_change ; highp float u_aspect_ratio ; highp float u_device_pixel_ratio ; highp vec2 u_viewport_size ; highp vec2 u_pixel_extrude_scale ; highp float u_pitch ;}; `,II=` # ifdef GL_ES
precision highp float ;
# else
# if ! defined ( lowp )
# define lowp
# endif
# if ! defined ( mediump )
# define mediump
# endif
# if ! defined ( highp )
# define highp
# endif
# endif
vec2 unpack_float ( const float packedValue ) { int packedIntValue = int ( packedValue ); int v0 = packedIntValue / 256 ; return vec2 ( v0 , packedIntValue - v0 * 256 );} vec2 unpack_opacity ( const uint packedOpacity ) { return vec2 ( float ( packedOpacity >> 1 u ) / 127.0 , float ( packedOpacity & 1 u ));} vec4 decode_color ( const vec2 encodedColor ) { return vec4 ( unpack_float ( encodedColor [ 0 ]) / 255.0 , unpack_float ( encodedColor [ 1 ]) / 255.0
);} float unpack_mix_vec2 ( const vec2 packedValue , const float t ) { return mix ( packedValue [ 0 ], packedValue [ 1 ], t );} vec4 unpack_mix_color ( const vec4 packedColors , const float t ) { vec4 minColor = decode_color ( vec2 ( packedColors [ 0 ], packedColors [ 1 ])); vec4 maxColor = decode_color ( vec2 ( packedColors [ 2 ], packedColors [ 3 ])); return mix ( minColor , maxColor , t );} vec2 get_pattern_pos ( const vec2 pixel_coord_upper , const vec2 pixel_coord_lower , const vec2 pattern_size , const float tile_units_to_pixels , const vec2 pos ) { vec2 offset = mod ( mod ( mod ( pixel_coord_upper , pattern_size ) * 256.0 , pattern_size ) * 256.0 + pixel_coord_lower , pattern_size ); return ( tile_units_to_pixels * pos + offset ) / pattern_size ;} mat3 rotationMatrixFromAxisAngle ( vec3 u , float angle ) { float c = cos ( angle ); float s = sin ( angle ); float c2 = 1.0 - c ; return mat3 ( u . x * u . x * c2 + c , u . x * u . y * c2 - u . z * s , u . x * u . z * c2 + u . y * s , u . y * u . x * c2 + u . z * s , u . y * u . y * c2 + c , u . y * u . z * c2 - u . x * s , u . z * u . x * c2 - u . y * s , u . z * u . y * c2 + u . x * s , u . z * u . z * c2 + c
);}
# ifdef TERRAIN3D
uniform sampler2D u_terrain ; uniform highp sampler2D u_depth ; layout ( std140 ) uniform TerrainUBO { highp mat4 u_terrain_matrix ; highp vec4 u_terrain_unpack ; highp float u_terrain_dim ; highp float u_terrain_exaggeration ;};
# endif
const highp vec4 bitSh = vec4 ( 256. * 256. * 256. , 256. * 256. , 256. , 1. ); const highp vec4 bitShifts = vec4 ( 1. ) / bitSh ; highp float unpack ( highp vec4 color ) { return dot ( color , bitShifts );} highp float depthOpacity ( vec3 frag ) {
# ifdef TERRAIN3D
highp float d = unpack ( texture ( u_depth , frag . xy * 0.5 + 0.5 )) + 0.0001 - frag . z ; return 1.0 - max ( 0.0 , min ( 1.0 , - d * 500.0 ));
# else
return 1.0 ;
# endif
} float calculate_visibility ( vec4 pos ) {
# ifdef TERRAIN3D
vec3 frag = pos . xyz / pos . w ; highp float d = depthOpacity ( frag ); if ( d > 0.95 ) return 1.0 ; return ( d + depthOpacity ( frag + vec3 ( 0.0 , 0.01 , 0.0 ))) / 2.0 ;
# else
return 1.0 ;
# endif
} float ele ( ivec2 pos ) {
# ifdef TERRAIN3D
vec4 rgb = ( texelFetch ( u_terrain , pos , 0 ) * 255.0 ) * u_terrain_unpack ; return rgb . r + rgb . g + rgb . b - u_terrain_unpack . a ;
# else
return 0.0 ;
# endif
} float get_elevation ( vec2 pos ) {
# ifdef TERRAIN3D
# ifdef GLOBE
if (( pos . y <- 32767.5 ) || ( pos . y > 32766.5 )) { return 0.0 ;}
# endif
vec2 coord = ( u_terrain_matrix * vec4 ( pos , 0.0 , 1.0 )). xy * u_terrain_dim + 1.5 ; vec2 f = fract ( coord ); ivec2 c = ivec2 ( floor ( coord )); ivec2 hi = textureSize ( u_terrain , 0 ) - 1 ; float tl = ele ( clamp ( c , ivec2 ( 0 ), hi )); float tr = ele ( clamp ( c + ivec2 ( 1 , 0 ), ivec2 ( 0 ), hi )); float bl = ele ( clamp ( c + ivec2 ( 0 , 1 ), ivec2 ( 0 ), hi )); float br = ele ( clamp ( c + ivec2 ( 1 , 1 ), ivec2 ( 0 ), hi )); float elevation = mix ( mix ( tl , tr , f . x ), mix ( bl , br , f . x ), f . y ); return elevation * u_terrain_exaggeration ;
# else
return 0.0 ;
# endif
} const float PI = 3.141592653589793 ;
# define PROJECTION_UBO
layout ( std140 ) uniform ProjectionUBO { highp mat4 u_projection_matrix ; highp mat4 u_projection_fallback_matrix ; highp vec4 u_projection_tile_mercator_coords ; highp vec4 u_projection_clipping_plane ; highp float u_projection_transition ; highp int u_projection_clip_antimeridian ;}; layout ( std140 ) uniform FrameUBO { highp vec2 u_units_to_pixels ; highp vec2 u_world_size ; highp float u_camera_to_center_distance ; highp float u_symbol_fade_change ; highp float u_aspect_ratio ; highp float u_device_pixel_ratio ; highp vec2 u_viewport_size ; highp vec2 u_pixel_extrude_scale ; highp float u_pitch ;}; `,FI=` uniform vec4 u_color ; uniform float u_opacity ; void main () { fragColor = u_color * u_opacity ;
# ifdef OVERDRAW_INSPECTOR
fragColor = vec4 ( 1.0 );
# endif
} `,zI="layout(location=0) in vec2 a_pos;void main() {gl_Position=projectTile(a_pos,a_pos);}",kI=` uniform vec2 u_pattern_tl_a ; uniform vec2 u_pattern_br_a ; uniform vec2 u_pattern_tl_b ; uniform vec2 u_pattern_br_b ; uniform vec2 u_texsize ; uniform float u_mix ; uniform float u_opacity ; uniform sampler2D u_image ; in vec2 v_pos_a ; in vec2 v_pos_b ; void main () { vec2 imagecoord = mod ( v_pos_a , 1.0 ); vec2 pos = mix ( u_pattern_tl_a / u_texsize , u_pattern_br_a / u_texsize , imagecoord ); vec4 color1 = texture ( u_image , pos ); vec2 imagecoord_b = mod ( v_pos_b , 1.0 ); vec2 pos2 = mix ( u_pattern_tl_b / u_texsize , u_pattern_br_b / u_texsize , imagecoord_b ); vec4 color2 = texture ( u_image , pos2 ); fragColor = mix ( color1 , color2 , u_mix ) * u_opacity ;
# ifdef OVERDRAW_INSPECTOR
fragColor = vec4 ( 1.0 );
# endif
} `,RI="uniform vec2 u_pattern_size_a;uniform vec2 u_pattern_size_b;uniform vec2 u_pixel_coord_upper;uniform vec2 u_pixel_coord_lower;uniform float u_scale_a;uniform float u_scale_b;uniform float u_tile_units_to_pixels;layout(location=0) in vec2 a_pos;out vec2 v_pos_a;out vec2 v_pos_b;void main() {gl_Position=projectTile(a_pos,a_pos);v_pos_a=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_a*u_pattern_size_a,u_tile_units_to_pixels,a_pos);v_pos_b=get_pattern_pos(u_pixel_coord_upper,u_pixel_coord_lower,u_scale_b*u_pattern_size_b,u_tile_units_to_pixels,a_pos);}",LI=` in vec3 v_data ; in float v_visibility ;
# pragma maplibre : define highp vec4 color
# pragma maplibre : define mediump float radius
# pragma maplibre : define lowp float blur
# pragma maplibre : define lowp float opacity
# pragma maplibre : define highp vec4 stroke_color
# pragma maplibre : define mediump float stroke_width
# pragma maplibre : define lowp float stroke_opacity
void main () {
# pragma maplibre : initialize highp vec4 color
# pragma maplibre : initialize mediump float radius
# pragma maplibre : initialize lowp float blur
# pragma maplibre : initialize lowp float opacity
# pragma maplibre : initialize highp vec4 stroke_color
# pragma maplibre : initialize mediump float stroke_width
# pragma maplibre : initialize lowp float stroke_opacity
vec2 extrude = v_data . xy ; float extrude_length = length ( extrude ); float antialiased_blur = v_data . z ; float opacity_t = smoothstep ( 0.0 , antialiased_blur , extrude_length - 1.0 ); float color_t = stroke_width < 0.01 ? 0.0 : smoothstep ( antialiased_blur , 0.0 , extrude_length - radius / ( radius + stroke_width )); fragColor = v_visibility * opacity_t * mix ( color * opacity , stroke_color * stroke_opacity , color_t ); const float epsilon = 0.5 / 255.0 ; if ( fragColor . r < epsilon && fragColor . g < epsilon && fragColor . b < epsilon && fragColor . a < epsilon ) { discard ;}
# ifdef OVERDRAW_INSPECTOR
fragColor = vec4 ( 1.0 );
# endif
} `,BI=` uniform bool u_scale_with_map ; uniform bool u_pitch_with_map ; uniform vec2 u_extrude_scale ; uniform highp float u_globe_extrude_scale ; uniform vec2 u_translate ; layout ( location = 0 ) in ivec2 a_pos ; out vec3 v_data ; out float v_visibility ;
# pragma maplibre : define highp vec4 color
# pragma maplibre : define mediump float radius
# pragma maplibre : define lowp float blur
# pragma maplibre : define lowp float opacity
# pragma maplibre : define highp vec4 stroke_color
# pragma maplibre : define mediump float stroke_width
# pragma maplibre : define lowp float stroke_opacity
void main ( void ) {
# pragma maplibre : initialize highp vec4 color
# pragma maplibre : initialize mediump float radius
# pragma maplibre : initialize lowp float blur
# pragma maplibre : initialize lowp float opacity
# pragma maplibre : initialize highp vec4 stroke_color
# pragma maplibre : initialize mediump float stroke_width
# pragma maplibre : initialize lowp float stroke_opacity
ivec2 pos_raw = a_pos + 32768 ; vec2 extrude = vec2 ( pos_raw & 7 ) / 7.0 * 2.0 - 1.0 ; vec2 circle_center = vec2 ( pos_raw >> 3 ) + u_translate ; float ele = get_elevation ( circle_center ); v_visibility = calculate_visibility ( projectTileWithElevation ( circle_center , ele )); if ( u_pitch_with_map ) {
# ifdef GLOBE
vec3 center_vector = projectToSphere ( circle_center );
# endif
float angle_scale = u_globe_extrude_scale ; vec2 corner_position = circle_center ; if ( u_scale_with_map ) { angle_scale *= ( radius + stroke_width ); corner_position += extrude * u_extrude_scale * ( radius + stroke_width );} else {
# ifdef GLOBE
vec4 projected_center = interpolateProjection ( circle_center , center_vector , ele );
# else
vec4 projected_center = projectTileWithElevation ( circle_center , ele );
# endif
corner_position += extrude * u_extrude_scale * ( radius + stroke_width ) * ( projected_center . w / u_camera_to_center_distance ); angle_scale *= ( radius + stroke_width ) * ( projected_center . w / u_camera_to_center_distance );}
# ifdef GLOBE
vec2 angles = extrude * angle_scale ; vec3 corner_vector = globeRotateVector ( center_vector , angles ); gl_Position = interpolateProjection ( corner_position , corner_vector , ele );
# else
gl_Position = projectTileWithElevation ( corner_position , ele );
# endif
} else { gl_Position = projectTileWithElevation ( circle_center , ele ); if ( gl_Position . z / gl_Position . w > 1.0 ) { gl_Position . xy = vec2 ( 10000.0 );} if ( u_scale_with_map ) { gl_Position . xy += extrude * ( radius + stroke_width ) * u_extrude_scale * u_camera_to_center_distance ;} else { gl_Position . xy += extrude * ( radius + stroke_width ) * u_extrude_scale * gl_Position . w ;}} float antialiasblur =- max ( 1.0 / u_device_pixel_ratio / ( radius + stroke_width ), blur ); v_data = vec3 ( extrude . x , extrude . y , antialiasblur );} `,jg="void main() {fragColor=vec4(1.0);}";const Wi={prelude:we(MI,II),projectionMercator:we(`
void clipAntimeridian () {} `,"float projectLineThickness(float tileY) {return 1.0;}float projectCircleRadius(float tileY) {return 1.0;}vec4 projectTile(vec2 p) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);return result;}vec4 projectTile(vec2 p,vec2 rawPos) {vec4 result=u_projection_matrix*vec4(p,0.0,1.0);if (rawPos.y <-32767.5 || rawPos.y > 32766.5) {result.z=-10000000.0;}return result;}vec4 projectTileWithElevation(vec2 posInTile,float elevation) {return u_projection_matrix*vec4(posInTile,elevation,1.0);}vec4 projectTileFor3D(vec2 posInTile,float elevation) {return projectTileWithElevation(posInTile,elevation);}"),projectionGlobe:we("in highp float v_projection_tile_x;void clipAntimeridian() {if (u_projection_clip_antimeridian !=0 && (v_projection_tile_x < 0.0 || v_projection_tile_x >=8192.0)) {discard;}}",` # define GLOBE_RADIUS 6371008.8
# ifndef PROJECTION_UBO
uniform highp vec4 u_projection_tile_mercator_coords ; uniform highp vec4 u_projection_clipping_plane ; uniform highp float u_projection_transition ; uniform mat4 u_projection_fallback_matrix ;
# endif
out highp float v_projection_tile_x ; vec3 globeRotateVector ( vec3 vec , vec2 angles ) { vec3 axisRight = vec3 ( vec . z , 0.0 , - vec . x ); vec3 axisUp = cross ( axisRight , vec ); axisRight = normalize ( axisRight ); axisUp = normalize ( axisUp ); vec2 t = tan ( angles ); return normalize ( vec + axisRight * t . x + axisUp * t . y );} mat3 globeGetRotationMatrix ( vec3 spherePos ) { vec3 axisRight = vec3 ( spherePos . z , 0.0 , - spherePos . x ); vec3 axisDown = cross ( axisRight , spherePos ); axisRight = normalize ( axisRight ); axisDown = normalize ( axisDown ); return mat3 ( axisRight , axisDown , spherePos
);} float circumferenceRatioAtTileY ( float tileY ) { float mercator_pos_y = u_projection_tile_mercator_coords . y + u_projection_tile_mercator_coords . w * tileY ; float t = exp ( PI - ( mercator_pos_y * PI * 2.0 )); return ( 2.0 * t ) / ( t * t + 1.0 );} float projectLineThickness ( float tileY ) { float thickness = 1.0 / circumferenceRatioAtTileY ( tileY ); if ( u_projection_transition < 0.999 ) { return mix ( 1.0 , thickness , u_projection_transition );} else { return thickness ;}} vec3 projectToSphere ( vec2 translatedPos , vec2 rawPos ) { vec2 mercator_pos = u_projection_tile_mercator_coords . xy + u_projection_tile_mercator_coords . zw * translatedPos ; float spherical_x = mercator_pos . x * PI * 2.0 + PI ; float t = exp ( PI - ( mercator_pos . y * PI * 2.0 )); float t2 = t * t ; float denom = t2 + 1.0 ; float sin_sy = ( t2 - 1.0 ) / denom ; float cos_sy = ( 2.0 * t ) / denom ; vec3 pos = vec3 ( sin ( spherical_x ) * cos_sy , sin_sy , cos ( spherical_x ) * cos_sy
); if ( rawPos . y <- 32767.5 ) { pos = vec3 ( 0.0 , 1.0 , 0.0 );} if ( rawPos . y > 32766.5 ) { pos = vec3 ( 0.0 , - 1.0 , 0.0 );} return pos ;} vec3 projectToSphere ( vec2 posInTile ) { return projectToSphere ( posInTile , vec2 ( 0.0 , 0.0 ));} float globeComputeClippingZ ( vec3 spherePos ) { return ( 1.0 - ( dot ( spherePos , u_projection_clipping_plane . xyz ) + u_projection_clipping_plane . w ));} vec4 interpolateProjection ( vec2 posInTile , vec3 spherePos , float elevation ) { v_projection_tile_x = posInTile . x ; vec3 elevatedPos = spherePos * ( 1.0 + elevation / GLOBE_RADIUS ); vec4 globePosition = u_projection_matrix * vec4 ( elevatedPos , 1.0 ); globePosition . z = globeComputeClippingZ ( elevatedPos ) * globePosition . w ; if ( u_projection_transition > 0.999 ) { return globePosition ;} vec4 flatPosition = u_projection_fallback_matrix * vec4 ( posInTile , elevation , 1.0 ); const float z_globeness_threshold = 0.2 ; vec4 result = globePosition ; result . z = mix ( 0.0 , globePosition . z , clamp (( u_projection_transition - z_globeness_threshold ) / ( 1.0 - z_globeness_threshold ), 0.0 , 1.0 )); result . xyw = mix ( flatPosition . xyw , globePosition . xyw , u_projection_transition ); if (( posInTile . y <- 32767.5 ) || ( posInTile . y > 32766.5 )) { result = globePosition ; const float poles_hidden_anim_percentage = 0.02 ; result . z = mix ( globePosition . z , 100.0 , pow ( max (( 1.0 - u_projection_transition ) / poles_hidden_anim_percentage , 0.0 ), 8.0 ));} return result ;} vec4 interpolateProjectionFor3D ( vec2 posInTile , vec3 spherePos , float elevation ) { v_projection_tile_x = posInTile . x ; vec3 elevatedPos = spherePos * ( 1.0 + elevation / GLOBE_RADIUS ); vec4 globePosition = u_projection_matrix * vec4 ( elevatedPos , 1.0 ); if ( u_projection_transition > 0.999 ) { return globePosition ;} vec4 fallbackPosition = u_projection_fallback_matrix * vec4 ( posInTile , elevation , 1.0 ); return mix ( fallbackPosition , globePosition , u_projection_transition );} vec4 projectTile ( vec2 posInTile ) { return interpolateProjection ( posInTile , projectToSphere ( posInTile ), 0.0 );} vec4 projectTile ( vec2 posInTile , vec2 rawPos ) { return interpolateProjection ( posInTile , projectToSphere ( posInTile , rawPos ), 0.0 );} vec4 projectTileWithElevation ( vec2 posInTile , float elevation ) { return interpolateProjection ( posInTile , projectToSphere ( posInTile ), elevation );} vec4 projectTileFor3D ( vec2 posInTile , float elevation ) { vec3 spherePos = projectToSphere ( posInTile , posInTile ); return interpolateProjectionFor3D ( posInTile , spherePos , elevation );} `),background:we(FI,zI),backgroundPattern:we(kI,RI),circle:we(LI,BI),clippingMask:we(jg,"layout(location=0) in vec2 a_pos;void main() {gl_Position=projectTile(a_pos,a_pos);}"),heatmap:we(` uniform highp float u_intensity ; in vec2 v_extrude ;
# pragma maplibre : define highp float weight
# define GAUSS_COEF 0.3989422804014327
void main () {
# pragma maplibre : initialize highp float weight
float d =- 0.5 * 3.0 * 3.0 * dot ( v_extrude , v_extrude ); float val = weight * u_intensity * GAUSS_COEF * exp ( d ); fragColor = vec4 ( val , 1.0 , 1.0 , 1.0 );
# ifdef OVERDRAW_INSPECTOR
fragColor = vec4 ( 1.0 );
# endif
} `,` uniform float u_extrude_scale ; uniform float u_opacity ; uniform float u_intensity ; uniform highp float u_globe_extrude_scale ; layout ( location = 0 ) in ivec2 a_pos ; out vec2 v_extrude ;
# pragma maplibre : define highp float weight
# pragma maplibre : define mediump float radius
const highp float ZERO = 1.0 / 255.0 / 16.0 ;
# define GAUSS_COEF 0.3989422804014327
void main ( void ) {
# pragma maplibre : initialize highp float weight
# pragma maplibre : initialize mediump float radius
ivec2 pos_raw = a_pos + 32768 ; vec2 unscaled_extrude = vec2 ( pos_raw & 7 ) / 7.0 * 2.0 - 1.0 ; float S = sqrt ( - 2.0 * log ( ZERO / weight / u_intensity / GAUSS_COEF )) / 3.0 ; v_extrude = S * unscaled_extrude ; vec2 extrude = v_extrude * radius * u_extrude_scale ; vec2 circle_center = vec2 ( pos_raw >> 3 );
# ifdef GLOBE
vec2 angles = v_extrude * radius * u_globe_extrude_scale ; vec3 center_vector = projectToSphere ( circle_center ); vec3 corner_vector = globeRotateVector ( center_vector , angles ); gl_Position = interpolateProjection ( circle_center + extrude , corner_vector , 0.0 );
# else
gl_Position = projectTileFor3D ( circle_center + extrude , get_elevation ( circle_center ));
# endif
} `),heatmapTexture:we(` uniform sampler2D u_image ; uniform sampler2D u_color_ramp ; uniform float u_opacity ; in vec2 v_pos ; void main () { float t = texture ( u_image , v_pos ). r ; vec4 color = texture ( u_color_ramp , vec2 ( t , 0.5 )); fragColor = color * u_opacity ;
# ifdef OVERDRAW_INSPECTOR
fragColor = vec4 ( 0.0 );
# endif
} `,"uniform mat4 u_matrix;layout(location=0) in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos*u_world_size,0,1);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),collisionBox:we("in float v_placed;in float v_notUsed;void main() {float alpha=0.5;fragColor=vec4(1.0,0.0,0.0,1.0)*alpha;if (v_placed > 0.5) {fragColor=vec4(0.0,0.0,1.0,0.5)*alpha;}if (v_notUsed > 0.5) {fragColor*=.1;}}","layout(location=0) in vec2 a_anchor_pos;layout(location=1) in vec2 a_placed;layout(location=2) in vec2 a_box_real;out float v_placed;out float v_notUsed;void main() {gl_Position=projectTileWithElevation(a_anchor_pos,get_elevation(a_anchor_pos));gl_Position.xy=((a_box_real+0.5)*u_pixel_extrude_scale*2.0-1.0)*vec2(1.0,-1.0)*gl_Position.w;if (gl_Position.z/gl_Position.w < 1.1) {gl_Position.z=0.5;}v_placed=a_placed.x;v_notUsed=a_placed.y;}"),collisionCircle:we("in float v_radius;in vec2 v_extrude;in float v_collision;void main() {float alpha=0.5;float stroke_radius=0.9;float distance_to_center=length(v_extrude);float distance_to_edge=abs(distance_to_center-v_radius);float opacity_t=smoothstep(-stroke_radius,0.0,-distance_to_edge);vec4 color=mix(vec4(0.0,0.0,1.0,0.5),vec4(1.0,0.0,0.0,1.0),v_collision);fragColor=color*alpha*opacity_t;}","layout(location=0) in vec2 a_pos;layout(location=1) in float a_radius;layout(location=2) in vec2 a_flags;out float v_radius;out vec2 v_extrude;out float v_collision;void main() {float radius=a_radius;float collision=a_flags.x;float vertexIdx=a_flags.y;vec2 quadVertexOffset=vec2(mix(-1.0,1.0,float(vertexIdx >=2.0)),mix(-1.0,1.0,float(vertexIdx >=1.0 && vertexIdx <=2.0)));vec2 quadVertexExtent=quadVertexOffset*radius;float padding_factor=1.2;v_radius=radius;v_extrude=quadVertexExtent*padding_factor;v_collision=collision;gl_Position=vec4((a_pos/u_viewport_size*2.0-1.0)*vec2(1.0,-1.0),0.0,1.0)+vec4(quadVertexExtent*padding_factor/u_viewport_size*2.0,0.0,0.0);}"),colorRelief:we(` # ifdef GL_ES
precision highp float ;
# endif
uniform sampler2D u_image ; uniform vec4 u_unpack ; uniform sampler2D u_elevation_stops ; uniform sampler2D u_color_stops ; uniform int u_color_ramp_size ; uniform float u_opacity ; in vec2 v_pos ; float getElevation ( vec2 coord ) { vec4 data = texture ( u_image , coord ) * 255.0 ; data . a =- 1.0 ; return dot ( data , u_unpack );} float getElevationStop ( int stop ) { vec4 data = texelFetch ( u_elevation_stops , ivec2 ( stop , 0 ), 0 ) * 255.0 ; data . a =- 1.0 ; return dot ( data , u_unpack );} void main () { float el = getElevation ( v_pos ); int r = ( u_color_ramp_size - 1 ); int l = 0 ; float el_l = getElevationStop ( l ); float el_r = getElevationStop ( r ); while ( r - l > 1 ){ int m = ( r + l ) / 2 ; float el_m = getElevationStop ( m ); if ( el < el_m ){ r = m ; el_r = el_m ;} else
{ l = m ; el_l = el_m ;}} float x = ( float ( l ) + ( el - el_l ) / ( el_r - el_l ) + 0.5 ) / float ( u_color_ramp_size ); fragColor = u_opacity * texture ( u_color_stops , vec2 ( x , 0 ));
# ifdef OVERDRAW_INSPECTOR
fragColor = vec4 ( 1.0 );
# endif
} `,"uniform vec2 u_dimension;layout(location=0) in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);highp vec2 epsilon=2.0/u_dimension;float scale=(u_dimension.x-4.0)/u_dimension.x;v_pos=(a_pos/8192.0)*scale+epsilon;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),debug:we("uniform highp vec4 u_color;uniform sampler2D u_overlay;in vec2 v_uv;void main() {vec4 overlay_color=texture(u_overlay,v_uv);fragColor=mix(u_color,overlay_color,overlay_color.a);}","layout(location=0) in vec2 a_pos;out vec2 v_uv;uniform float u_overlay_scale;void main() {v_uv=a_pos/8192.0;gl_Position=projectTileWithElevation(a_pos*u_overlay_scale,get_elevation(a_pos));}"),depth:we(jg,` layout ( location = 0 ) in vec2 a_pos ; void main () {
# ifdef GLOBE
gl_Position = projectTileFor3D ( a_pos , 0.0 );
# else
gl_Position = u_projection_matrix * vec4 ( a_pos , 0.0 , 1.0 );
# endif
} `),fill:we(` # pragma maplibre : define highp vec4 color
# pragma maplibre : define lowp float opacity
void main () {
# pragma maplibre : initialize highp vec4 color
# pragma maplibre : initialize lowp float opacity
fragColor = color * opacity ;
# ifdef OVERDRAW_INSPECTOR
fragColor = vec4 ( 1.0 );
# endif
} `,` uniform vec2 u_fill_translate ; layout ( location = 0 ) in vec2 a_pos ;
# pragma maplibre : define highp vec4 color
# pragma maplibre : define lowp float opacity
void main () {
# pragma maplibre : initialize highp vec4 color
# pragma maplibre : initialize lowp float opacity
if ( opacity < 0.01 ) { gl_Position = vec4 ( - 2.0 , - 2.0 , - 2.0 , 1.0 ); return ;} gl_Position = projectTile ( a_pos + u_fill_translate , a_pos );} `),fillOutline:we(` in vec2 v_pos ;
# ifdef GLOBE
in float v_depth ;
# endif
# pragma maplibre : define highp vec4 outline_color
# pragma maplibre : define lowp float opacity
void main () {
# pragma maplibre : initialize highp vec4 outline_color
# pragma maplibre : initialize lowp float opacity
float dist = length ( v_pos - gl_FragCoord . xy ); float alpha = 1.0 - smoothstep ( 0.0 , 1.0 , dist ); fragColor = outline_color * ( alpha * opacity );
# ifdef GLOBE
if ( v_depth > 1.0 ) { discard ;}
# endif
# ifdef OVERDRAW_INSPECTOR
fragColor = vec4 ( 1.0 );
# endif
} `,` uniform vec2 u_fill_translate ; layout ( location = 0 ) in vec2 a_pos ; out vec2 v_pos ;
# ifdef GLOBE
out float v_depth ;
# endif
# pragma maplibre : define highp vec4 outline_color
# pragma maplibre : define lowp float opacity
void main () {
# pragma maplibre : initialize highp vec4 outline_color
# pragma maplibre : initialize lowp float opacity
if ( opacity < 0.01 ) { gl_Position = vec4 ( - 2.0 , - 2.0 , - 2.0 , 1.0 ); return ;} gl_Position = projectTile ( a_pos + u_fill_translate , a_pos ); v_pos = ( gl_Position . xy / gl_Position . w + 1.0 ) / 2.0 * u_world_size ;
# ifdef GLOBE
v_depth = gl_Position . z / gl_Position . w ;
# endif
} `),fillOutlinePattern:we(` uniform vec2 u_texsize ; uniform sampler2D u_image ; uniform float u_fade ; uniform bool u_sdf_pattern ; in vec2 v_pos_a ; in vec2 v_pos_b ; in vec2 v_pos ;
# ifdef GLOBE
in float v_depth ;
# endif
# pragma maplibre : define lowp float opacity
# pragma maplibre : define highp vec4 color
# pragma maplibre : define lowp vec4 pattern_from
# pragma maplibre : define lowp vec4 pattern_to
void main () {
# pragma maplibre : initialize lowp float opacity
# pragma maplibre : initialize highp vec4 color
# pragma maplibre : initialize mediump vec4 pattern_from
# pragma maplibre : initialize mediump vec4 pattern_to
vec2 pattern_tl_a = pattern_from . xy ; vec2 pattern_br_a = pattern_from . zw ; vec2 pattern_tl_b = pattern_to . xy ; vec2 pattern_br_b = pattern_to . zw ; vec2 imagecoord = mod ( v_pos_a , 1.0 ); vec2 pos = mix ( pattern_tl_a / u_texsize , pattern_br_a / u_texsize , imagecoord ); vec4 color1 = texture ( u_image , pos ); vec2 imagecoord_b = mod ( v_pos_b , 1.0 ); vec2 pos2 = mix ( pattern_tl_b / u_texsize , pattern_br_b / u_texsize , imagecoord_b ); vec4 color2 = texture ( u_image , pos2 ); float dist = length ( v_pos - gl_FragCoord . xy ); float alpha = 1.0 - smoothstep ( 0.0 , 1.0 , dist ); if ( u_sdf_pattern ) { highp float sdf_edge = ( 256.0 - 64.0 ) / 256.0 ; highp float sdf_gamma_a = max ( fwidth ( color1 . a ) * 0.5 , 1.0 / 255.0 / 16.0 ); highp float sdf_gamma_b = max ( fwidth ( color2 . a ) * 0.5 , 1.0 / 255.0 / 16.0 ); float sdf_alpha_a = smoothstep ( sdf_edge - sdf_gamma_a , sdf_edge + sdf_gamma_a , color1 . a ); float sdf_alpha_b = smoothstep ( sdf_edge - sdf_gamma_b , sdf_edge + sdf_gamma_b , color2 . a ); fragColor = mix ( color * sdf_alpha_a , color * sdf_alpha_b , u_fade ) * alpha * opacity ;} else { fragColor = mix ( color1 , color2 , u_fade ) * alpha * opacity ;}
# ifdef GLOBE
if ( v_depth > 1.0 ) { discard ;}
# endif
# ifdef OVERDRAW_INSPECTOR
fragColor = vec4 ( 1.0 );
# endif
} `,` uniform vec2 u_pixel_coord_upper ; uniform vec2 u_pixel_coord_lower ; uniform vec3 u_scale ; uniform vec2 u_fill_translate ; layout ( location = 0 ) in vec2 a_pos ; out vec2 v_pos_a ; out vec2 v_pos_b ; out vec2 v_pos ;
# ifdef GLOBE
out float v_depth ;
# endif
# pragma maplibre : define lowp float opacity
# pragma maplibre : define highp vec4 color
# pragma maplibre : define lowp vec4 pattern_from
# pragma maplibre : define lowp vec4 pattern_to
# pragma maplibre : define lowp float pixel_ratio_from
# pragma maplibre : define lowp float pixel_ratio_to
void main () {
# pragma maplibre : initialize lowp float opacity
# pragma maplibre : initialize highp vec4 color
# pragma maplibre : initialize mediump vec4 pattern_from
# pragma maplibre : initialize mediump vec4 pattern_to
# pragma maplibre : initialize lowp float pixel_ratio_from
# pragma maplibre : initialize lowp float pixel_ratio_to
if ( opacity < 0.01 ) { gl_Position = vec4 ( - 2.0 , - 2.0 , - 2.0 , 1.0 ); return ;} vec2 pattern_tl_a = pattern_from . xy ; vec2 pattern_br_a = pattern_from . zw ; vec2 pattern_tl_b = pattern_to . xy ; vec2 pattern_br_b = pattern_to . zw ; float tileRatio = u_scale . x ; float fromScale = u_scale . y ; float toScale = u_scale . z ; gl_Position = projectTile ( a_pos + u_fill_translate , a_pos ); vec2 display_size_a = ( pattern_br_a - pattern_tl_a ) / pixel_ratio_from ; vec2 display_size_b = ( pattern_br_b - pattern_tl_b ) / pixel_ratio_to ; v_pos_a = get_pattern_pos ( u_pixel_coord_upper , u_pixel_coord_lower , fromScale * display_size_a , tileRatio , a_pos ); v_pos_b = get_pattern_pos ( u_pixel_coord_upper , u_pixel_coord_lower , toScale * display_size_b , tileRatio , a_pos ); v_pos = ( gl_Position . xy / gl_Position . w + 1.0 ) / 2.0 * u_world_size ;
# ifdef GLOBE
v_depth = gl_Position . z / gl_Position . w ;
# endif
} `),fillPattern:we(` # ifdef GL_ES
precision highp float ;
# endif
uniform vec2 u_texsize ; uniform float u_fade ; uniform bool u_sdf_pattern ; uniform sampler2D u_image ; in vec2 v_pos_a ; in vec2 v_pos_b ;
# pragma maplibre : define lowp float opacity
# pragma maplibre : define highp vec4 color
# pragma maplibre : define lowp vec4 pattern_from
# pragma maplibre : define lowp vec4 pattern_to
void main () {
# pragma maplibre : initialize lowp float opacity
# pragma maplibre : initialize highp vec4 color
# pragma maplibre : initialize mediump vec4 pattern_from
# pragma maplibre : initialize mediump vec4 pattern_to
vec2 pattern_tl_a = pattern_from . xy ; vec2 pattern_br_a = pattern_from . zw ; vec2 pattern_tl_b = pattern_to . xy ; vec2 pattern_br_b = pattern_to . zw ; vec2 imagecoord = mod ( v_pos_a , 1.0 ); vec2 pos = mix ( pattern_tl_a / u_texsize , pattern_br_a / u_texsize , imagecoord ); vec4 color1 = texture ( u_image , pos ); vec2 imagecoord_b = mod ( v_pos_b , 1.0 ); vec2 pos2 = mix ( pattern_tl_b / u_texsize , pattern_br_b / u_texsize , imagecoord_b ); vec4 color2 = texture ( u_image , pos2 ); if ( u_sdf_pattern ) { highp float sdf_edge = ( 256.0 - 64.0 ) / 256.0 ; highp float sdf_gamma_a = max ( fwidth ( color1 . a ) * 0.5 , 1.0 / 255.0 / 16.0 ); highp float sdf_gamma_b = max ( fwidth ( color2 . a ) * 0.5 , 1.0 / 255.0 / 16.0 ); float sdf_alpha_a = smoothstep ( sdf_edge - sdf_gamma_a , sdf_edge + sdf_gamma_a , color1 . a ); float sdf_alpha_b = smoothstep ( sdf_edge - sdf_gamma_b , sdf_edge + sdf_gamma_b , color2 . a ); fragColor = mix ( color * sdf_alpha_a , color * sdf_alpha_b , u_fade ) * opacity ;} else { fragColor = mix ( color1 , color2 , u_fade ) * opacity ;}
# ifdef OVERDRAW_INSPECTOR
fragColor = vec4 ( 1.0 );
# endif
} `,` uniform vec2 u_pixel_coord_upper ; uniform vec2 u_pixel_coord_lower ; uniform vec3 u_scale ; uniform vec2 u_fill_translate ; layout ( location = 0 ) in vec2 a_pos ; out vec2 v_pos_a ; out vec2 v_pos_b ;
# pragma maplibre : define lowp float opacity
# pragma maplibre : define highp vec4 color
# pragma maplibre : define lowp vec4 pattern_from
# pragma maplibre : define lowp vec4 pattern_to
# pragma maplibre : define lowp float pixel_ratio_from
# pragma maplibre : define lowp float pixel_ratio_to
void main () {
# pragma maplibre : initialize lowp float opacity
# pragma maplibre : initialize highp vec4 color
# pragma maplibre : initialize mediump vec4 pattern_from
# pragma maplibre : initialize mediump vec4 pattern_to
# pragma maplibre : initialize lowp float pixel_ratio_from
# pragma maplibre : initialize lowp float pixel_ratio_to
if ( opacity < 0.01 ) { gl_Position = vec4 ( - 2.0 , - 2.0 , - 2.0 , 1.0 ); return ;} vec2 pattern_tl_a = pattern_from . xy ; vec2 pattern_br_a = pattern_from . zw ; vec2 pattern_tl_b = pattern_to . xy ; vec2 pattern_br_b = pattern_to . zw ; float tileZoomRatio = u_scale . x ; float fromScale = u_scale . y ; float toScale = u_scale . z ; vec2 display_size_a = ( pattern_br_a - pattern_tl_a ) / pixel_ratio_from ; vec2 display_size_b = ( pattern_br_b - pattern_tl_b ) / pixel_ratio_to ; gl_Position = projectTile ( a_pos + u_fill_translate , a_pos ); v_pos_a = get_pattern_pos ( u_pixel_coord_upper , u_pixel_coord_lower , fromScale * display_size_a , tileZoomRatio , a_pos ); v_pos_b = get_pattern_pos ( u_pixel_coord_upper , u_pixel_coord_lower , toScale * display_size_b , tileZoomRatio , a_pos );} `),fillExtrusion:we(` in vec4 v_color ; void main () { fragColor = v_color ;
# ifdef OVERDRAW_INSPECTOR
fragColor = vec4 ( 1.0 );
# endif
} `,` uniform vec3 u_lightcolor ; uniform lowp vec3 u_lightpos ; uniform lowp vec3 u_lightpos_globe ; uniform lowp float u_lightintensity ; uniform float u_vertical_gradient ; uniform lowp float u_opacity ; uniform vec2 u_fill_translate ; layout ( location = 0 ) in vec2 a_pos ; layout ( location = 1 ) in ivec4 a_normal_ed ;
# ifdef TERRAIN3D
layout ( location = 2 ) in vec2 a_centroid ;
# endif
out vec4 v_color ;
# pragma maplibre : define highp float base
# pragma maplibre : define highp float height
# pragma maplibre : define highp vec4 color
void main () {
# pragma maplibre : initialize highp float base
# pragma maplibre : initialize highp float height
# pragma maplibre : initialize highp vec4 color
vec3 normal = vec3 ( a_normal_ed . xyz ); float gradient_base = max ( 0.0 , base ); float gradient_height = max ( 0.0 , height );
# ifdef TERRAIN3D
float height_terrain3d_offset = get_elevation ( a_centroid ); float base_terrain3d_offset = height_terrain3d_offset - ( base > 0.0 ? 0.0 : 10.0 );
# else
float height_terrain3d_offset = 0.0 ; float base_terrain3d_offset = 0.0 ;
# endif
base = max ( 0.0 , base ) + base_terrain3d_offset ; height = max ( 0.0 , height ) + height_terrain3d_offset ; float t = float ( a_normal_ed . x & 1 ); float elevation = t > 0.0 ? height : base ; vec2 posInTile = a_pos + u_fill_translate ;
# ifdef GLOBE
vec3 spherePos = projectToSphere ( posInTile , a_pos ); gl_Position = interpolateProjectionFor3D ( posInTile , spherePos , elevation );
# else
gl_Position = u_projection_matrix * vec4 ( posInTile , elevation , 1.0 );
# endif
float colorvalue = color . r * 0.2126 + color . g * 0.7152 + color . b * 0.0722 ; v_color = vec4 ( 0.0 , 0.0 , 0.0 , 1.0 ); vec4 ambientlight = vec4 ( 0.03 , 0.03 , 0.03 , 1.0 ); color += ambientlight ; vec3 normalForLighting = normal / 16384.0 ; float directional = clamp ( dot ( normalForLighting , u_lightpos ), 0.0 , 1.0 );
# ifdef GLOBE
mat3 rotMatrix = globeGetRotationMatrix ( spherePos ); normalForLighting = rotMatrix * normalForLighting ; directional = mix ( directional , clamp ( dot ( normalForLighting , u_lightpos_globe ), 0.0 , 1.0 ), u_projection_transition );
# endif
directional = mix (( 1.0 - u_lightintensity ), max (( 1.0 - colorvalue + u_lightintensity ), 1.0 ), directional ); if ( normal . z == 0.0 ) { directional *= (( 1.0 - u_vertical_gradient ) + ( u_vertical_gradient * clamp (( t + gradient_base ) * pow ( gradient_height / 150.0 , 0.5 ), mix ( 0.7 , 0.98 , 1.0 - u_lightintensity ), 1.0 )));} v_color . r += clamp ( color . r * directional * u_lightcolor . r , mix ( 0.0 , 0.3 , 1.0 - u_lightcolor . r ), 1.0 ); v_color . g += clamp ( color . g * directional * u_lightcolor . g , mix ( 0.0 , 0.3 , 1.0 - u_lightcolor . g ), 1.0 ); v_color . b += clamp ( color . b * directional * u_lightcolor . b , mix ( 0.0 , 0.3 , 1.0 - u_lightcolor . b ), 1.0 ); v_color *= u_opacity ;} `),fillExtrusionPattern:we(` uniform vec2 u_texsize ; uniform float u_fade ; uniform sampler2D u_image ; in vec2 v_pos_a ; in vec2 v_pos_b ; in vec4 v_lighting ;
# pragma maplibre : define lowp float base
# pragma maplibre : define lowp float height
# pragma maplibre : define lowp vec4 pattern_from
# pragma maplibre : define lowp vec4 pattern_to
# pragma maplibre : define lowp float pixel_ratio_from
# pragma maplibre : define lowp float pixel_ratio_to
void main () {
# pragma maplibre : initialize lowp float base
# pragma maplibre : initialize lowp float height
# pragma maplibre : initialize mediump vec4 pattern_from
# pragma maplibre : initialize mediump vec4 pattern_to
# pragma maplibre : initialize lowp float pixel_ratio_from
# pragma maplibre : initialize lowp float pixel_ratio_to
vec2 pattern_tl_a = pattern_from . xy ; vec2 pattern_br_a = pattern_from . zw ; vec2 pattern_tl_b = pattern_to . xy ; vec2 pattern_br_b = pattern_to . zw ; vec2 imagecoord = mod ( v_pos_a , 1.0 ); vec2 pos = mix ( pattern_tl_a / u_texsize , pattern_br_a / u_texsize , imagecoord ); vec4 color1 = texture ( u_image , pos ); vec2 imagecoord_b = mod ( v_pos_b , 1.0 ); vec2 pos2 = mix ( pattern_tl_b / u_texsize , pattern_br_b / u_texsize , imagecoord_b ); vec4 color2 = texture ( u_image , pos2 ); vec4 mixedColor = mix ( color1 , color2 , u_fade ); fragColor = mixedColor * v_lighting ;
# ifdef OVERDRAW_INSPECTOR
fragColor = vec4 ( 1.0 );
# endif
} `,` uniform vec2 u_pixel_coord_upper ; uniform vec2 u_pixel_coord_lower ; uniform float u_height_factor ; uniform vec3 u_scale ; uniform float u_vertical_gradient ; uniform lowp float u_opacity ; uniform vec2 u_fill_translate ; uniform vec3 u_lightcolor ; uniform lowp vec3 u_lightpos ; uniform lowp vec3 u_lightpos_globe ; uniform lowp float u_lightintensity ; layout ( location = 0 ) in vec2 a_pos ; layout ( location = 1 ) in ivec4 a_normal_ed ;
# ifdef TERRAIN3D
layout ( location = 2 ) in vec2 a_centroid ;
# endif
# ifdef GLOBE
out vec3 v_sphere_pos ;
# endif
out vec2 v_pos_a ; out vec2 v_pos_b ; out vec4 v_lighting ;
# pragma maplibre : define lowp float base
# pragma maplibre : define lowp float height
# pragma maplibre : define lowp vec4 pattern_from
# pragma maplibre : define lowp vec4 pattern_to
# pragma maplibre : define lowp float pixel_ratio_from
# pragma maplibre : define lowp float pixel_ratio_to
void main () {
# pragma maplibre : initialize lowp float base
# pragma maplibre : initialize lowp float height
# pragma maplibre : initialize mediump vec4 pattern_from
# pragma maplibre : initialize mediump vec4 pattern_to
# pragma maplibre : initialize lowp float pixel_ratio_from
# pragma maplibre : initialize lowp float pixel_ratio_to
vec2 pattern_tl_a = pattern_from . xy ; vec2 pattern_br_a = pattern_from . zw ; vec2 pattern_tl_b = pattern_to . xy ; vec2 pattern_br_b = pattern_to . zw ; float tileRatio = u_scale . x ; float fromScale = u_scale . y ; float toScale = u_scale . z ; vec3 normal = vec3 ( a_normal_ed . xyz ); float edgedistance = float ( a_normal_ed . w ); vec2 display_size_a = ( pattern_br_a - pattern_tl_a ) / pixel_ratio_from ; vec2 display_size_b = ( pattern_br_b - pattern_tl_b ) / pixel_ratio_to ; float gradient_base = max ( 0.0 , base ); float gradient_height = max ( 0.0 , height );
# ifdef TERRAIN3D
float height_terrain3d_offset = get_elevation ( a_centroid ); float base_terrain3d_offset = height_terrain3d_offset - ( base > 0.0 ? 0.0 : 10.0 );
# else
float height_terrain3d_offset = 0.0 ; float base_terrain3d_offset = 0.0 ;
# endif
base = max ( 0.0 , base ) + base_terrain3d_offset ; height = max ( 0.0 , height ) + height_terrain3d_offset ; float t = float ( a_normal_ed . x & 1 ); float elevation = t > 0.0 ? height : base ; vec2 posInTile = a_pos + u_fill_translate ;
# ifdef GLOBE
vec3 spherePos = projectToSphere ( posInTile , a_pos ); vec3 elevatedPos = spherePos * ( 1.0 + elevation / GLOBE_RADIUS ); v_sphere_pos = elevatedPos ; gl_Position = interpolateProjectionFor3D ( posInTile , spherePos , elevation );
# else
gl_Position = u_projection_matrix * vec4 ( posInTile , elevation , 1.0 );
# endif
vec2 pos = a_normal_ed . x == 1 && a_normal_ed . y == 0 && a_normal_ed . z == 16384
? a_pos
: vec2 ( edgedistance , elevation * u_height_factor ); v_pos_a = get_pattern_pos ( u_pixel_coord_upper , u_pixel_coord_lower , fromScale * display_size_a , tileRatio , pos ); v_pos_b = get_pattern_pos ( u_pixel_coord_upper , u_pixel_coord_lower , toScale * display_size_b , tileRatio , pos ); v_lighting = vec4 ( 0.0 , 0.0 , 0.0 , 1.0 ); float directional = clamp ( dot ( normal / 16383.0 , u_lightpos ), 0.0 , 1.0 ); directional = mix (( 1.0 - u_lightintensity ), max (( 0.5 + u_lightintensity ), 1.0 ), directional ); if ( normal . z == 0.0 ) { directional *= (( 1.0 - u_vertical_gradient ) + ( u_vertical_gradient * clamp (( t + gradient_base ) * pow ( gradient_height / 150.0 , 0.5 ), mix ( 0.7 , 0.98 , 1.0 - u_lightintensity ), 1.0 )));} v_lighting . rgb += clamp ( directional * u_lightcolor , mix ( vec3 ( 0.0 ), vec3 ( 0.3 ), 1.0 - u_lightcolor ), vec3 ( 1.0 )); v_lighting *= u_opacity ;} `),hillshadePrepare:we(` # ifdef GL_ES
precision highp float ;
# endif
uniform sampler2D u_image ; in vec2 v_pos ; uniform vec2 u_dimension ; uniform float u_zoom ; uniform vec4 u_unpack ; uniform float u_log2_world_width ; float getElevation ( ivec2 texel ) { vec4 data = texelFetch ( u_image , texel , 0 ) * 255.0 ; data . a =- 1.0 ; return dot ( data , u_unpack );} void main () { ivec2 pos = ivec2 ( gl_FragCoord . xy ) + ivec2 ( 1 ); float tileSize = u_dimension . x - 4.0 ; float a = getElevation ( pos + ivec2 ( - 1 , - 1 )); float b = getElevation ( pos + ivec2 ( 0 , - 1 )); float c = getElevation ( pos + ivec2 ( 1 , - 1 )); float d = getElevation ( pos + ivec2 ( - 1 , 0 )); float e = getElevation ( pos ); float f = getElevation ( pos + ivec2 ( 1 , 0 )); float g = getElevation ( pos + ivec2 ( - 1 , 1 )); float h = getElevation ( pos + ivec2 ( 0 , 1 )); float i = getElevation ( pos + ivec2 ( 1 , 1 )); float exaggerationFactor = u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3 ; float exaggeration = u_zoom < 15.0 ? ( u_zoom - 15.0 ) * exaggerationFactor : 0.0 ; vec2 deriv = vec2 (( c + f + f + i ) - ( a + d + d + g ),( g + h + h + i ) - ( a + b + b + c )) * tileSize / pow ( 2.0 , exaggeration + ( 3.0 + u_log2_world_width - u_zoom )); fragColor = clamp ( vec4 ( deriv . x / 8.0 + 128.0 / 255.0 , deriv . y / 8.0 + 128.0 / 255.0 , 1.0 , 1.0 ), 0.0 , 1.0 );
# ifdef OVERDRAW_INSPECTOR
fragColor = vec4 ( 1.0 );
# endif
} `,"uniform mat4 u_matrix;uniform vec2 u_dimension;layout(location=0) in vec2 a_pos;layout(location=1) in vec2 a_texture_pos;out vec2 v_pos;void main() {gl_Position=u_matrix*vec4(a_pos,0,1);highp vec2 epsilon=1.0/u_dimension;float scale=(u_dimension.x-2.0)/u_dimension.x;v_pos=(a_texture_pos/8192.0)*scale+epsilon;}"),hillshade:we(` uniform sampler2D u_image ; in highp vec2 v_pos ; uniform vec2 u_latrange ; uniform float u_exaggeration ; uniform vec4 u_accent ; uniform int u_method ; uniform float u_altitudes [ NUM_ILLUMINATION_SOURCES ]; uniform float u_azimuths [ NUM_ILLUMINATION_SOURCES ]; uniform vec4 u_shadows [ NUM_ILLUMINATION_SOURCES ]; uniform vec4 u_highlights [ NUM_ILLUMINATION_SOURCES ];
# define PI 3.141592653589793
# define STANDARD 0
# define COMBINED 1
# define IGOR 2
# define MULTIDIRECTIONAL 3
# define BASIC 4
float get_aspect ( vec2 deriv ){ return deriv . x != 0.0 ? atan ( deriv . y , - deriv . x ) : PI / 2.0 * ( deriv . y > 0.0 ? 1.0 :- 1.0 );} void igor_hillshade ( vec2 deriv ){ deriv = deriv * u_exaggeration * 2.0 ; float aspect = get_aspect ( deriv ); float azimuth = u_azimuths [ 0 ] + PI ; float slope_stength = atan ( length ( deriv )) * 2.0 / PI ; float aspect_strength = 1.0 - abs ( mod (( aspect + azimuth ) / PI + 0.5 , 2.0 ) - 1.0 ); float shadow_strength = slope_stength * aspect_strength ; float highlight_strength = slope_stength * ( 1.0 - aspect_strength ); fragColor = u_shadows [ 0 ] * shadow_strength + u_highlights [ 0 ] * highlight_strength ;} void standard_hillshade ( vec2 deriv ){ float azimuth = u_azimuths [ 0 ] + PI ; float slope = atan ( 0.625 * length ( deriv )); float aspect = get_aspect ( deriv ); float intensity = u_exaggeration ; float base = 1.875 - intensity * 1.75 ; float maxValue = 0.5 * PI ; float scaledSlope = intensity != 0.5 ? (( pow ( base , slope ) - 1.0 ) / ( pow ( base , maxValue ) - 1.0 )) * maxValue : slope ; float accent = cos ( scaledSlope ); vec4 accent_color = ( 1.0 - accent ) * u_accent * clamp ( intensity * 2.0 , 0.0 , 1.0 ); float shade = abs ( mod (( aspect + azimuth ) / PI + 0.5 , 2.0 ) - 1.0 ); vec4 shade_color = mix ( u_shadows [ 0 ], u_highlights [ 0 ], shade ) * sin ( scaledSlope ) * clamp ( intensity * 2.0 , 0.0 , 1.0 ); fragColor = accent_color * ( 1.0 - shade_color . a ) + shade_color ;} void basic_hillshade ( vec2 deriv ){ deriv = deriv * u_exaggeration * 2.0 ; float azimuth = u_azimuths [ 0 ] + PI ; float cos_az = cos ( azimuth ); float sin_az = sin ( azimuth ); float cos_alt = cos ( u_altitudes [ 0 ]); float sin_alt = sin ( u_altitudes [ 0 ]); float cang = ( sin_alt - ( deriv . y * cos_az * cos_alt - deriv . x * sin_az * cos_alt )) / sqrt ( 1.0 + dot ( deriv , deriv )); float shade = clamp ( cang , 0.0 , 1.0 ); if ( shade > 0.5 ){ fragColor = u_highlights [ 0 ] * ( 2.0 * shade - 1.0 );} else
{ fragColor = u_shadows [ 0 ] * ( 1.0 - 2.0 * shade );}} void multidirectional_hillshade ( vec2 deriv ){ deriv = deriv * u_exaggeration * 2.0 ; fragColor = vec4 ( 0 , 0 , 0 , 0 ); for ( int i = 0 ; i < NUM_ILLUMINATION_SOURCES ; i ++ ){ float cos_alt = cos ( u_altitudes [ i ]); float sin_alt = sin ( u_altitudes [ i ]); float cos_az =- cos ( u_azimuths [ i ]); float sin_az =- sin ( u_azimuths [ i ]); float cang = ( sin_alt - ( deriv . y * cos_az * cos_alt - deriv . x * sin_az * cos_alt )) / sqrt ( 1.0 + dot ( deriv , deriv )); float shade = clamp ( cang , 0.0 , 1.0 ); if ( shade > 0.5 ){ fragColor += u_highlights [ i ] * ( 2.0 * shade - 1.0 ) / float ( NUM_ILLUMINATION_SOURCES );} else
{ fragColor += u_shadows [ i ] * ( 1.0 - 2.0 * shade ) / float ( NUM_ILLUMINATION_SOURCES );}}} void combined_hillshade ( vec2 deriv ){ deriv = deriv * u_exaggeration * 2.0 ; float azimuth = u_azimuths [ 0 ] + PI ; float cos_az = cos ( azimuth ); float sin_az = sin ( azimuth ); float cos_alt = cos ( u_altitudes [ 0 ]); float sin_alt = sin ( u_altitudes [ 0 ]); float cang = acos (( sin_alt - ( deriv . y * cos_az * cos_alt - deriv . x * sin_az * cos_alt )) / sqrt ( 1.0 + dot ( deriv , deriv ))); cang = clamp ( cang , 0.0 , PI / 2.0 ); float shade = cang * atan ( length ( deriv )) * 4.0 / PI / PI ; float highlight = ( PI / 2.0 - cang ) * atan ( length ( deriv )) * 4.0 / PI / PI ; fragColor = u_shadows [ 0 ] * shade + u_highlights [ 0 ] * highlight ;} void main () { highp vec2 size = vec2 ( textureSize ( u_image , 0 )); highp vec2 texturePos = ( v_pos * ( size - 2.0 ) + 1.0 ) / size ; vec4 pixel = texture ( u_image , texturePos ); float scaleFactor = cos ( radians (( u_latrange [ 0 ] - u_latrange [ 1 ]) * ( 1.0 - v_pos . y ) + u_latrange [ 1 ])); vec2 deriv = ( pixel . rg - 128.0 / 255.0 ) * 8.0 / scaleFactor ; if ( u_method == BASIC ) { basic_hillshade ( deriv );} else if ( u_method == COMBINED ) { combined_hillshade ( deriv );} else if ( u_method == IGOR ) { igor_hillshade ( deriv );} else if ( u_method == MULTIDIRECTIONAL ) { multidirectional_hillshade ( deriv );} else if ( u_method == STANDARD ) { standard_hillshade ( deriv );} else { standard_hillshade ( deriv );}
# ifdef OVERDRAW_INSPECTOR
fragColor = vec4 ( 1.0 );
# endif
} `,"uniform mat4 u_matrix;layout(location=0) in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=projectTile(a_pos,a_pos);v_pos=a_pos/8192.0;if (a_pos.y <-32767.5) {v_pos.y=0.0;}if (a_pos.y > 32766.5) {v_pos.y=1.0;}}"),line:we(` in vec2 v_width2 ; in vec2 v_normal ; in float v_gamma_scale ;
# ifdef GLOBE
in float v_depth ;
# endif
# pragma maplibre : define highp vec4 color
# pragma maplibre : define lowp float blur
# pragma maplibre : define lowp float opacity
void main () {
# pragma maplibre : initialize highp vec4 color
# pragma maplibre : initialize lowp float blur
# pragma maplibre : initialize lowp float opacity
clipAntimeridian (); float dist = length ( v_normal ) * v_width2 . s ; float blur2 = ( blur + 1.0 / u_device_pixel_ratio ) * v_gamma_scale ; float alpha = clamp ( min ( dist - ( v_width2 . t - blur2 ), v_width2 . s - dist ) / blur2 , 0.0 , 1.0 ); fragColor = color * ( alpha * opacity );
# ifdef GLOBE
if ( v_depth > 1.0 ) { discard ;}
# endif
# ifdef OVERDRAW_INSPECTOR
fragColor = vec4 ( 1.0 );
# endif
} `,`
# define scale 0.015873016
layout ( location = 0 ) in ivec2 a_pos_normal ; layout ( location = 1 ) in uvec4 a_data ; layout ( location = 2 ) in vec2 a_offset_normal ; uniform vec2 u_translation ; uniform mediump float u_ratio ; out vec2 v_normal ; out vec2 v_width2 ; out float v_gamma_scale ; out highp float v_linesofar ;
# ifdef GLOBE
out float v_depth ;
# endif
# pragma maplibre : define highp vec4 color
# pragma maplibre : define lowp float blur
# pragma maplibre : define lowp float opacity
# pragma maplibre : define mediump float gapwidth
# pragma maplibre : define lowp float offset
# pragma maplibre : define mediump float width
void main () {
# pragma maplibre : initialize highp vec4 color
# pragma maplibre : initialize lowp float blur
# pragma maplibre : initialize lowp float opacity
# pragma maplibre : initialize mediump float gapwidth
# pragma maplibre : initialize lowp float offset
# pragma maplibre : initialize mediump float width
if ( opacity < 0.01 ) { gl_Position = vec4 ( - 2.0 , - 2.0 , - 2.0 , 1.0 ); return ;} float ANTIALIASING = 1.0 / u_device_pixel_ratio / 2.0 ; vec2 a_extrude = vec2 ( ivec2 ( a_data . xy ) - 128 ); v_linesofar = float (( a_data . z >> 2 u ) + a_data . w * 64 u ) * 2.0 ; vec2 pos = vec2 ( a_pos_normal >> 1 ); mediump vec2 normal = vec2 ( a_pos_normal & 1 ); normal . y = normal . y * 2.0 - 1.0 ; v_normal = normal ; gapwidth = gapwidth / 2.0 ; float halfwidth = width / 2.0 ; offset =- 1.0 * offset ; float inset = gapwidth + ( gapwidth > 0.0 ? ANTIALIASING : 0.0 ); float outset = gapwidth + halfwidth * ( gapwidth > 0.0 ? 2.0 : 1.0 ) + ( halfwidth == 0.0 ? 0.0 : ANTIALIASING ); mediump vec2 dist = outset * a_extrude * scale ; mediump vec2 offset2 = offset * a_offset_normal * scale * normal . y ; float adjustedThickness = projectLineThickness ( pos . y ); vec4 projected_no_extrude = projectTile ( pos + offset2 / u_ratio * adjustedThickness + u_translation ); vec4 projected_with_extrude = projectTile ( pos + offset2 / u_ratio * adjustedThickness + u_translation + dist / u_ratio * adjustedThickness ); gl_Position = projected_with_extrude ;
# ifdef GLOBE
v_depth = gl_Position . z / gl_Position . w ;
# endif
# ifdef TERRAIN3D
v_gamma_scale = 1.0 ;
# else
float extrude_length_without_perspective = length ( dist ); float extrude_length_with_perspective = length (( projected_with_extrude . xy - projected_no_extrude . xy ) / projected_with_extrude . w * u_units_to_pixels ); v_gamma_scale = extrude_length_without_perspective / extrude_length_with_perspective ;
# endif
v_width2 = vec2 ( outset , inset );} `),lineGradient:we(` uniform sampler2D u_image ; in vec2 v_width2 ; in vec2 v_normal ; in float v_gamma_scale ; in highp vec2 v_uv ;
# ifdef GLOBE
in float v_depth ;
# endif
# pragma maplibre : define lowp float blur
# pragma maplibre : define lowp float opacity
void main () {
# pragma maplibre : initialize lowp float blur
# pragma maplibre : initialize lowp float opacity
clipAntimeridian (); float dist = length ( v_normal ) * v_width2 . s ; float blur2 = ( blur + 1.0 / u_device_pixel_ratio ) * v_gamma_scale ; float alpha = clamp ( min ( dist - ( v_width2 . t - blur2 ), v_width2 . s - dist ) / blur2 , 0.0 , 1.0 ); vec4 color = texture ( u_image , v_uv ); fragColor = color * ( alpha * opacity );
# ifdef GLOBE
if ( v_depth > 1.0 ) { discard ;}
# endif
# ifdef OVERDRAW_INSPECTOR
fragColor = vec4 ( 1.0 );
# endif
} `,`
# define scale 0.015873016
layout ( location = 0 ) in ivec2 a_pos_normal ; layout ( location = 1 ) in uvec4 a_data ; layout ( location = 2 ) in vec2 a_offset_normal ; layout ( location = 3 ) in float a_uv_x ; layout ( location = 4 ) in float a_split_index ; uniform vec2 u_translation ; uniform mediump float u_ratio ; uniform float u_image_height ; out vec2 v_normal ; out vec2 v_width2 ; out float v_gamma_scale ; out highp vec2 v_uv ;
# ifdef GLOBE
out float v_depth ;
# endif
# pragma maplibre : define lowp float blur
# pragma maplibre : define lowp float opacity
# pragma maplibre : define mediump float gapwidth
# pragma maplibre : define lowp float offset
# pragma maplibre : define mediump float width
void main () {
# pragma maplibre : initialize lowp float blur
# pragma maplibre : initialize lowp float opacity
# pragma maplibre : initialize mediump float gapwidth
# pragma maplibre : initialize lowp float offset
# pragma maplibre : initialize mediump float width
if ( opacity < 0.01 ) { gl_Position = vec4 ( - 2.0 , - 2.0 , - 2.0 , 1.0 ); return ;} float ANTIALIASING = 1.0 / u_device_pixel_ratio / 2.0 ; vec2 a_extrude = vec2 ( ivec2 ( a_data . xy ) - 128 ); highp float texel_height = 1.0 / u_image_height ; highp float half_texel_height = 0.5 * texel_height ; v_uv = vec2 ( a_uv_x , a_split_index * texel_height - half_texel_height ); vec2 pos = vec2 ( a_pos_normal >> 1 ); mediump vec2 normal = vec2 ( a_pos_normal & 1 ); normal . y = normal . y * 2.0 - 1.0 ; v_normal = normal ; gapwidth = gapwidth / 2.0 ; float halfwidth = width / 2.0 ; offset =- 1.0 * offset ; float inset = gapwidth + ( gapwidth > 0.0 ? ANTIALIASING : 0.0 ); float outset = gapwidth + halfwidth * ( gapwidth > 0.0 ? 2.0 : 1.0 ) + ( halfwidth == 0.0 ? 0.0 : ANTIALIASING ); mediump vec2 dist = outset * a_extrude * scale ; mediump vec2 offset2 = offset * a_offset_normal * scale * normal . y ; float adjustedThickness = projectLineThickness ( pos . y ); vec4 projected_no_extrude = projectTile ( pos + offset2 / u_ratio * adjustedThickness + u_translation ); vec4 projected_with_extrude = projectTile ( pos + offset2 / u_ratio * adjustedThickness + u_translation + dist / u_ratio * adjustedThickness ); gl_Position = projected_with_extrude ;
# ifdef GLOBE
v_depth = gl_Position . z / gl_Position . w ;
# endif
# ifdef TERRAIN3D
v_gamma_scale = 1.0 ;
# else
float extrude_length_without_perspective = length ( dist ); float extrude_length_with_perspective = length (( projected_with_extrude . xy - projected_no_extrude . xy ) / projected_with_extrude . w * u_units_to_pixels ); v_gamma_scale = extrude_length_without_perspective / extrude_length_with_perspective ;
# endif
v_width2 = vec2 ( outset , inset );} `),linePattern:we(` # ifdef GL_ES
precision highp float ;
# endif
uniform vec2 u_texsize ; uniform float u_fade ; uniform mediump vec3 u_scale ; uniform sampler2D u_image ; in vec2 v_normal ; in vec2 v_width2 ; in float v_linesofar ; in float v_gamma_scale ; in float v_width ;
# ifdef GLOBE
in float v_depth ;
# endif
# pragma maplibre : define lowp vec4 pattern_from
# pragma maplibre : define lowp vec4 pattern_to
# pragma maplibre : define lowp float pixel_ratio_from
# pragma maplibre : define lowp float pixel_ratio_to
# pragma maplibre : define lowp float blur
# pragma maplibre : define lowp float opacity
void main () {
# pragma maplibre : initialize mediump vec4 pattern_from
# pragma maplibre : initialize mediump vec4 pattern_to
# pragma maplibre : initialize lowp float pixel_ratio_from
# pragma maplibre : initialize lowp float pixel_ratio_to
# pragma maplibre : initialize lowp float blur
# pragma maplibre : initialize lowp float opacity
clipAntimeridian (); vec2 pattern_tl_a = pattern_from . xy ; vec2 pattern_br_a = pattern_from . zw ; vec2 pattern_tl_b = pattern_to . xy ; vec2 pattern_br_b = pattern_to . zw ; float tileZoomRatio = u_scale . x ; float fromScale = u_scale . y ; float toScale = u_scale . z ; vec2 display_size_a = ( pattern_br_a - pattern_tl_a ) / pixel_ratio_from ; vec2 display_size_b = ( pattern_br_b - pattern_tl_b ) / pixel_ratio_to ; vec2 pattern_size_a = vec2 ( display_size_a . x * fromScale / tileZoomRatio , display_size_a . y ); vec2 pattern_size_b = vec2 ( display_size_b . x * toScale / tileZoomRatio , display_size_b . y ); float aspect_a = display_size_a . y / v_width ; float aspect_b = display_size_b . y / v_width ; float dist = length ( v_normal ) * v_width2 . s ; float blur2 = ( blur + 1.0 / u_device_pixel_ratio ) * v_gamma_scale ; float alpha = clamp ( min ( dist - ( v_width2 . t - blur2 ), v_width2 . s - dist ) / blur2 , 0.0 , 1.0 ); float x_a = mod ( v_linesofar / pattern_size_a . x * aspect_a , 1.0 ); float x_b = mod ( v_linesofar / pattern_size_b . x * aspect_b , 1.0 ); float y = 0.5 * v_normal . y + 0.5 ; vec2 texel_size = 1.0 / u_texsize ; vec2 pos_a = mix ( pattern_tl_a * texel_size - texel_size , pattern_br_a * texel_size + texel_size , vec2 ( x_a , y )); vec2 pos_b = mix ( pattern_tl_b * texel_size - texel_size , pattern_br_b * texel_size + texel_size , vec2 ( x_b , y )); vec4 color = mix ( texture ( u_image , pos_a ), texture ( u_image , pos_b ), u_fade ); fragColor = color * alpha * opacity ;
# ifdef GLOBE
if ( v_depth > 1.0 ) { discard ;}
# endif
# ifdef OVERDRAW_INSPECTOR
fragColor = vec4 ( 1.0 );
# endif
} `,`
# define scale 0.015873016
# define LINE_DISTANCE_SCALE 2.0
layout ( location = 0 ) in ivec2 a_pos_normal ; layout ( location = 1 ) in uvec4 a_data ; layout ( location = 2 ) in vec2 a_offset_normal ; uniform vec2 u_translation ; uniform mediump float u_ratio ; out vec2 v_normal ; out vec2 v_width2 ; out float v_linesofar ; out float v_gamma_scale ; out float v_width ;
# ifdef GLOBE
out float v_depth ;
# endif
# pragma maplibre : define lowp float blur
# pragma maplibre : define lowp float opacity
# pragma maplibre : define lowp float offset
# pragma maplibre : define mediump float gapwidth
# pragma maplibre : define mediump float width
# pragma maplibre : define lowp float floorwidth
# pragma maplibre : define lowp vec4 pattern_from
# pragma maplibre : define lowp vec4 pattern_to
# pragma maplibre : define lowp float pixel_ratio_from
# pragma maplibre : define lowp float pixel_ratio_to
void main () {
# pragma maplibre : initialize lowp float blur
# pragma maplibre : initialize lowp float opacity
# pragma maplibre : initialize lowp float offset
# pragma maplibre : initialize mediump float gapwidth
# pragma maplibre : initialize mediump float width
# pragma maplibre : initialize lowp float floorwidth
# pragma maplibre : initialize mediump vec4 pattern_from
# pragma maplibre : initialize mediump vec4 pattern_to
# pragma maplibre : initialize lowp float pixel_ratio_from
# pragma maplibre : initialize lowp float pixel_ratio_to
if ( opacity < 0.01 ) { gl_Position = vec4 ( - 2.0 , - 2.0 , - 2.0 , 1.0 ); return ;} float ANTIALIASING = 1.0 / u_device_pixel_ratio / 2.0 ; vec2 a_extrude = vec2 ( ivec2 ( a_data . xy ) - 128 ); float a_linesofar = float (( a_data . z >> 2 u ) + a_data . w * 64 u ) * LINE_DISTANCE_SCALE ; vec2 pos = vec2 ( a_pos_normal >> 1 ); mediump vec2 normal = vec2 ( a_pos_normal & 1 ); normal . y = normal . y * 2.0 - 1.0 ; v_normal = normal ; gapwidth = gapwidth / 2.0 ; float halfwidth = width / 2.0 ; offset =- 1.0 * offset ; float inset = gapwidth + ( gapwidth > 0.0 ? ANTIALIASING : 0.0 ); float outset = gapwidth + halfwidth * ( gapwidth > 0.0 ? 2.0 : 1.0 ) + ( halfwidth == 0.0 ? 0.0 : ANTIALIASING ); mediump vec2 dist = outset * a_extrude * scale ; mediump vec2 offset2 = offset * a_offset_normal * scale * normal . y ; float adjustedThickness = projectLineThickness ( pos . y ); vec4 projected_no_extrude = projectTile ( pos + offset2 / u_ratio * adjustedThickness + u_translation ); vec4 projected_with_extrude = projectTile ( pos + offset2 / u_ratio * adjustedThickness + u_translation + dist / u_ratio * adjustedThickness ); gl_Position = projected_with_extrude ;
# ifdef GLOBE
v_depth = gl_Position . z / gl_Position . w ;
# endif
# ifdef TERRAIN3D
v_gamma_scale = 1.0 ;
# else
float extrude_length_without_perspective = length ( dist ); float extrude_length_with_perspective = length (( projected_with_extrude . xy - projected_no_extrude . xy ) / projected_with_extrude . w * u_units_to_pixels ); v_gamma_scale = extrude_length_without_perspective / extrude_length_with_perspective ;
# endif
v_linesofar = a_linesofar ; v_width2 = vec2 ( outset , inset ); v_width = floorwidth ;} `),lineSDF:we(` uniform lowp float u_lineatlas_width ; uniform sampler2D u_image ; uniform float u_mix ; in vec2 v_normal ; in vec2 v_width2 ; in vec2 v_tex_a ; in vec2 v_tex_b ; in float v_gamma_scale ;
# ifdef GLOBE
in float v_depth ;
# endif
# pragma maplibre : define highp vec4 color
# pragma maplibre : define lowp float blur
# pragma maplibre : define lowp float opacity
# pragma maplibre : define mediump float width
# pragma maplibre : define lowp float floorwidth
# pragma maplibre : define mediump vec4 dasharray_from
# pragma maplibre : define mediump vec4 dasharray_to
void main () {
# pragma maplibre : initialize highp vec4 color
# pragma maplibre : initialize lowp float blur
# pragma maplibre : initialize lowp float opacity
# pragma maplibre : initialize mediump float width
# pragma maplibre : initialize lowp float floorwidth
# pragma maplibre : initialize mediump vec4 dasharray_from
# pragma maplibre : initialize mediump vec4 dasharray_to
clipAntimeridian (); float dist = length ( v_normal ) * v_width2 . s ; float blur2 = ( blur + 1.0 / u_device_pixel_ratio ) * v_gamma_scale ; float alpha = clamp ( min ( dist - ( v_width2 . t - blur2 ), v_width2 . s - dist ) / blur2 , 0.0 , 1.0 ); float sdfdist_a = texture ( u_image , v_tex_a ). a ; float sdfdist_b = texture ( u_image , v_tex_b ). a ; float sdfdist = mix ( sdfdist_a , sdfdist_b , u_mix ); float sdfgamma = ( u_lineatlas_width / 256.0 / u_device_pixel_ratio ) / min ( dasharray_from . w , dasharray_to . w ); alpha *= smoothstep ( 0.5 - sdfgamma / floorwidth , 0.5 + sdfgamma / floorwidth , sdfdist ); fragColor = color * ( alpha * opacity );
# ifdef GLOBE
if ( v_depth > 1.0 ) { discard ;}
# endif
# ifdef OVERDRAW_INSPECTOR
fragColor = vec4 ( 1.0 );
# endif
} `,`
# define scale 0.015873016
# define LINE_DISTANCE_SCALE 2.0
layout ( location = 0 ) in ivec2 a_pos_normal ; layout ( location = 1 ) in uvec4 a_data ; layout ( location = 2 ) in vec2 a_offset_normal ; uniform vec2 u_translation ; uniform mediump float u_ratio ; uniform float u_tileratio ; uniform float u_crossfade_from ; uniform float u_crossfade_to ; uniform float u_lineatlas_height ; out vec2 v_normal ; out vec2 v_width2 ; out vec2 v_tex_a ; out vec2 v_tex_b ; out float v_gamma_scale ;
# ifdef GLOBE
out float v_depth ;
# endif
# pragma maplibre : define highp vec4 color
# pragma maplibre : define lowp float blur
# pragma maplibre : define lowp float opacity
# pragma maplibre : define mediump float gapwidth
# pragma maplibre : define lowp float offset
# pragma maplibre : define mediump float width
# pragma maplibre : define lowp float floorwidth
# pragma maplibre : define mediump vec4 dasharray_from
# pragma maplibre : define mediump vec4 dasharray_to
void main () {
# pragma maplibre : initialize highp vec4 color
# pragma maplibre : initialize lowp float blur
# pragma maplibre : initialize lowp float opacity
# pragma maplibre : initialize mediump float gapwidth
# pragma maplibre : initialize lowp float offset
# pragma maplibre : initialize mediump float width
# pragma maplibre : initialize lowp float floorwidth
# pragma maplibre : initialize mediump vec4 dasharray_from
# pragma maplibre : initialize mediump vec4 dasharray_to
if ( opacity < 0.01 ) { gl_Position = vec4 ( - 2.0 , - 2.0 , - 2.0 , 1.0 ); return ;} float ANTIALIASING = 1.0 / u_device_pixel_ratio / 2.0 ; vec2 a_extrude = vec2 ( ivec2 ( a_data . xy ) - 128 ); float a_linesofar = float (( a_data . z >> 2 u ) + a_data . w * 64 u ) * LINE_DISTANCE_SCALE ; vec2 pos = vec2 ( a_pos_normal >> 1 ); mediump vec2 normal = vec2 ( a_pos_normal & 1 ); normal . y = normal . y * 2.0 - 1.0 ; v_normal = normal ; gapwidth = gapwidth / 2.0 ; float halfwidth = width / 2.0 ; offset =- 1.0 * offset ; float inset = gapwidth + ( gapwidth > 0.0 ? ANTIALIASING : 0.0 ); float outset = gapwidth + halfwidth * ( gapwidth > 0.0 ? 2.0 : 1.0 ) + ( halfwidth == 0.0 ? 0.0 : ANTIALIASING ); mediump vec2 dist = outset * a_extrude * scale ; mediump vec2 offset2 = offset * a_offset_normal * scale * normal . y ; float adjustedThickness = projectLineThickness ( pos . y ); vec4 projected_no_extrude = projectTile ( pos + offset2 / u_ratio * adjustedThickness + u_translation ); vec4 projected_with_extrude = projectTile ( pos + offset2 / u_ratio * adjustedThickness + u_translation + dist / u_ratio * adjustedThickness ); gl_Position = projected_with_extrude ;
# ifdef GLOBE
v_depth = gl_Position . z / gl_Position . w ;
# endif
# ifdef TERRAIN3D
v_gamma_scale = 1.0 ;
# else
float extrude_length_without_perspective = length ( dist ); float extrude_length_with_perspective = length (( projected_with_extrude . xy - projected_no_extrude . xy ) / projected_with_extrude . w * u_units_to_pixels ); v_gamma_scale = extrude_length_without_perspective / extrude_length_with_perspective ;
# endif
float u_patternscale_a_x = u_tileratio / dasharray_from . w / u_crossfade_from ; float u_patternscale_a_y =- dasharray_from . z / 2.0 / u_lineatlas_height ; float u_patternscale_b_x = u_tileratio / dasharray_to . w / u_crossfade_to ; float u_patternscale_b_y =- dasharray_to . z / 2.0 / u_lineatlas_height ; v_tex_a = vec2 ( a_linesofar * u_patternscale_a_x / floorwidth , normal . y * u_patternscale_a_y + ( float ( dasharray_from . y ) + 0.5 ) / u_lineatlas_height ); v_tex_b = vec2 ( a_linesofar * u_patternscale_b_x / floorwidth , normal . y * u_patternscale_b_y + ( float ( dasharray_to . y ) + 0.5 ) / u_lineatlas_height ); v_width2 = vec2 ( outset , inset );} `),lineGradientSDF:we(` uniform sampler2D u_image ; uniform sampler2D u_image_dash ; uniform float u_mix ; uniform lowp float u_lineatlas_width ; in vec2 v_normal ; in vec2 v_width2 ; in vec2 v_tex_a ; in vec2 v_tex_b ; in float v_gamma_scale ; in highp vec2 v_uv ;
# ifdef GLOBE
in float v_depth ;
# endif
# pragma maplibre : define lowp float blur
# pragma maplibre : define lowp float opacity
# pragma maplibre : define mediump float width
# pragma maplibre : define lowp float floorwidth
# pragma maplibre : define mediump vec4 dasharray_from
# pragma maplibre : define mediump vec4 dasharray_to
void main () {
# pragma maplibre : initialize lowp float blur
# pragma maplibre : initialize lowp float opacity
# pragma maplibre : initialize mediump float width
# pragma maplibre : initialize lowp float floorwidth
# pragma maplibre : initialize mediump vec4 dasharray_from
# pragma maplibre : initialize mediump vec4 dasharray_to
clipAntimeridian (); float dist = length ( v_normal ) * v_width2 . s ; float blur2 = ( blur + 1.0 / u_device_pixel_ratio ) * v_gamma_scale ; float alpha = clamp ( min ( dist - ( v_width2 . t - blur2 ), v_width2 . s - dist ) / blur2 , 0.0 , 1.0 ); vec4 color = texture ( u_image , v_uv ); float sdfdist_a = texture ( u_image_dash , v_tex_a ). a ; float sdfdist_b = texture ( u_image_dash , v_tex_b ). a ; float sdfdist = mix ( sdfdist_a , sdfdist_b , u_mix ); float sdfgamma = ( u_lineatlas_width / 256.0 ) / min ( dasharray_from . w , dasharray_to . w ); float dash_alpha = smoothstep ( 0.5 - sdfgamma / floorwidth , 0.5 + sdfgamma / floorwidth , sdfdist ); fragColor = color * ( alpha * dash_alpha * opacity );
# ifdef GLOBE
if ( v_depth > 1.0 ) { discard ;}
# endif
# ifdef OVERDRAW_INSPECTOR
fragColor = vec4 ( 1.0 );
# endif
} `,`
# define scale 0.015873016
# define LINE_DISTANCE_SCALE 2.0
layout ( location = 0 ) in ivec2 a_pos_normal ; layout ( location = 1 ) in uvec4 a_data ; layout ( location = 2 ) in vec2 a_offset_normal ; layout ( location = 3 ) in float a_uv_x ; layout ( location = 4 ) in float a_split_index ; uniform vec2 u_translation ; uniform mediump float u_ratio ; uniform float u_image_height ; uniform float u_tileratio ; uniform float u_crossfade_from ; uniform float u_crossfade_to ; uniform float u_lineatlas_height ; out vec2 v_normal ; out vec2 v_width2 ; out float v_gamma_scale ; out highp vec2 v_uv ; out vec2 v_tex_a ; out vec2 v_tex_b ;
# ifdef GLOBE
out float v_depth ;
# endif
# pragma maplibre : define lowp float blur
# pragma maplibre : define lowp float opacity
# pragma maplibre : define mediump float gapwidth
# pragma maplibre : define lowp float offset
# pragma maplibre : define mediump float width
# pragma maplibre : define lowp float floorwidth
# pragma maplibre : define mediump vec4 dasharray_from
# pragma maplibre : define mediump vec4 dasharray_to
void main () {
# pragma maplibre : initialize lowp float blur
# pragma maplibre : initialize lowp float opacity
# pragma maplibre : initialize mediump float gapwidth
# pragma maplibre : initialize lowp float offset
# pragma maplibre : initialize mediump float width
# pragma maplibre : initialize lowp float floorwidth
# pragma maplibre : initialize mediump vec4 dasharray_from
# pragma maplibre : initialize mediump vec4 dasharray_to
if ( opacity < 0.01 ) { gl_Position = vec4 ( - 2.0 , - 2.0 , - 2.0 , 1.0 ); return ;} float ANTIALIASING = 1.0 / u_device_pixel_ratio / 2.0 ; vec2 a_extrude = vec2 ( ivec2 ( a_data . xy ) - 128 ); float a_linesofar = float (( a_data . z >> 2 u ) + a_data . w * 64 u ) * LINE_DISTANCE_SCALE ; float texel_height = 1.0 / u_image_height ; float half_texel_height = 0.5 * texel_height ; v_uv = vec2 ( a_uv_x , a_split_index * texel_height - half_texel_height ); vec2 pos = vec2 ( a_pos_normal >> 1 ); mediump vec2 normal = vec2 ( a_pos_normal & 1 ); normal . y = normal . y * 2.0 - 1.0 ; v_normal = normal ; gapwidth = gapwidth / 2.0 ; float halfwidth = width / 2.0 ; offset =- 1.0 * offset ; float inset = gapwidth + ( gapwidth > 0.0 ? ANTIALIASING : 0.0 ); float outset = gapwidth + halfwidth * ( gapwidth > 0.0 ? 2.0 : 1.0 ) + ( halfwidth == 0.0 ? 0.0 : ANTIALIASING ); mediump vec2 dist = outset * a_extrude * scale ; mediump vec2 offset2 = offset * a_offset_normal * scale * normal . y ; float adjustedThickness = projectLineThickness ( pos . y ); vec4 projected_no_extrude = projectTile ( pos + offset2 / u_ratio * adjustedThickness + u_translation ); vec4 projected_with_extrude = projectTile ( pos + offset2 / u_ratio * adjustedThickness + u_translation + dist / u_ratio * adjustedThickness ); gl_Position = projected_with_extrude ;
# ifdef GLOBE
v_depth = gl_Position . z / gl_Position . w ;
# endif
# ifdef TERRAIN3D
v_gamma_scale = 1.0 ;
# else
float extrude_length_without_perspective = length ( dist ); float extrude_length_with_perspective = length (( projected_with_extrude . xy - projected_no_extrude . xy ) / projected_with_extrude . w * u_units_to_pixels ); v_gamma_scale = extrude_length_without_perspective / extrude_length_with_perspective ;
# endif
float u_patternscale_a_x = u_tileratio / dasharray_from . w / u_crossfade_from ; float u_patternscale_a_y =- dasharray_from . z / 2.0 / u_lineatlas_height ; float u_patternscale_b_x = u_tileratio / dasharray_to . w / u_crossfade_to ; float u_patternscale_b_y =- dasharray_to . z / 2.0 / u_lineatlas_height ; v_tex_a = vec2 ( a_linesofar * u_patternscale_a_x / floorwidth , normal . y * u_patternscale_a_y + ( float ( dasharray_from . y ) + 0.5 ) / u_lineatlas_height ); v_tex_b = vec2 ( a_linesofar * u_patternscale_b_x / floorwidth , normal . y * u_patternscale_b_y + ( float ( dasharray_to . y ) + 0.5 ) / u_lineatlas_height ); v_width2 = vec2 ( outset , inset );} `),layerOpacity:we(` uniform sampler2D u_image ; uniform float u_opacity ; in vec2 v_pos ; void main () { fragColor = texture ( u_image , v_pos ) * u_opacity ;
# ifdef OVERDRAW_INSPECTOR
fragColor = vec4 ( 0.0 );
# endif
} `,"layout(location=0) in vec2 a_pos;out vec2 v_pos;void main() {gl_Position=vec4(a_pos.x*2.0-1.0,1.0-a_pos.y*2.0,0.0,1.0);v_pos.x=a_pos.x;v_pos.y=1.0-a_pos.y;}"),raster:we(` uniform float u_fade_t ; uniform float u_opacity ; uniform sampler2D u_image0 ; uniform sampler2D u_image1 ; in vec3 v_pos0 ; in vec3 v_pos1 ; uniform float u_brightness_low ; uniform float u_brightness_high ; uniform float u_saturation_factor ; uniform float u_contrast_factor ; uniform vec3 u_spin_weights ; void main () { vec4 color0 = texture ( u_image0 , v_pos0 . xy / v_pos0 . z ); vec4 color1 = texture ( u_image1 , v_pos1 . xy / v_pos1 . z ); if ( color0 . a > 0.0 ) { color0 . rgb = color0 . rgb / color0 . a ;} if ( color1 . a > 0.0 ) { color1 . rgb = color1 . rgb / color1 . a ;} vec4 color = mix ( color0 , color1 , u_fade_t ); color . a *= u_opacity ; vec3 rgb = color . rgb ; rgb = vec3 ( dot ( rgb , u_spin_weights . xyz ), dot ( rgb , u_spin_weights . zxy ), dot ( rgb , u_spin_weights . yzx )); float average = ( color . r + color . g + color . b ) / 3.0 ; rgb += ( average - rgb ) * u_saturation_factor ; rgb = ( rgb - 0.5 ) * u_contrast_factor + 0.5 ; vec3 u_high_vec = vec3 ( u_brightness_low , u_brightness_low , u_brightness_low ); vec3 u_low_vec = vec3 ( u_brightness_high , u_brightness_high , u_brightness_high ); fragColor = vec4 ( mix ( u_high_vec , u_low_vec , rgb ) * color . a , color . a );
# ifdef OVERDRAW_INSPECTOR
fragColor = vec4 ( 1.0 );
# endif
} `,` uniform vec2 u_tl_parent ; uniform float u_scale_parent ; uniform float u_buffer_scale ; uniform vec3 u_image_warp ; uniform vec4 u_coords_top ; uniform vec4 u_coords_bottom ; layout ( location = 0 ) in vec2 a_pos ; out vec3 v_pos0 ; out vec3 v_pos1 ; void main () { vec2 fractionalPos = a_pos / 8192.0 ; vec2 topLeft = u_coords_top . xy ; vec2 topRight = u_coords_top . zw ; vec2 bottomLeft = u_coords_bottom . xy ; vec2 bottomRight = u_coords_bottom . zw ; vec2 bilinearPos = mix ( mix ( topLeft , topRight , fractionalPos . x ), mix ( bottomLeft , bottomRight , fractionalPos . x ), fractionalPos . y ); float denominator = dot ( u_image_warp . xy , fractionalPos ) + 1.0 ; vec2 acrossTop = topRight - topLeft + u_image_warp . x * topRight ; vec2 downLeft = bottomLeft - topLeft + u_image_warp . y * bottomLeft ; vec2 projectivePos = ( acrossTop * fractionalPos . x + downLeft * fractionalPos . y + topLeft ) / denominator ; vec2 position = mix ( projectivePos , bilinearPos , u_image_warp . z ); gl_Position = projectTile ( position , position ); vec2 texturePos = (( fractionalPos - 0.5 ) / u_buffer_scale ) + 0.5 ;
# ifdef GLOBE
if ( a_pos . y <- 32767.5 ) { texturePos . y = 0.0 ;} if ( a_pos . y > 32766.5 ) { texturePos . y = 1.0 ;}
# endif
float perspectiveRatio = mix ( 1.0 / denominator , 1.0 , u_image_warp . z ); v_pos0 = vec3 ( texturePos * perspectiveRatio , perspectiveRatio ); vec2 parentPos = ( texturePos * u_scale_parent ) + u_tl_parent ; v_pos1 = vec3 ( parentPos * perspectiveRatio , perspectiveRatio );} `),symbolIcon:we(` uniform sampler2D u_texture ; in vec2 v_tex ; in float v_total_opacity ; void main () { fragColor = texture ( u_texture , v_tex ) * v_total_opacity ;
# ifdef OVERDRAW_INSPECTOR
fragColor = vec4 ( 1.0 );
# endif
} `,` layout ( location = 0 ) in vec4 a_pos_offset ; layout ( location = 1 ) in uvec4 a_data ; layout ( location = 2 ) in vec4 a_pixeloffset ; layout ( location = 3 ) in vec3 a_projected_pos ; layout ( location = 4 ) in uint a_fade_opacity ; layout ( location = 5 ) in float a_height_offset ; uniform bool u_is_size_zoom_constant ; uniform bool u_is_size_feature_constant ; uniform highp float u_size_t ; uniform highp float u_size ; uniform bool u_rotate_symbol ; uniform mat4 u_label_plane_matrix ; uniform mat4 u_coord_matrix ; uniform bool u_is_text ; uniform bool u_pitch_with_map ; uniform vec2 u_texsize ; uniform bool u_is_along_line ; uniform bool u_is_variable_anchor ; uniform vec2 u_translation ; uniform float u_pitched_scale ; uniform bool u_is_offset ; uniform bool u_height_anchor_ground ; out vec2 v_tex ; out float v_total_opacity ;
# pragma maplibre : define lowp float opacity
void main () {
# pragma maplibre : initialize lowp float opacity
vec2 a_pos = a_pos_offset . xy ; vec2 a_offset = a_pos_offset . zw ; vec2 a_tex = vec2 ( a_data . xy ); vec2 a_size = vec2 ( a_data . zw ); float a_size_min = float ( a_data . z >> 1 u ); vec2 a_pxoffset = a_pixeloffset . xy ; vec2 a_minFontScale = a_pixeloffset . zw / 256.0 ; float ele = a_height_offset + ( u_height_anchor_ground ? get_elevation ( a_pos ) : 0.0 ); highp float segment_angle =- a_projected_pos [ 2 ]; float size ; if ( ! u_is_size_zoom_constant && ! u_is_size_feature_constant ) { size = mix ( a_size_min , a_size [ 1 ], u_size_t ) / 128.0 ;} else if ( u_is_size_zoom_constant && ! u_is_size_feature_constant ) { size = a_size_min / 128.0 ;} else { size = u_size ;} vec2 translated_a_pos = a_pos + u_translation ; vec4 projectedPoint = projectTileWithElevation ( translated_a_pos , ele ); vec2 fade_opacity = unpack_opacity ( a_fade_opacity ); float fade_change = fade_opacity [ 1 ] > 0.5 ? u_symbol_fade_change :- u_symbol_fade_change ; float visibility = calculate_visibility ( projectedPoint ); v_total_opacity = opacity * max ( 0.0 , min ( visibility , fade_opacity [ 0 ] + fade_change )); if ( v_total_opacity < 0.1 ){ gl_Position = vec4 ( - 2. , - 2. , - 2. , 1. ); return ;} highp float camera_to_anchor_distance = projectedPoint . w ; highp float distance_ratio = u_pitch_with_map ?
camera_to_anchor_distance / u_camera_to_center_distance :
u_camera_to_center_distance / camera_to_anchor_distance ; highp float perspective_ratio = clamp ( 0.5 + 0.5 * distance_ratio , 0.0 , 4.0 ); if ( ! u_is_offset ) { size *= perspective_ratio ;} float fontScale = u_is_text ? size / 24.0 : size ; highp float symbol_rotation = 0.0 ; if ( u_rotate_symbol ) { vec4 offsetProjectedPoint = projectTileWithElevation ( translated_a_pos + vec2 ( 1 , 0 ), ele ); vec2 a = projectedPoint . xy / projectedPoint . w ; vec2 b = offsetProjectedPoint . xy / offsetProjectedPoint . w ; symbol_rotation = atan (( b . y - a . y ) / u_aspect_ratio , b . x - a . x );} highp float angle_sin = sin ( segment_angle + symbol_rotation ); highp float angle_cos = cos ( segment_angle + symbol_rotation ); mat2 rotation_matrix = mat2 ( angle_cos , - 1.0 * angle_sin , angle_sin , angle_cos ); vec4 projected_pos ; if ( u_is_along_line || u_is_variable_anchor ) { projected_pos = vec4 ( a_projected_pos . xy , ele , 1.0 );} else if ( u_pitch_with_map ) { projected_pos = u_label_plane_matrix * vec4 ( a_projected_pos . xy + u_translation , ele , 1.0 );} else { projected_pos = u_label_plane_matrix * projectTileWithElevation ( a_projected_pos . xy + u_translation , ele );} float z = float ( u_pitch_with_map ) * projected_pos . z / projected_pos . w ; float projectionScaling = 1.0 ;
# ifdef GLOBE
if ( u_pitch_with_map ) { float anchor_pos_tile_y = ( u_coord_matrix * vec4 ( projected_pos . xy / projected_pos . w , z , 1.0 )). y ; projectionScaling = mix ( projectionScaling , 1.0 / circumferenceRatioAtTileY ( anchor_pos_tile_y ) * u_pitched_scale , u_projection_transition );}
# endif
vec4 finalPos = u_coord_matrix * vec4 ( projected_pos . xy / projected_pos . w + rotation_matrix * ( a_offset / 32.0 * max ( a_minFontScale , fontScale ) + a_pxoffset / 16.0 ) * projectionScaling , z , 1.0 ); if ( u_pitch_with_map ) { finalPos = projectTileWithElevation ( finalPos . xy , finalPos . z );} gl_Position = finalPos ; v_tex = a_tex / u_texsize ;} `),symbolSDF:we(` # define SDF_PX 8.0
uniform bool u_is_halo ; uniform bool u_is_plain ; uniform sampler2D u_texture ; uniform highp float u_gamma_scale ; uniform bool u_is_text ; in vec2 v_data0 ; in vec3 v_data1 ;
# pragma maplibre : define highp vec4 fill_color
# pragma maplibre : define highp vec4 halo_color
# pragma maplibre : define lowp float halo_width
# pragma maplibre : define lowp float halo_blur
void main () {
# pragma maplibre : initialize highp vec4 fill_color
# pragma maplibre : initialize highp vec4 halo_color
# pragma maplibre : initialize lowp float halo_width
# pragma maplibre : initialize lowp float halo_blur
float EDGE_GAMMA = 0.105 / u_device_pixel_ratio ; vec2 tex = v_data0 . xy ; float gamma_scale = v_data1 . x ; float size = v_data1 . y ; float total_opacity = v_data1 [ 2 ]; float fontScale = u_is_text ? size / 24.0 : size ; highp float gamma = EDGE_GAMMA / ( fontScale * u_gamma_scale ); lowp float inner_edge = ( 256.0 - 64.0 ) / 256.0 ; lowp float dist = texture ( u_texture , tex ). a ; lowp vec4 color_alpha_out_text , color_alpha_out_halo ; if ( u_is_plain ){ highp float gamma_scaled = gamma * gamma_scale ; highp float alpha = smoothstep ( inner_edge - gamma_scaled , inner_edge + gamma_scaled , dist ); color_alpha_out_text = total_opacity * alpha * fill_color ;} if ( u_is_halo ) { float gamma_halo = ( halo_blur * 1.19 / SDF_PX + EDGE_GAMMA ) / ( fontScale * u_gamma_scale ); float inner_edge_halo = inner_edge + gamma_halo * gamma_scale ; highp float gamma_scaled_halo = gamma_halo * gamma_scale ; highp float alpha_halo = smoothstep ( inner_edge_halo - gamma_scaled_halo , inner_edge_halo + gamma_scaled_halo , dist ); highp float halo_edge = ( 6.0 - halo_width / fontScale ) / SDF_PX ; alpha_halo = min ( smoothstep ( halo_edge - gamma_scaled_halo , halo_edge + gamma_scaled_halo , dist ), 1.0 - alpha_halo ); color_alpha_out_halo = total_opacity * alpha_halo * halo_color ;} if ( u_is_plain && u_is_halo ) { fragColor = color_alpha_out_text + ( 1. - color_alpha_out_text . a ) * color_alpha_out_halo ;} else if ( u_is_halo ){ fragColor = color_alpha_out_halo ;} else { fragColor = color_alpha_out_text ;}
# ifdef OVERDRAW_INSPECTOR
fragColor = vec4 ( 1.0 );
# endif
} `,` layout ( location = 0 ) in vec4 a_pos_offset ; layout ( location = 1 ) in uvec4 a_data ; layout ( location = 2 ) in vec4 a_pixeloffset ; layout ( location = 3 ) in vec3 a_projected_pos ; layout ( location = 4 ) in uint a_fade_opacity ; layout ( location = 5 ) in float a_height_offset ; uniform bool u_is_size_zoom_constant ; uniform bool u_is_size_feature_constant ; uniform highp float u_size_t ; uniform highp float u_size ; uniform mat4 u_label_plane_matrix ; uniform mat4 u_coord_matrix ; uniform bool u_is_text ; uniform bool u_pitch_with_map ; uniform bool u_is_along_line ; uniform bool u_is_variable_anchor ; uniform bool u_rotate_symbol ; uniform vec2 u_texsize ; uniform vec2 u_translation ; uniform float u_pitched_scale ; uniform bool u_is_offset ; uniform bool u_height_anchor_ground ; out vec2 v_data0 ; out vec3 v_data1 ;
# pragma maplibre : define highp vec4 fill_color
# pragma maplibre : define highp vec4 halo_color
# pragma maplibre : define lowp float opacity
# pragma maplibre : define lowp float halo_width
# pragma maplibre : define lowp float halo_blur
void main () {
# pragma maplibre : initialize highp vec4 fill_color
# pragma maplibre : initialize highp vec4 halo_color
# pragma maplibre : initialize lowp float opacity
# pragma maplibre : initialize lowp float halo_width
# pragma maplibre : initialize lowp float halo_blur
vec2 a_pos = a_pos_offset . xy ; vec2 a_offset = a_pos_offset . zw ; vec2 a_tex = vec2 ( a_data . xy ); vec2 a_size = vec2 ( a_data . zw ); float a_size_min = float ( a_data . z >> 1 u ); vec2 a_pxoffset = a_pixeloffset . xy / 16.0 ; vec2 a_minFontScale = a_pixeloffset . zw / 256.0 ; float ele = a_height_offset + ( u_height_anchor_ground ? get_elevation ( a_pos ) : 0.0 ); highp float segment_angle =- a_projected_pos [ 2 ]; float size ; if ( ! u_is_size_zoom_constant && ! u_is_size_feature_constant ) { size = mix ( a_size_min , a_size [ 1 ], u_size_t ) / 128.0 ;} else if ( u_is_size_zoom_constant && ! u_is_size_feature_constant ) { size = a_size_min / 128.0 ;} else { size = u_size ;} vec2 translated_a_pos = a_pos + u_translation ; vec4 projectedPoint = projectTileWithElevation ( translated_a_pos , ele ); vec2 fade_opacity = unpack_opacity ( a_fade_opacity ); float visibility = calculate_visibility ( projectedPoint ); float fade_change = fade_opacity [ 1 ] > 0.5 ? u_symbol_fade_change :- u_symbol_fade_change ; float interpolated_fade_opacity = max ( 0.0 , min ( visibility , fade_opacity [ 0 ] + fade_change )); float total_opacity = opacity * interpolated_fade_opacity ; if ( total_opacity < 0.1 ){ gl_Position = vec4 ( - 2. , - 2. , - 2. , 1. ); return ;} highp float camera_to_anchor_distance = projectedPoint . w ; highp float distance_ratio = u_pitch_with_map ?
camera_to_anchor_distance / u_camera_to_center_distance :
u_camera_to_center_distance / camera_to_anchor_distance ; highp float perspective_ratio = clamp ( 0.5 + 0.5 * distance_ratio , 0.0 , 4.0 ); if ( ! u_is_offset ) { size *= perspective_ratio ;} float fontScale = u_is_text ? size / 24.0 : size ; highp float symbol_rotation = 0.0 ; if ( u_rotate_symbol ) { vec4 offsetProjectedPoint = projectTileWithElevation ( translated_a_pos + vec2 ( 1 , 0 ), ele ); vec2 a = projectedPoint . xy / projectedPoint . w ; vec2 b = offsetProjectedPoint . xy / offsetProjectedPoint . w ; symbol_rotation = atan (( b . y - a . y ) / u_aspect_ratio , b . x - a . x );} highp float angle_sin = sin ( segment_angle + symbol_rotation ); highp float angle_cos = cos ( segment_angle + symbol_rotation ); mat2 rotation_matrix = mat2 ( angle_cos , - 1.0 * angle_sin , angle_sin , angle_cos ); vec4 projected_pos ; if ( u_is_along_line || u_is_variable_anchor ) { projected_pos = vec4 ( a_projected_pos . xy , ele , 1.0 );} else if ( u_pitch_with_map ) { projected_pos = u_label_plane_matrix * vec4 ( a_projected_pos . xy + u_translation , ele , 1.0 );} else { projected_pos = u_label_plane_matrix * projectTileWithElevation ( a_projected_pos . xy + u_translation , ele );} float z = float ( u_pitch_with_map ) * projected_pos . z / projected_pos . w ; float projectionScaling = 1.0 ;
# ifdef GLOBE
if ( u_pitch_with_map ) { float anchor_pos_tile_y = ( u_coord_matrix * vec4 ( projected_pos . xy / projected_pos . w , z , 1.0 )). y ; projectionScaling = mix ( projectionScaling , 1.0 / circumferenceRatioAtTileY ( anchor_pos_tile_y ) * u_pitched_scale , u_projection_transition );}
# endif
vec4 finalPos = u_coord_matrix * vec4 ( projected_pos . xy / projected_pos . w + rotation_matrix * ( a_offset / 32.0 * max ( a_minFontScale , fontScale ) + a_pxoffset ) * projectionScaling , z , 1.0 ); if ( u_pitch_with_map ) { finalPos = projectTileWithElevation ( finalPos . xy , finalPos . z );} float gamma_scale = finalPos . w ; gl_Position = finalPos ; v_data0 = a_tex / u_texsize ; v_data1 = vec3 ( gamma_scale , size , total_opacity );} `),symbolTextAndIcon:we(` # define SDF_PX 8.0
# define SDF 1.0
# define ICON 0.0
uniform bool u_is_halo ; uniform bool u_is_text ; uniform sampler2D u_texture ; uniform sampler2D u_texture_icon ; uniform highp float u_gamma_scale ; in vec4 v_data0 ; in vec3 v_data1 ; in float v_is_sdf ;
# pragma maplibre : define highp vec4 fill_color
# pragma maplibre : define highp vec4 halo_color
# pragma maplibre : define lowp float halo_width
# pragma maplibre : define lowp float halo_blur
void main () {
# pragma maplibre : initialize highp vec4 fill_color
# pragma maplibre : initialize highp vec4 halo_color
# pragma maplibre : initialize lowp float halo_width
# pragma maplibre : initialize lowp float halo_blur
float total_opacity = v_data1 [ 2 ]; if ( v_is_sdf == ICON ) { vec2 tex_icon = v_data0 . zw ; fragColor = texture ( u_texture_icon , tex_icon ) * total_opacity ;
# ifdef OVERDRAW_INSPECTOR
fragColor = vec4 ( 1.0 );
# endif
return ;} vec2 tex = v_data0 . xy ; float EDGE_GAMMA = 0.105 / u_device_pixel_ratio ; float gamma_scale = v_data1 . x ; float size = v_data1 . y ; float fontScale = size / 24.0 ; highp float gamma = EDGE_GAMMA / ( fontScale * u_gamma_scale ); lowp float buff = ( 256.0 - 64.0 ) / 256.0 ; lowp float dist = texture ( u_texture , tex ). a ; lowp vec4 color_alpha_out , color_alpha_out_halo ; if ( u_is_text ) { highp float gamma_scaled = gamma * gamma_scale ; highp float alpha = smoothstep ( buff - gamma_scaled , buff + gamma_scaled , dist ); color_alpha_out = fill_color * ( alpha * total_opacity );} if ( u_is_halo ) { highp float gamma_halo = ( halo_blur * 1.19 / SDF_PX + EDGE_GAMMA ) / ( fontScale * u_gamma_scale ); lowp float buff_halo = ( 6.0 - halo_width / fontScale ) / SDF_PX ; highp float gamma_scaled_halo = gamma_halo * gamma_scale ; highp float alpha_halo = smoothstep ( buff_halo - gamma_scaled_halo , buff_halo + gamma_scaled_halo , dist ); color_alpha_out_halo = halo_color * ( alpha_halo * total_opacity );} if ( u_is_text && u_is_halo ) { fragColor = color_alpha_out + ( 1. - color_alpha_out . a ) * color_alpha_out_halo ;} else if ( u_is_halo ) { fragColor = color_alpha_out_halo ;} else { fragColor = color_alpha_out ;}
# ifdef OVERDRAW_INSPECTOR
fragColor = vec4 ( 1.0 );
# endif
} `,` layout ( location = 0 ) in vec4 a_pos_offset ; layout ( location = 1 ) in uvec4 a_data ; layout ( location = 2 ) in vec3 a_projected_pos ; layout ( location = 3 ) in uint a_fade_opacity ; layout ( location = 4 ) in float a_height_offset ; uniform bool u_is_size_zoom_constant ; uniform bool u_is_size_feature_constant ; uniform highp float u_size_t ; uniform highp float u_size ; uniform mat4 u_label_plane_matrix ; uniform mat4 u_coord_matrix ; uniform bool u_is_text ; uniform bool u_pitch_with_map ; uniform bool u_rotate_symbol ; uniform vec2 u_texsize ; uniform vec2 u_texsize_icon ; uniform bool u_is_along_line ; uniform bool u_is_variable_anchor ; uniform vec2 u_translation ; uniform float u_pitched_scale ; uniform bool u_is_offset ; uniform bool u_height_anchor_ground ; out vec4 v_data0 ; out vec3 v_data1 ; out float v_is_sdf ;
# pragma maplibre : define highp vec4 fill_color
# pragma maplibre : define highp vec4 halo_color
# pragma maplibre : define lowp float opacity
# pragma maplibre : define lowp float halo_width
# pragma maplibre : define lowp float halo_blur
void main () {
# pragma maplibre : initialize highp vec4 fill_color
# pragma maplibre : initialize highp vec4 halo_color
# pragma maplibre : initialize lowp float opacity
# pragma maplibre : initialize lowp float halo_width
# pragma maplibre : initialize lowp float halo_blur
vec2 a_pos = a_pos_offset . xy ; vec2 a_offset = a_pos_offset . zw ; vec2 a_tex = vec2 ( a_data . xy ); vec2 a_size = vec2 ( a_data . zw ); float a_size_min = float ( a_data . z >> 1 u ); float is_sdf = float ( a_data . z & 1 u ); float ele = a_height_offset + ( u_height_anchor_ground ? get_elevation ( a_pos ) : 0.0 ); highp float segment_angle =- a_projected_pos [ 2 ]; float size ; if ( ! u_is_size_zoom_constant && ! u_is_size_feature_constant ) { size = mix ( a_size_min , a_size [ 1 ], u_size_t ) / 128.0 ;} else if ( u_is_size_zoom_constant && ! u_is_size_feature_constant ) { size = a_size_min / 128.0 ;} else { size = u_size ;} vec2 translated_a_pos = a_pos + u_translation ; vec4 projectedPoint = projectTileWithElevation ( translated_a_pos , ele ); vec2 fade_opacity = unpack_opacity ( a_fade_opacity ); float visibility = calculate_visibility ( projectedPoint ); float fade_change = fade_opacity [ 1 ] > 0.5 ? u_symbol_fade_change :- u_symbol_fade_change ; float interpolated_fade_opacity = max ( 0.0 , min ( visibility , fade_opacity [ 0 ] + fade_change )); float total_opacity = opacity * interpolated_fade_opacity ; if ( total_opacity < 0.1 ){ gl_Position = vec4 ( - 2. , - 2. , - 2. , 1. ); return ;} highp float camera_to_anchor_distance = projectedPoint . w ; highp float distance_ratio = u_pitch_with_map ?
camera_to_anchor_distance / u_camera_to_center_distance :
u_camera_to_center_distance / camera_to_anchor_distance ; highp float perspective_ratio = clamp ( 0.5 + 0.5 * distance_ratio , 0.0 , 4.0 ); if ( ! u_is_offset ) { size *= perspective_ratio ;} float fontScale = size / 24.0 ; highp float symbol_rotation = 0.0 ; if ( u_rotate_symbol ) { vec4 offsetProjectedPoint = projectTileWithElevation ( translated_a_pos + vec2 ( 1 , 0 ), ele ); vec2 a = projectedPoint . xy / projectedPoint . w ; vec2 b = offsetProjectedPoint . xy / offsetProjectedPoint . w ; symbol_rotation = atan (( b . y - a . y ) / u_aspect_ratio , b . x - a . x );} highp float angle_sin = sin ( segment_angle + symbol_rotation ); highp float angle_cos = cos ( segment_angle + symbol_rotation ); mat2 rotation_matrix = mat2 ( angle_cos , - 1.0 * angle_sin , angle_sin , angle_cos ); vec4 projected_pos ; if ( u_is_along_line || u_is_variable_anchor ) { projected_pos = vec4 ( a_projected_pos . xy , ele , 1.0 );} else if ( u_pitch_with_map ) { projected_pos = u_label_plane_matrix * vec4 ( a_projected_pos . xy + u_translation , ele , 1.0 );} else { projected_pos = u_label_plane_matrix * projectTileWithElevation ( a_projected_pos . xy + u_translation , ele );} float z = float ( u_pitch_with_map ) * projected_pos . z / projected_pos . w ; float projectionScaling = 1.0 ;
# ifdef GLOBE
if ( u_pitch_with_map && ! u_is_along_line ) { float anchor_pos_tile_y = ( u_coord_matrix * vec4 ( projected_pos . xy / projected_pos . w , z , 1.0 )). y ; projectionScaling = mix ( projectionScaling , 1.0 / circumferenceRatioAtTileY ( anchor_pos_tile_y ) * u_pitched_scale , u_projection_transition );}
# endif
vec4 finalPos = u_coord_matrix * vec4 ( projected_pos . xy / projected_pos . w + rotation_matrix * ( a_offset / 32.0 * fontScale ) * projectionScaling , z , 1.0 ); if ( u_pitch_with_map ) { finalPos = projectTileWithElevation ( finalPos . xy , finalPos . z );} float gamma_scale = finalPos . w ; gl_Position = finalPos ; v_data0 . xy = a_tex / u_texsize ; v_data0 . zw = a_tex / u_texsize_icon ; v_data1 = vec3 ( gamma_scale , size , total_opacity ); v_is_sdf = is_sdf ;} `),terrain:we("uniform sampler2D u_texture;uniform vec4 u_fog_color;uniform vec4 u_horizon_color;uniform float u_fog_ground_blend;uniform float u_fog_ground_blend_opacity;uniform float u_horizon_fog_blend;uniform bool u_is_globe_mode;in vec2 v_texture_pos;in float v_fog_depth;const float gamma=2.2;vec4 gammaToLinear(vec4 color) {return pow(color,vec4(gamma));}vec4 linearToGamma(vec4 color) {return pow(color,vec4(1.0/gamma));}void main() {vec4 surface_color=texture(u_texture,vec2(v_texture_pos.x,1.0-v_texture_pos.y));if (!u_is_globe_mode && u_fog_ground_blend_opacity > 0.0 && v_fog_depth > u_fog_ground_blend) {vec4 surface_color_linear=gammaToLinear(surface_color);float blend_color=smoothstep(0.0,1.0,max((v_fog_depth-u_horizon_fog_blend)/(1.0-u_horizon_fog_blend),0.0));vec4 fog_horizon_color_linear=mix(gammaToLinear(u_fog_color),gammaToLinear(u_horizon_color),blend_color);float factor_fog=max(v_fog_depth-u_fog_ground_blend,0.0)/(1.0-u_fog_ground_blend);fragColor=linearToGamma(mix(surface_color_linear,fog_horizon_color_linear,pow(factor_fog,2.0)*u_fog_ground_blend_opacity));} else {fragColor=surface_color;}}","layout(location=0) in vec3 a_pos3d;uniform mat4 u_fog_matrix;uniform float u_ele_delta;out vec2 v_texture_pos;out float v_fog_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;v_texture_pos=a_pos3d.xy/8192.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);vec4 pos=u_fog_matrix*vec4(a_pos3d.xy,ele,1.0);v_fog_depth=pos.z/pos.w*0.5+0.5;}"),terrainDepth:we("in float v_depth;const highp vec4 bitSh=vec4(256.*256.*256.,256.*256.,256.,1.);const highp vec4 bitMsk=vec4(0.,vec3(1./256.0));highp vec4 pack(highp float value) {highp vec4 comp=fract(value*bitSh);comp-=comp.xxyz*bitMsk;return comp;}void main() {fragColor=pack(v_depth);}","layout(location=0) in vec3 a_pos3d;uniform float u_ele_delta;out float v_depth;void main() {float ele=get_elevation(a_pos3d.xy);float ele_delta=a_pos3d.z==1.0 ? u_ele_delta : 0.0;gl_Position=projectTileFor3D(a_pos3d.xy,ele-ele_delta);v_depth=gl_Position.z/gl_Position.w;}"),terrainHeight:we("in highp float v_elevation;void main() {fragColor=vec4(v_elevation,0.0,0.0,1.0);}","layout(location=0) in vec3 a_pos3d;uniform vec4 u_tile_bounds;out highp float v_elevation;void main() {v_elevation=get_elevation(a_pos3d.xy);vec2 position=u_tile_bounds.xy+a_pos3d.xy/8192.0*u_tile_bounds.zw;gl_Position=vec4(position.x*2.0-1.0,1.0-position.y*2.0,0.0,1.0);}"),atmosphere:we(` # ifdef GL_ES
precision highp float ;
# endif
in vec3 view_direction ; uniform vec3 u_sun_pos ; uniform vec3 u_globe_position ; uniform float u_globe_radius ; uniform float u_atmosphere_blend ; /**Shader use from https:*Made some change to adapt to MapLibre Globe geometry*/ const float PI = 3.141592653589793 ; const int iSteps = 5 ; const int jSteps = 3 ; /*radius of the planet*/ const float EARTH_RADIUS = 6371e3 ; /*radius of the atmosphere*/ const float ATMOS_RADIUS = 6471e3 ; vec2 rsi ( vec3 r0 , vec3 rd , float sr ) { float a = dot ( rd , rd ); float b = 2.0 * dot ( rd , r0 ); float c = dot ( r0 , r0 ) - ( sr * sr ); float d = ( b * b ) - 4.0 * a * c ; if ( d < 0.0 ) return vec2 ( 1e5 , - 1e5 ); return vec2 (( - b - sqrt ( d )) / ( 2.0 * a ),( - b + sqrt ( d )) / ( 2.0 * a ));} vec4 atmosphere ( vec3 r , vec3 r0 , vec3 pSun , float iSun , float rPlanet , float rAtmos , vec3 kRlh , float kMie , float shRlh , float shMie , float g ) { pSun = normalize ( pSun ); r = normalize ( r ); vec2 p = rsi ( r0 , r , rAtmos ); if ( p . x > p . y ) { return vec4 ( 0.0 , 0.0 , 0.0 , 1.0 );} if ( p . x < 0.0 ) { p . x = 0.0 ;} vec3 pos = r0 + r * p . x ; vec2 p2 = rsi ( r0 , r , rPlanet ); if ( p2 . x <= p2 . y && p2 . x > 0.0 ) { p . y = min ( p . y , p2 . x );} float iStepSize = ( p . y - p . x ) / float ( iSteps ); float iTime = p . x + iStepSize * 0.5 ; vec3 totalRlh = vec3 ( 0 , 0 , 0 ); vec3 totalMie = vec3 ( 0 , 0 , 0 ); float iOdRlh = 0.0 ; float iOdMie = 0.0 ; float mu = dot ( r , pSun ); float mumu = mu * mu ; float gg = g * g ; float pRlh = 3.0 / ( 16.0 * PI ) * ( 1.0 + mumu ); float pMie = 3.0 / ( 8.0 * PI ) * (( 1.0 - gg ) * ( mumu + 1.0 )) / ( pow ( 1.0 + gg - 2.0 * mu * g , 1.5 ) * ( 2.0 + gg )); for ( int i = 0 ; i < iSteps ; i ++ ) { vec3 iPos = r0 + r * iTime ; float iHeight = length ( iPos ) - rPlanet ; float odStepRlh = exp ( - iHeight / shRlh ) * iStepSize ; float odStepMie = exp ( - iHeight / shMie ) * iStepSize ; iOdRlh += odStepRlh ; iOdMie += odStepMie ; float jStepSize = rsi ( iPos , pSun , rAtmos ). y / float ( jSteps ); float jTime = jStepSize * 0.5 ; float jOdRlh = 0.0 ; float jOdMie = 0.0 ; for ( int j = 0 ; j < jSteps ; j ++ ) { vec3 jPos = iPos + pSun * jTime ; float jHeight = length ( jPos ) - rPlanet ; jOdRlh += exp ( - jHeight / shRlh ) * jStepSize ; jOdMie += exp ( - jHeight / shMie ) * jStepSize ; jTime += jStepSize ;} vec3 attn = exp ( - ( kMie * ( iOdMie + jOdMie ) + kRlh * ( iOdRlh + jOdRlh ))); totalRlh += odStepRlh * attn ; totalMie += odStepMie * attn ; iTime += iStepSize ;} float opacity = exp ( - ( length ( kRlh ) * length ( totalRlh ) + kMie * length ( totalMie ))); vec3 color = iSun * ( pRlh * kRlh * totalRlh + pMie * kMie * totalMie ); return vec4 ( color , opacity );} void main () { vec3 scale_camera_pos =- u_globe_position * EARTH_RADIUS / u_globe_radius ; vec4 color = atmosphere ( normalize ( view_direction ), scale_camera_pos , u_sun_pos , 22.0 , EARTH_RADIUS , ATMOS_RADIUS , vec3 ( 5.5 e - 6 , 13.0 e - 6 , 22.4 e - 6 ), 21e-6 , 8e3 , 1.2 e3 , 0.758
); color . rgb = 1.0 - exp ( - 1.0 * color . rgb ); color = pow ( color , vec4 ( 1.0 / 2.2 )); fragColor = vec4 ( color . rgb , 1.0 - color . a ) * u_atmosphere_blend ;} `,"layout(location=0) in vec2 a_pos;uniform mat4 u_inv_proj_matrix;out vec3 view_direction;void main() {view_direction=(u_inv_proj_matrix*vec4(a_pos,0.0,1.0)).xyz;gl_Position=vec4(a_pos,0.0,1.0);}"),sky:we("uniform vec4 u_sky_color;uniform vec4 u_horizon_color;uniform vec2 u_horizon;uniform vec2 u_horizon_normal;uniform float u_sky_horizon_blend;uniform float u_sky_blend;uniform vec3 u_globe_position;uniform float u_globe_radius;uniform float u_atmosphere_blend;in vec3 v_view_direction;const float ATMOSPHERE_HEIGHT_TO_GLOBE_RADIUS=100000.0/6371000.0;void main() {float x=gl_FragCoord.x;float y=gl_FragCoord.y;float blend=(y-u_horizon.y)*u_horizon_normal.y+(x-u_horizon.x)*u_horizon_normal.x;float opacity=1.0;if (u_sky_blend > 0.0) {vec3 ray=normalize(v_view_direction);float globe_distance=length(u_globe_position);float angle_to_globe_center=acos(clamp(dot(ray,u_globe_position)/globe_distance,-1.0,1.0));float horizon_angle=asin(min(u_globe_radius/globe_distance,1.0));blend=mix(blend,((angle_to_globe_center-horizon_angle)*u_camera_to_center_distance+1.0)*u_device_pixel_ratio,u_sky_blend);float closest_approach=max(dot(ray,u_globe_position),0.0);float lowest_altitude=sqrt(max(globe_distance*globe_distance-closest_approach*closest_approach,0.0))-u_globe_radius;float atmosphere_height=u_globe_radius*ATMOSPHERE_HEIGHT_TO_GLOBE_RADIUS;float inside_atmosphere=1.0-smoothstep(atmosphere_height,10.0*atmosphere_height,globe_distance-u_globe_radius);float through_atmosphere=1.0-smoothstep(0.0,atmosphere_height,lowest_altitude);opacity=inside_atmosphere*through_atmosphere*(1.0-u_atmosphere_blend);}if (blend > 0.0) {if (blend < u_sky_horizon_blend) {fragColor=mix(u_sky_color,u_horizon_color,pow(1.0-blend/u_sky_horizon_blend,2.0));} else {fragColor=u_sky_color;}}fragColor*=mix(1.0,opacity,u_sky_blend);}","layout(location=0) in vec2 a_pos;uniform mat4 u_inv_proj_matrix;out vec3 v_view_direction;void main() {v_view_direction=(u_inv_proj_matrix*vec4(a_pos,0.0,1.0)).xyz;gl_Position=vec4(a_pos,1.0,1.0);}")};function we(e,t){let i=/#pragma maplibre: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g,r=t.match(/in ([\w]+) ([\w]+)/g),a=e.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),n=t.match(/uniform ([\w]+) ([\w]+)([\s]*)([\w]*)/g),o=n?n.concat(a):a,s=r?r.length:0,l={};return e=e.replace(i,(u,h,c,d,p)=>(l[p]=!0,h==="define"?`
# ifndef HAS_UNIFORM_u_$ { p }
in $ { c } $ { d } $ { p };
# else
uniform $ { c } $ { d } u_$ { p };
# endif
`:`
# ifdef HAS_UNIFORM_u_$ { p }
$ { c } $ { d } $ { p } = u_$ { p };
# endif
`)),t=t.replace(i,(u,h,c,d,p)=>{let f=d==="float"?"vec2":"vec4",m=p.match(/color/)?"color":f;return l[p]?h==="define"?`
# ifndef HAS_UNIFORM_u_$ { p }
uniform lowp float u_$ { p } _t ;
layout ( location = $ { s ++ }) in $ { c } $ { f } a_$ { p };
out $ { c } $ { d } $ { p };
# else
uniform $ { c } $ { d } u_$ { p };
# endif
`:m==="vec4"?`
# ifndef HAS_UNIFORM_u_$ { p }
$ { p } = a_$ { p };
# else
$ { c } $ { d } $ { p } = u_$ { p };
# endif
`:`
# ifndef HAS_UNIFORM_u_$ { p }
$ { p } = unpack_mix_$ { m }( a_$ { p }, u_$ { p } _t );
# else
$ { c } $ { d } $ { p } = u_$ { p };
# endif
`:h==="define"?`
# ifndef HAS_UNIFORM_u_$ { p }
uniform lowp float u_$ { p } _t ;
layout ( location = $ { s ++ }) in $ { c } $ { f } a_$ { p };
# else
uniform $ { c } $ { d } u_$ { p };
# endif
`:m==="vec4"?`
# ifndef HAS_UNIFORM_u_$ { p }
$ { c } $ { d } $ { p } = a_$ { p };
# else
$ { c } $ { d } $ { p } = u_$ { p };
# endif
`:`
# ifndef HAS_UNIFORM_u_$ { p }
$ { c } $ { d } $ { p } = unpack_mix_$ { m }( a_$ { p }, u_$ { p } _t );
# else
$ { c } $ { d } $ { p } = u_$ { p };
# endif
2026-10-19 07:27:48 +08:00
`}),{fragmentSource:e,vertexSource:t,staticAttributes:r,staticUniforms:o}}const Uv="#define PROJECTION_MERCATOR",$v="mercator";var Ws=class{constructor(e=ln){this._cachedMesh=null,this._worldCoordinateHelper=e}get name(){return this._worldCoordinateHelper.name}get worldCoordinateHelper(){return this._worldCoordinateHelper}get useSubdivision(){return!1}get shaderVariantName(){return $v}get shaderDefine(){return Uv}get shaderPreludeCode(){return Wi.projectionMercator}get vertexShaderPreludeCode(){return Wi.projectionMercator.vertexSource}get subdivisionGranularity(){return Wd.noSubdivision}get useGlobeControls(){return!1}get transitionState(){return 0}destroy(){}getMeshFromTileID(e,t,i,r,a){if(this._cachedMesh)return this._cachedMesh;let n=new qr;n.emplaceBack(0,0),n.emplaceBack(O,0),n.emplaceBack(0,O),n.emplaceBack(O,O);let o=e.createVertexBuffer(n,Ba.members),s=Ke.simpleSegment(0,0,4,2),l=new Ki;l.emplaceBack(1,0,2),l.emplaceBack(1,2,3);let u=e.createIndexBuffer(l);return this._cachedMesh=new wo(o,u,s),this._cachedMesh}recalculate(){}hasTransition(){return!1}},Vg=class Gv{constructor(t=0,i=0,r=0,a=0){if(isNaN(t)||t<0||isNaN(i)||i<0||isNaN(r)||r<0||isNaN(a)||a<0)throw Error("Invalid value for edge-insets, top, bottom, left and right must all be numbers");this.top=t,this.bottom=i,this.left=r,this.right=a}interpolate(t,i,r){return i.top!=null&&t.top!=null&&(this.top=We.number(t.top,i.top,r)),i.bottom!=null&&t.bottom!=null&&(this.bottom=We.number(t.bottom,i.bottom,r)),i.left!=null&&t.left!=null&&(this.left=We.number(t.left,i.left,r)),i.right!=null&&t.right!=null&&(this.right=We.number(t.right,i.right,r)),this}getCenter(t,i){return new M(Y((this.left+t-this.right)/2,0,t),Y((this.top+i-this.bottom)/2,0,i))}equals(t){return this.top===t.top&&this.bottom===t.bottom&&this.left===t.left&&this.right===t.right}clone(){return new Gv(this.top,this.bottom,this.left,this.right)}toJSON(){return{top:this.top,bottom:this.bottom,left:this.left,right:this.right}}};function Ml(e,t){if(!e.renderWorldCopies||!e.worldCoordinateHelper.wraps||e.lngRange)return;let i=t.lng-e.center.lng;t.lng+=i>180?-360:i<-180?360:0}function Ng(e){return Math.max(0,Math.floor(e))}var Dp=class{constructor(e,t){var i;this.applyConstrain=(r,a)=>this._constrainOverride===null?this._callbacks.defaultConstrain(r,a):this._constrainOverride(r,a),this._callbacks=e,this._tileSize=512,this._worldCoordinateHelper=ln,this._renderWorldCopies=(t==null?void 0:t.renderWorldCopies)===void 0||!!(t!=null&&t.renderWorldCopies),this._minZoom=(t==null?void 0:t.minZoom)||0,this._maxZoom=(t==null?void 0:t.maxZoom)||22,this._minPitch=(t==null?void 0:t.minPitch)===void 0||(t==null?void 0:t.minPitch)===null?0:t==null?void 0:t.minPitch,this._maxPitch=(t==null?void 0:t.maxPitch)===void 0||(t==null?void 0:t.maxPitch)===null?60:t==null?void 0:t.maxPitch,this._constrainOverride=(i=t==null?void 0:t.constrainOverride)!=null?i:null,this.setMaxBounds(),this._width=0,this._height=0,this._center=new W(0,0),this._elevation=0,this._zoom=0,this._tileZoom=Ng(this._zoom),this._scale=pt(this._zoom),this._bearingInRadians=0,this._fovInRadians=.6435011087932844,this._pitchInRadians=0,this._rollInRadians=0,this._unmodified=!0,this._edgeInsets=new Vg,this._minElevationForCurrentTile=0,this._autoCalculateNearFarZ=!0}apply(e,t){this._constrainOverride=e.constrainOverride,this._latRange=e.latRange,this._lngRange=e.lngRange,this._width=e.width,this._height=e.height,this._center=e.center,this._elevation=e.elevation,this._minElevationForCurrentTile=e.minElevationForCurrentTile,this._zoom=e.zoom,this._tileZoom=Ng(this._zoom),this._scale=pt(this._zoom),this._bearingInRadians=e.bearingInRadians,this._fovInRadians=e.fovInRadians,this._pitchInRadians=e.pitchInRadians,this._rollInRadians=e.rollInRadians,this._unmodified=e.unmodified,this._edgeInsets=new Vg(e.padding.top,e.padding.bottom,e.padding.left,e.padding.right),this._minZoom=e.minZoom,this._maxZoom=e.maxZoom,this._minPitch=e.minPitch,this._maxPitch=e.maxPitch,this._renderWorldCopies=e.renderWorldCopies,this._cameraToCenterDistance=e.cameraToCenterDistance,this._nearZ
2026-10-19 00:00:12 +08:00
` ), x = y . concat ( Wi . prelude . vertexSource , o . vertexSource , t . vertexSource ). join ( `
2026-10-19 07:27:48 +08:00
` ), b = u . createShader ( u . FRAGMENT_SHADER ); if ( u . isContextLost ()){ this . failedToCreate =! 0 ; return } u . shaderSource ( b , v ), u . compileShader ( b ), u . attachShader ( this . program , b ); let w = u . createShader ( u . VERTEX_SHADER ); if ( u . isContextLost ()){ this . failedToCreate =! 0 ; return } u . shaderSource ( w , x ), u . compileShader ( w ), u . attachShader ( this . program , w ), this . attributes = {}; let T = {}; if ( this . numAttributes = d . length , u . linkProgram ( this . program ), ! u . getProgramParameter ( this . program , u . LINK_STATUS )){ if ( u . isContextLost () || u . getProgramParameter ( this . program , u . ATTACHED_SHADERS ) === 0 ){ this . failedToCreate =! 0 ; return } throw u . getShaderParameter ( b , u . COMPILE_STATUS ) ? u . getShaderParameter ( w , u . COMPILE_STATUS ) ? Error ( `Program failed to link: ${ u . getProgramInfoLog ( this . program ) } ` ) : Error ( `Could not compile vertex shader: ${ u . getShaderInfoLog ( w ) } ` ) : Error ( `Could not compile fragment shader: ${ u . getShaderInfoLog ( b ) } ` )} $5 ( u , this . program ); let S = sF ( u , this . program ); for ( let C of d ){ if ( ! C ) continue ; let I = u . getAttribLocation ( this . program , C ); I >= 0 && ( this . attributes [ C ] = { location : I , isInteger : S . has ( C )})} u . deleteShader ( w ), u . deleteShader ( b ); for ( let C of _ ) if ( C &&! T [ C ]){ let I = u . getUniformLocation ( this . program , C ); I && ( T [ C ] = I )} this . fixedUniforms = r ( e , T ), this . terrainUniforms = eF ( e , T ), this . binderUniforms = i ? i . getUniforms ( e , T ) : []} draw ( e , t , i , r , a , n , o , s , l , u , h , c , d , p , f , m , g , _ , y ){ var b ; let v = e . gl ; if ( this . failedToCreate ) return ; if ( e . program . set ( this . program ), e . terrainUniformBuffer . bind (), e . frameUniformBuffer . bind (), e . setDepthMode ( i ), e . setStencilMode ( r ), e . setColorMode ( a ), e . setCullFace ( n ), s ){ e . activeTexture . set ( v . TEXTURE2 ), v . bindTexture ( v . TEXTURE_2D , s . depthTexture ), e . activeTexture . set ( v . TEXTURE3 ), v . bindTexture ( v . TEXTURE_2D , s . texture ); for ( let w in this . terrainUniforms ) this . terrainUniforms [ w ]. set ( s [ w ]); K5 ( e . terrainUniformBuffer , s )} if ( Z5 ( e , l ), o ) for ( let w in this . fixedUniforms ) this . fixedUniforms [ w ]. set ( o [ w ]); m && m . setUniforms ( e , this . binderUniforms , p ,{ zoom : f }); let x = 0 ; switch ( t ){ case v . LINES : x = 2 ; break ; case v . TRIANGLES : x = 3 ; break ; case v . LINE_STRIP : x = 1 } for ( let w of d . get ()) w . vaos || ( w . vaos = {}),( b = w . vaos )[ u ] || ( b [ u ] = new Q5 ), w . vaos [ u ]. bind ( e , this , h , m ? m . getPaintVertexBuffers () : [], c , w . vertexOffset , g , _ , y ), v . drawElements ( t , w . primitiveLength * x , v . UNSIGNED_SHORT , w . primitiveOffset * x * 2 )}}; function hx ( e , t , i ){ let r = 1 / oi ( i , 1 , t . tileZoom ), a = 2 ** i . tileID . overscaledZ , n = i . tileSize * 2 ** t . tileZoom / a , o = n * ( i . tileID . canonical . x + i . tileID . wrap * a ), s = n * i . tileID . canonical . y ; return { u_image : 0 , u_texsize : i . imageAtlasTexture . size , u_scale : [ r , e . fromScale , e . toScale ], u_fade : e . t , u_pixel_coord_upper : [ o >> 16 , s >> 16 ], u_pixel_coord_lower : [ o & 65535 , s & 65535 ]}} function uF ( e , t , i , r , a ){ let n = i . getPattern ( e . from . toString ()), o = i . getPattern ( e . to . toString ()),{ width : s , height : l } = i . getPixelSize (), u = 2 ** a . tileID . overscaledZ , h = a . tileSize * 2 ** r . tileZoom / u , c = h * ( a . tileID . canonical . x + a . tileID . wrap * u ), d = h * a . tileID . canonical . y ; return { u_image : 0 , u_pattern_tl_a : n . tl , u_pattern_br_a : n . br , u_pattern_tl_b : o . tl , u_pattern_br_b : o . br , u_texsize : [ s , l ], u_mix : t . t , u_pattern_size_a : n . displaySize , u_pattern_size_b : o . displaySize , u_scale_a : t . fromScale , u_scale_b : t . toScale , u_tile_units_to_pixels : 1 / oi ( a , 1 , r . tileZoom ), u_pixel_coord_upper : [ c >> 16 , d >> 16 ], u_pixel_coord_lower : [ c & 65535 , d & 65535 ]}} const hF = ( e , t )=>({ u_lightpos : new Vt ( e , t . u_lightpos ), u_lightpos_globe : new Vt ( e , t . u_lightpos_globe ), u_lightintensity : new G ( e , t . u_lightintensity ), u_lightcolor : new Vt ( e , t . u_lightcolor ), u_vertical_gradient : new G ( e , t . u_vertical_gradient ), u_opacity : new G ( e , t . u_opacity ), u_fill_translate : new pe ( e , t . u_fill_translate )}), cF = ( e , t )=>({ u_lightpos : new Vt ( e , t . u_lightpos ), u_lightpos_globe : new Vt ( e , t . u_lightpos_globe ), u_lightintensity : new G ( e , t . u_lightintensity ), u_lightcolor : new Vt ( e , t . u_lightcolor ), u_vertical_gradient : new G ( e , t . u_vertical_gradient ), u_height_factor : new G ( e , t . u_height_factor ), u_opacity : new G ( e , t . u_opacity ), u_fill_translate : new pe ( e , t . u_fill_translate ), u_image : new J ( e , t . u_image ), u_texsize : new pe ( e , t . u_texsize ), u_pixel_coord_upper : new pe ( e , t . u_pixel_coord_upper ), u_pixel_coord_lower : new pe ( e , t . u_pixel_coord_lower ), u_scale : new Vt ( e , t . u_scale ), u_fade : new G ( e , t . u_fade )}), cx = ( e , t , i , r , a )=>{ let n = G_ ( t . position ), o = O_ (); t . anchor === "viewport" && Qx ( o , e . bearin
2026-10-19 00:00:12 +08:00
uniform mat4 u_projection_matrix ;
2026-10-19 07:27:48 +08:00
$ { o . prelude . vertexSource } `,define:o.define},defaultProjectionData:c,getProjectionData:f=>{var m;return h.getProjectionData({overscaledTileID:new Ct(f.tileID.canonical.z,(m=f.tileID.wrap)!=null?m:0,f.tileID.canonical.z,f.tileID.canonical.x,f.tileID.canonical.y),aligned:f.aligned,applyGlobeMatrix:f.applyGlobeMatrix,applyTerrainMatrix:f.applyTerrainMatrix})},renderTerrainHeightMap:s&&a.currentPass==="offscreen"?f=>Hz(a,s,f):void 0},p=u.renderingMode?u.renderingMode:"2d";if(a.currentPass==="offscreen"){let f=u.prerender;f&&(l.setCustomLayerDefaults(),l.setColorMode(a.colorModeForRenderPass()),f.call(u,l.gl,d),l.setDirty(),e.setBaseState())}else if(a.currentPass==="translucent"){l.setCustomLayerDefaults(),l.setColorMode(a.colorModeForRenderPass()),l.setStencilMode(Pe.disabled);let f=p==="3d"?a.getDepthModeFor3D():a.getDepthModeForSublayer(0,ge.ReadOnly);l.setDepthMode(f),u.render(l.gl,d),l.setDirty(),e.setBaseState(),l.bindFramebuffer.set(null)}}function Yz(e,t,i,r){let a=r.context,n=a.bindFramebuffer.get(),o=a.viewport.get();a.setCustomLayerDefaults(),a.setColorMode(r.colorModeForRenderPass()),a.setDepthMode(ge.disabled),a.setStencilMode(Pe.disabled),t.implementation.renderToTerrainTile(a.gl,{tileID:{canonical:i.canonical,wrap:i.wrap},width:o[2],height:o[3]}),a.setDirty(),e.setBaseState(),a.bindFramebuffer.set(n),a.viewport.set(o)}function Kz(e,t){let i=t.context,r=i.gl,{sky:a,pixelRatio:n}=t.data,o=tz(a,t.transform,n),s=new ge(r.LEQUAL,ge.ReadWrite,[0,1]),l=Pe.disabled,u=t.colorModeForRenderPass();t.useProgram("sky").draw(i,r.TRIANGLES,s,l,u,Ae.disabled,o,null,void 0,"sky",e.vertexBuffer,e.indexBuffer,e.segments)}function Jz(e,t){let i=G_(e.position);sb(i,i);let r=Ii(new Float64Array(16));return e.anchor==="map"&&(Dr(r,r,t.rollInRadians),Wa(r,r,-t.pitchInRadians),Dr(r,r,t.bearingInRadians),Wa(r,r,t.center.lat*Math.PI/180),j_(r,r,-t.center.lng*Math.PI/180)),ub(i,i,r),i}function Qz(e,t){let i=t.context,r=i.gl,{sky:a,light:n}=t.data,o=t.useProgram("atmosphere"),s=new ge(r.LEQUAL,ge.ReadOnly,[0,1]),l=t.transform,u=Jz(n,l),h=l.getProjectionData({overscaledTileID:null,applyGlobeMatrix:!0,applyTerrainMatrix:!0}),c=Kr(l.worldSize,l.center.lat),d=Qv(l),p=ex(Pi(d)-c,c),f=a["atmosphere-blend"]*h.projectionTransition*p;if(f===0)return;let m=QF(u,f,d,c,l.inverseProjectionMatrix);o.draw(i,r.TRIANGLES,s,Pe.disabled,tt.alphaBlended,Ae.disabled,m,null,null,"atmosphere",e.vertexBuffer,e.indexBuffer,e.segments)}const ek={symbol:oz,circle:dz,heatmap:pz,line:Dz,fill:Sz,fillExtrusion:Ez,hillshade:Cz,colorRelief:Az,raster:Mz,background:kz,sky:Kz,atmosphere:Qz,custom:Xz,debug:Uz,debugPadding:Vz,terrainDepth:qz},__=id.maxOverzooming+id.maxUnderzooming+1,y_=1/2**16,tk={name:$v,define:Uv,prelude:Wi.projectionMercator};var ik=class{constructor(e){this.currentLayer=0,this.opaquePassCutoff=1/0,this.depthRangeFor3D=[0,1],this.isRenderingToTexture=!1,this.nextStencilID=1,this.tileClippingMaskIDs={},this.transform=e.transform,this.terrain=e.terrain,this.data=e.data,this.context=e.context,this.programCache=e.programCache,this.currentPass=e.currentPass,this.projection=e.projection}getProjectionDataForTile(e,t={}){var r;let i=this.transform.getProjectionData({overscaledTileID:e,aligned:t.aligned,applyGlobeMatrix:!this.isRenderingToTexture,applyTerrainMatrix:(r=t.applyTerrainMatrix)!=null?r:!0});return this.isRenderingToTexture||(i.uniformBufferKey=t.aligned?` $ { e . key } / aligned `:e.key),i}getTerrainDataForTile(e){var t,i;return this.isRenderingToTexture?null:(i=(t=this.terrain)==null?void 0:t.getTerrainData(e))!=null?i:null}getMeshFromTileID(e,t,i,r){return this.projection.getMeshFromTileID(this.context,e,t,i,r)}useProgram(e,t,i=!1,r=[]){return this.programCache.getProgram({name:e,programConfiguration:t,projectionShaderVariant:i?tk:this.data.projectionShaderVariant,showOverdrawInspector:this.data.showOverdrawInspector,useTerrain:this.terrain!==null,defines:r})}colorModeForRenderPass(){let e=this.context.gl;if(this.data.showOverdrawInspector){let t=.125;return new tt([e.CONSTANT_COLOR,e.ONE],new se(t,t,t,0),[!0,!0,!0,!0])}return this.currentPass==="opaque"?tt.unb
2026-10-19 00:00:12 +08:00
` ,{},[ "case" ,[ "all" ,[ "!" ,[ "has" , ` ${ a } name: ${ e } ` ]],[ "has" , "name:en" ],[ "!" ,[ "has" , "script" ]]], "" ,[ "coalesce" ,[ "get" , "pgf:name" ],[ "get" , "name" ]]],{ "text-font" : [ "case" ,[ "==" ,[ "get" , "script" ], "Devanagari" ],[ "literal" ,[ "Noto Sans Devanagari Regular v1" ]],[ "literal" ,[ i || "Noto Sans Regular" ]]]}],[ "get" , "name:en" ]],[ "format" ,[ "coalesce" ,[ "get" , ` ${ a } name: ${ e } ` ],[ "get" , "pgf:name" ],[ "get" , "name" ]], Si ( r )]],[ "all" ,[ "any" ,[ "has" , "name" ],[ "has" , "pgf:name" ]],[ "any" ,[ "has" , "name2" ],[ "has" , "pgf:name2" ]],[ "!" ,[ "any" ,[ "has" , "name3" ],[ "has" , "pgf:name3" ]]]],[ "case" ,[ "all" , Ui ( e , r , "name" ), Ui ( e , r , "name2" )],[ "format" ,[ "get" , ` ${ a } name: ${ e } ` ], Si ( r ), `
` ,{},... Gt ( "name" , i ), `
` ,{},... Gt ( "name2" , i )],[ "case" , Ui ( e , r , "name2" ),[ "format" ,[ "coalesce" ,[ "get" , ` ${ a } name: ${ e } ` ],[ "get" , "pgf:name" ],[ "get" , "name" ]], Si ( r ), `
` ,{},... Gt ( "name2" , i )],[ "format" ,[ "coalesce" ,[ "get" , ` ${ a } name: ${ e } ` ],[ "get" , "pgf:name2" ],[ "get" , "name2" ]], Si ( r ), `
` ,{},... Gt ( "name" , i )]]],[ "case" ,[ "all" , Ui ( e , r , "name" ), Ui ( e , r , "name2" ), Ui ( e , r , "name3" )],[ "format" ,[ "get" , ` ${ a } name: ${ e } ` ], Si ( r ), `
` ,{},... Gt ( "name" , i ), `
` ,{},... Gt ( "name2" , i ), `
` ,{},... Gt ( "name3" , i )],[ "case" ,[ "!" , Ui ( e , r , "name" )],[ "format" ,[ "coalesce" ,[ "get" , ` ${ a } name: ${ e } ` ],[ "get" , "pgf:name" ],[ "get" , "name" ]], Si ( r ), `
` ,{},... Gt ( "name2" , i ), `
` ,{},... Gt ( "name3" , i )],[ "!" , Ui ( e , r , "name2" )],[ "format" ,[ "coalesce" ,[ "get" , ` ${ a } name: ${ e } ` ],[ "get" , "pgf:name2" ],[ "get" , "name2" ]], Si ( r ), `
` ,{},... Gt ( "name" , i ), `
` ,{},... Gt ( "name3" , i )],[ "format" ,[ "coalesce" ,[ "get" , ` ${ a } name: ${ e } ` ],[ "get" , "pgf:name3" ],[ "get" , "name3" ]], Si ( r ), `
` ,{},... Gt ( "name" , i ), `
2026-10-19 07:27:48 +08:00
` ,{},... Gt ( "name2" , i )]]]]} er ( Ti , "get_multiline_name" ); var b6 = [{ lang : "ar" , full_name : "Arabic" , script : "Arabic" },{ lang : "cs" , full_name : "Czech" , script : "Latin" },{ lang : "bg" , full_name : "Bulgarian" , script : "Cyrillic" },{ lang : "da" , full_name : "Danish" , script : "Latin" },{ lang : "de" , full_name : "German" , script : "Latin" },{ lang : "el" , full_name : "Greek" , script : "Greek" },{ lang : "en" , full_name : "English" , script : "Latin" },{ lang : "es" , full_name : "Spanish" , script : "Latin" },{ lang : "et" , full_name : "Estonian" , script : "Latin" },{ lang : "fa" , full_name : "Persian" , script : "Arabic" },{ lang : "fi" , full_name : "Finnish" , script : "Latin" },{ lang : "fr" , full_name : "French" , script : "Latin" },{ lang : "ga" , full_name : "Irish" , script : "Latin" },{ lang : "he" , full_name : "Hebrew" , script : "Hebrew" },{ lang : "hi" , full_name : "Hindi" , script : "Devanagari" },{ lang : "hr" , full_name : "Croatian" , script : "Latin" },{ lang : "hu" , full_name : "Hungarian" , script : "Latin" },{ lang : "id" , full_name : "Indonesian" , script : "Latin" },{ lang : "it" , full_name : "Italian" , script : "Latin" },{ lang : "ja" , full_name : "Japanese" , script : "" },{ lang : "ko" , full_name : "Korean" , script : "Hangul" },{ lang : "lt" , full_name : "Lithuanian" , script : "Latin" },{ lang : "lv" , full_name : "Latvian" , script : "Latin" },{ lang : "ne" , full_name : "Nepali" , script : "Devanagari" },{ lang : "nl" , full_name : "Dutch" , script : "Latin" },{ lang : "no" , full_name : "Norwegian" , script : "Latin" },{ lang : "mr" , full_name : "Marathi" , script : "Devanagari" },{ lang : "mt" , full_name : "Maltese" , script : "Latin" },{ lang : "pl" , full_name : "Polish" , script : "Latin" },{ lang : "pt" , full_name : "Portuguese" , script : "Latin" },{ lang : "ro" , full_name : "Romanian" , script : "Latin" },{ lang : "ru" , full_name : "Russian" , script : "Cyrillic" },{ lang : "sk" , full_name : "Slovak" , script : "Latin" },{ lang : "sl" , full_name : "Slovenian" , script : "Latin" },{ lang : "sv" , full_name : "Swedish" , script : "Latin" },{ lang : "tr" , full_name : "Turkish" , script : "Latin" },{ lang : "uk" , full_name : "Ukrainian" , script : "Cyrillic" },{ lang : "ur" , full_name : "Urdu" , script : "Arabic" },{ lang : "vi" , full_name : "Vietnamese" , script : "Latin" },{ lang : "zh-Hans" , full_name : "Chinese (Simplified)" , script : "Han" },{ lang : "zh-Hant" , full_name : "Chinese (Traditional)" , script : "Han" }]; function Ix ( e , t ){ return [{ id : "background" , type : "background" , paint : { "background-color" : t . background }},{ id : "earth" , type : "fill" , filter : [ "==" , "$type" , "Polygon" ], source : e , "source-layer" : "earth" , paint : { "fill-color" : t . earth }},... t . landcover ? [{ id : "landcover" , type : "fill" , source : e , "source-layer" : "landcover" , paint : { "fill-color" : [ "match" ,[ "get" , "kind" ], "grassland" , t . landcover . grassland , "barren" , t . landcover . barren , "urban_area" , t . landcover . urban_area , "farmland" , t . landcover . farmland , "glacier" , t . landcover . glacier , "scrub" , t . landcover . scrub , t . landcover . forest ], "fill-opacity" : [ "interpolate" ,[ "linear" ],[ "zoom" ], 5 , 1 , 7 , 0 ]}}] : [],{ id : "landuse_park" , type : "fill" , source : e , "source-layer" : "landuse" , filter : [ "in" , "kind" , "national_park" , "park" , "cemetery" , "protected_area" , "nature_reserve" , "forest" , "golf_course" , "wood" , "scrub" , "grassland" , "grass" , "glacier" , "sand" , "military" , "naval_base" , "airfield" ], paint : { "fill-opacity" : [ "interpolate" ,[ "linear" ],[ "zoom" ], 6 , 0 , 11 , 1 ], "fill-color" : [ "case" ,[ "in" ,[ "get" , "kind" ],[ "literal" ,[ "national_park" , "park" , "cemetery" , "protected_area" , "nature_reserve" , "forest" , "golf_course" ]]], t . park_b ,[ "==" ,[ "get" , "kind" ], "wood" ], t . wood_b ,[ "in" ,[ "get" , "kind" ],[ "literal" ,[ "scrub" , "grassland" , "grass" ]]], t . scrub_b ,[ "==" ,[ "get" , "kind" ], "glacier" ], t . glacier ,[ "==" ,[ "get" , "kind" ], "sand" ], t . sand ,[ "in" ,[ "get" , "kind" ],[ "literal" ,[ "military" , "naval_base" , "airfield" ]]], t . zoo , t . earth ]}},{ id : "landuse_urban_green" , type : "fill" , source : e , "source-layer" : "landuse" , filter : [ "in" , "kind" , "allotments" , "village_green" , "playground" ], paint : { "fill-color" : t . park_b , "fill-opacity" : . 7 }},{ id : "landuse_hospital" , type : "fill" , source : e , "source-layer" : "landuse" , filter : [ "==" , "kind" , "hospital" ], paint : { "fill-color" : t . hospital }},{ id : "landuse_industrial" , type : "fill" , source : e , "source-layer" : "landuse" , filter : [ "==" , "kind" , "industrial" ], paint : { "fill-color" : t . industrial }},{ id : "landuse_school" , type : "fill" , source : e , "source-layer" : "landuse" , filter : [ "in" , "kind" , "school" , "university" , "college" ], paint : { "fill-color" : t . school }},{ id : "landuse_beach" , type : "fill" , source : e , "source-layer" :