@@ -52,7 +52,9 @@ uniform bool u_is_size_feature_constant;
5252uniform highp float u_size_t; // used to interpolate between zoom stops when size is a composite function
5353uniform highp float u_size; // used when size is both zoom and feature constant
5454uniform mat4 u_matrix;
55+ #ifdef RENDER_SHADOWS
5556uniform mat4 u_inv_matrix;
57+ #endif
5658uniform mat4 u_label_plane_matrix;
5759uniform mat4 u_coord_matrix;
5860uniform bool u_is_text;
@@ -63,9 +65,15 @@ uniform highp float u_aspect_ratio;
6365uniform highp float u_camera_to_center_distance;
6466uniform float u_fade_change;
6567uniform vec2 u_texsize;
68+ #ifdef PROJECTION_GLOBE_VIEW
6669uniform vec3 u_up_vector;
70+ #endif
71+ #ifdef RENDER_TEXT_AND_SYMBOL
6772uniform vec2 u_texsize_icon;
73+ #endif
74+ #ifdef RENDER_SDF
6875uniform bool u_is_halo;
76+ #endif
6977
7078#ifdef PROJECTION_GLOBE_VIEW
7179uniform vec3 u_tile_id;
@@ -82,7 +90,9 @@ out vec2 v_tex_a;
8290out vec2 v_tex_b;
8391#endif
8492
93+ #ifdef RENDER_SDF
8594out float v_draw_halo;
95+ #endif
8696out vec3 v_gamma_scale_size_fade_opacity;
8797#ifdef RENDER_TEXT_AND_SYMBOL
8898out float is_sdf;
@@ -116,13 +126,17 @@ out highp float v_depth;
116126
117127// / Paint properties for a symbol layer.
118128struct SymbolPaintProperties {
129+ #ifdef RENDER_SDF
119130 // / Non-premultiplied render fill color.
120131 vec4 fill_np_color;
121132 // / Non-premultiplied render halo color.
122133 vec4 halo_np_color;
134+ #endif
123135 float opacity;
136+ #ifdef RENDER_SDF
124137 float halo_width;
125138 float halo_blur;
139+ #endif
126140 float emissive_strength;
127141 float occlusion_opacity;
128142 float z_offset;
@@ -155,35 +169,47 @@ struct SymbolPropertyHeader {
155169 // / Size of the data-driven block should be aligned to vec4.
156170 uint dataDrivenBlockSizeVec4;
157171 // / Property types and aligned block offsets for each property.
172+ #ifdef RENDER_SDF
158173 PropertyType fill_np_color;
159174 PropertyType halo_np_color;
175+ #endif
160176 PropertyType opacity;
177+ #ifdef RENDER_SDF
161178 PropertyType halo_width;
162179 PropertyType halo_blur;
180+ #endif
163181 PropertyType emissive_strength;
164182 PropertyType occlusion_opacity;
165183 PropertyType z_offset;
166184 PropertyType translate;
167185};
168186
169187// / Constant paint properties values shared for all features.
188+ #ifdef RENDER_SDF
170189uniform lowp vec4 u_spp_fill_np_color;
171190uniform lowp vec4 u_spp_halo_np_color;
191+ #endif
172192uniform lowp float u_spp_opacity;
193+ #ifdef RENDER_SDF
173194uniform lowp float u_spp_halo_width;
174195uniform lowp float u_spp_halo_blur;
196+ #endif
175197uniform lowp float u_spp_emissive_strength;
176198uniform lowp float u_spp_occlusion_opacity;
177199uniform highp float u_spp_z_offset;
178200// / [cos(angle), sin(angle)] for translate-anchor rotation; [1,0] = no rotation (viewport anchor).
179201uniform lowp vec2 u_spp_translate_rotation;
180202
181203// / Per-property zoom interpolation factor. Only meaningful for zoom-dependent properties.
204+ #ifdef RENDER_SDF
182205uniform highp float u_spp_fill_color_zoom_factor;
183206uniform highp float u_spp_halo_color_zoom_factor;
207+ #endif
184208uniform highp float u_spp_opacity_zoom_factor;
209+ #ifdef RENDER_SDF
185210uniform highp float u_spp_halo_width_zoom_factor;
186211uniform highp float u_spp_halo_blur_zoom_factor;
212+ #endif
187213uniform highp float u_spp_emissive_strength_zoom_factor;
188214uniform highp float u_spp_occlusion_opacity_zoom_factor;
189215uniform highp float u_spp_z_offset_zoom_factor;
@@ -216,12 +242,14 @@ layout(std140) uniform SymbolPaintPropertiesIndexUniform {
216242
217243// / Symbol paint properties need to be interpolated and passed to the fragment shader.
218244out lowp float v_opacity;
245+
219246#ifdef RENDER_SDF
220247out lowp vec4 v_fill_np_color;
221248out lowp vec4 v_halo_np_color;
222249out lowp float v_halo_width;
223250out lowp float v_halo_blur;
224251#endif
252+
225253#ifdef LIGHTING_3D_MODE
226254out lowp float v_emissive_strength;
227255#endif
@@ -240,11 +268,19 @@ SymbolPropertyHeader readSymbolPropertiesHeader() {
240268 uint dataDrivenMask = u_spp_header.header[0 ][0 ];
241269 uint zoomDependentMask = u_spp_header.header[0 ][1 ];
242270 header.dataDrivenBlockSizeVec4 = u_spp_header.header[0 ][2 ];
271+
272+ #ifdef RENDER_SDF
243273 header.fill_np_color = getPropertyType(0u, dataDrivenMask, zoomDependentMask, u_spp_header.header[0 ][3 ], u_spp_fill_color_zoom_factor);
244274 header.halo_np_color = getPropertyType(1u, dataDrivenMask, zoomDependentMask, u_spp_header.header[1 ][0 ], u_spp_halo_color_zoom_factor);
275+ #endif
276+
245277 header.opacity = getPropertyType(2u, dataDrivenMask, zoomDependentMask, u_spp_header.header[1 ][1 ], u_spp_opacity_zoom_factor);
278+
279+ #ifdef RENDER_SDF
246280 header.halo_width = getPropertyType(3u, dataDrivenMask, zoomDependentMask, u_spp_header.header[1 ][2 ], u_spp_halo_width_zoom_factor);
247281 header.halo_blur = getPropertyType(4u, dataDrivenMask, zoomDependentMask, u_spp_header.header[1 ][3 ], u_spp_halo_blur_zoom_factor);
282+ #endif
283+
248284 header.emissive_strength = getPropertyType(5u, dataDrivenMask, zoomDependentMask, u_spp_header.header[2 ][0 ], u_spp_emissive_strength_zoom_factor);
249285 header.occlusion_opacity = getPropertyType(6u, dataDrivenMask, zoomDependentMask, u_spp_header.header[2 ][1 ], u_spp_occlusion_opacity_zoom_factor);
250286 header.z_offset = getPropertyType(7u, dataDrivenMask, zoomDependentMask, u_spp_header.header[2 ][2 ], u_spp_z_offset_zoom_factor);
@@ -298,6 +334,7 @@ uint getDataDrivenBlockOffsetVec4(uint dataDrivenBlockSizeVec4) {
298334 return blockIndex * dataDrivenBlockSizeVec4;
299335}
300336
337+ #ifdef RENDER_SDF
301338// / Read a color property from the UBO.
302339// / Non-zoom: vec4 at offsetDwords = [RG, BA, pad, pad]; decode packed vec2.
303340// / Zoom-dep: vec4 at offsetDwords = [minRG, minBA, maxRG, maxBA]; mix via the property's
@@ -313,6 +350,7 @@ vec4 readColorProperty(PropertyType propertyType, uint dataDrivenBlockSizeVec4)
313350 }
314351 return color;
315352}
353+ #endif
316354
317355// / Read a vec2 property (translate) from the UBO.
318356// / Non-zoom: 2 consecutive floats [tx, ty] within the same vec4 (offset%4 <= 2).
@@ -348,11 +386,19 @@ SymbolPaintProperties readSymbolPaintProperties() {
348386 SymbolPropertyHeader header = readSymbolPropertiesHeader();
349387 uint sizeVec4 = header.dataDrivenBlockSizeVec4;
350388 SymbolPaintProperties props;
389+
390+ #ifdef RENDER_SDF
351391 props.fill_np_color = header.fill_np_color.isDataDriven ? readColorProperty(header.fill_np_color, sizeVec4) : u_spp_fill_np_color;
352392 props.halo_np_color = header.halo_np_color.isDataDriven ? readColorProperty(header.halo_np_color, sizeVec4) : u_spp_halo_np_color;
393+ #endif
394+
353395 props.opacity = header.opacity.isDataDriven ? readFloatProperty(header.opacity, sizeVec4) : u_spp_opacity;
396+
397+ #ifdef RENDER_SDF
354398 props.halo_width = header.halo_width.isDataDriven ? readFloatProperty(header.halo_width, sizeVec4) : u_spp_halo_width;
355399 props.halo_blur = header.halo_blur.isDataDriven ? readFloatProperty(header.halo_blur, sizeVec4) : u_spp_halo_blur;
400+ #endif
401+
356402 props.emissive_strength = header.emissive_strength.isDataDriven ? readFloatProperty(header.emissive_strength, sizeVec4) : u_spp_emissive_strength;
357403 props.occlusion_opacity = header.occlusion_opacity.isDataDriven ? readFloatProperty(header.occlusion_opacity, sizeVec4) : u_spp_occlusion_opacity;
358404 props.z_offset = header.z_offset.isDataDriven ? readFloatProperty(header.z_offset, sizeVec4) : u_spp_z_offset;
@@ -369,12 +415,14 @@ void main() {
369415 SymbolPaintProperties paint_properties = readSymbolPaintProperties();
370416 lowp float opacity = paint_properties.opacity;
371417 v_opacity = opacity;
418+
372419#ifdef RENDER_SDF
373420 v_fill_np_color = paint_properties.fill_np_color;
374421 v_halo_np_color = paint_properties.halo_np_color;
375422 v_halo_width = paint_properties.halo_width;
376423 v_halo_blur = paint_properties.halo_blur;
377424#endif
425+
378426#ifdef LIGHTING_3D_MODE
379427 v_emissive_strength = paint_properties.emissive_strength;
380428#endif
@@ -568,7 +616,9 @@ void main() {
568616 float gamma_scale = gl_Position .w;
569617
570618 // Cast to float is required to fix a rendering error in Swiftshader
619+ #ifdef RENDER_SDF
571620 v_draw_halo = (u_is_halo && float (gl_InstanceID ) == 0.0 ) ? 1.0 : 0.0 ;
621+ #endif
572622
573623 v_gamma_scale_size_fade_opacity = vec3 (gamma_scale, size, out_fade_opacity);
574624 v_tex_a = a_tex / u_texsize;
0 commit comments