summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2017-06-04 15:43:27 +0200
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-06-13 12:21:50 -0700
commit2cbc3d3332e32054e9fdc5323fef8e98f5f99a79 (patch)
tree05f2564ff02eeccc6b27e567df20daca5ca425bb
parent978363a47f3c15aa4f3ac42bd63d5f65a4f827b0 (diff)
downloadqtlocation-mapboxgl-2cbc3d3332e32054e9fdc5323fef8e98f5f99a79.tar.gz
[core] add shader defines for enabling/disabling attributes/uniforms for DDS
-rwxr-xr-xscripts/generate-shaders.js49
-rw-r--r--src/mbgl/shaders/circle.cpp140
-rw-r--r--src/mbgl/shaders/fill.cpp40
-rw-r--r--src/mbgl/shaders/fill_extrusion.cpp60
-rw-r--r--src/mbgl/shaders/fill_extrusion_pattern.cpp40
-rw-r--r--src/mbgl/shaders/fill_outline.cpp40
-rw-r--r--src/mbgl/shaders/fill_outline_pattern.cpp20
-rw-r--r--src/mbgl/shaders/fill_pattern.cpp20
-rw-r--r--src/mbgl/shaders/line.cpp80
-rw-r--r--src/mbgl/shaders/line_pattern.cpp60
-rw-r--r--src/mbgl/shaders/line_sdf.cpp80
-rw-r--r--src/mbgl/shaders/symbol_icon.cpp20
-rw-r--r--src/mbgl/shaders/symbol_sdf.cpp100
13 files changed, 708 insertions, 41 deletions
diff --git a/scripts/generate-shaders.js b/scripts/generate-shaders.js
index 2813d27365..159817f62f 100755
--- a/scripts/generate-shaders.js
+++ b/scripts/generate-shaders.js
@@ -69,21 +69,52 @@ ${fragmentPrelude}
fragmentSource = fragmentSource.replace(re, (match, operation, precision, type, name) => {
fragmentPragmas.add(name);
- return operation === "define" ?
- `varying ${precision} ${type} ${name};` :
- ``;
+ return operation === "define" ? `
+#ifndef HAS_UNIFORM_u_${name}
+varying ${precision} ${type} ${name};
+#else
+uniform ${precision} ${type} u_${name};
+#endif
+` : `
+#ifdef HAS_UNIFORM_u_${name}
+ ${precision} ${type} ${name} = u_${name};
+#endif
+`;
});
vertexSource = vertexSource.replace(re, (match, operation, precision, type, name) => {
const a_type = type === "float" ? "vec2" : "vec4";
if (fragmentPragmas.has(name)) {
- return operation === "define" ?
- `uniform lowp float a_${name}_t;\nattribute ${precision} ${a_type} a_${name};\nvarying ${precision} ${type} ${name};` :
- `${name} = unpack_mix_${a_type}(a_${name}, a_${name}_t);`;
+ return operation === "define" ? `
+#ifdef HAS_UNIFORM_u_${name}
+uniform lowp float a_${name}_t;
+attribute ${precision} ${a_type} a_${name};
+varying ${precision} ${type} ${name};
+#else
+uniform ${precision} ${type} u_${name};
+#endif
+` : `
+#ifndef HAS_UNIFORM_u_${name}
+ ${name} = unpack_mix_${a_type}(a_${name}, a_${name}_t);
+#else
+ ${precision} ${type} ${name} = u_${name};
+#endif
+`;
} else {
- return operation === "define" ?
- `uniform lowp float a_${name}_t;\nattribute ${precision} ${a_type} a_${name};` :
- `${precision} ${type} ${name} = unpack_mix_${a_type}(a_${name}, a_${name}_t);`;
+ return operation === "define" ? `
+#ifdef HAS_UNIFORM_u_${name}
+uniform lowp float a_${name}_t;
+attribute ${precision} ${a_type} a_${name};
+#else
+uniform ${precision} ${type} u_${name};
+#endif
+` : `
+#ifndef HAS_UNIFORM_u_${name}
+ ${precision} ${type} ${name} = unpack_mix_${a_type}(a_${name}, a_${name}_t);
+#else
+ ${precision} ${type} ${name} = u_${name};
+#endif
+`;
}
});
diff --git a/src/mbgl/shaders/circle.cpp b/src/mbgl/shaders/circle.cpp
index 2ecceeca70..2e0c76122c 100644
--- a/src/mbgl/shaders/circle.cpp
+++ b/src/mbgl/shaders/circle.cpp
@@ -13,38 +13,108 @@ uniform vec2 u_extrude_scale;
attribute vec2 a_pos;
+
+#ifndef HAS_UNIFORM_u_color
uniform lowp float a_color_t;
attribute highp vec4 a_color;
varying highp vec4 color;
+#else
+uniform highp vec4 u_color;
+#endif
+
+#ifndef HAS_UNIFORM_u_radius
uniform lowp float a_radius_t;
attribute mediump vec2 a_radius;
varying mediump float radius;
+#else
+uniform mediump float u_radius;
+#endif
+
+#ifndef HAS_UNIFORM_u_blur
uniform lowp float a_blur_t;
attribute lowp vec2 a_blur;
varying lowp float blur;
+#else
+uniform lowp float u_blur;
+#endif
+
+#ifndef HAS_UNIFORM_u_opacity
uniform lowp float a_opacity_t;
attribute lowp vec2 a_opacity;
varying lowp float opacity;
+#else
+uniform lowp float u_opacity;
+#endif
+
+#ifndef HAS_UNIFORM_u_stroke_color
uniform lowp float a_stroke_color_t;
attribute highp vec4 a_stroke_color;
varying highp vec4 stroke_color;
+#else
+uniform highp vec4 u_stroke_color;
+#endif
+
+#ifndef HAS_UNIFORM_u_stroke_width
uniform lowp float a_stroke_width_t;
attribute mediump vec2 a_stroke_width;
varying mediump float stroke_width;
+#else
+uniform mediump float u_stroke_width;
+#endif
+
+#ifndef HAS_UNIFORM_u_stroke_opacity
uniform lowp float a_stroke_opacity_t;
attribute lowp vec2 a_stroke_opacity;
varying lowp float stroke_opacity;
+#else
+uniform lowp float u_stroke_opacity;
+#endif
varying vec3 v_data;
void main(void) {
+
+#ifndef HAS_UNIFORM_u_color
color = unpack_mix_vec4(a_color, a_color_t);
+#else
+ highp vec4 color = u_color;
+#endif
+
+#ifndef HAS_UNIFORM_u_radius
radius = unpack_mix_vec2(a_radius, a_radius_t);
+#else
+ mediump float radius = u_radius;
+#endif
+
+#ifndef HAS_UNIFORM_u_blur
blur = unpack_mix_vec2(a_blur, a_blur_t);
+#else
+ lowp float blur = u_blur;
+#endif
+
+#ifndef HAS_UNIFORM_u_opacity
opacity = unpack_mix_vec2(a_opacity, a_opacity_t);
+#else
+ lowp float opacity = u_opacity;
+#endif
+
+#ifndef HAS_UNIFORM_u_stroke_color
stroke_color = unpack_mix_vec4(a_stroke_color, a_stroke_color_t);
+#else
+ highp vec4 stroke_color = u_stroke_color;
+#endif
+
+#ifndef HAS_UNIFORM_u_stroke_width
stroke_width = unpack_mix_vec2(a_stroke_width, a_stroke_width_t);
+#else
+ mediump float stroke_width = u_stroke_width;
+#endif
+
+#ifndef HAS_UNIFORM_u_stroke_opacity
stroke_opacity = unpack_mix_vec2(a_stroke_opacity, a_stroke_opacity_t);
+#else
+ lowp float stroke_opacity = u_stroke_opacity;
+#endif
// unencode the extrusion vector that we snuck into the a_pos vector
vec2 extrude = vec2(mod(a_pos, 2.0) * 2.0 - 1.0);
@@ -69,24 +139,80 @@ void main(void) {
)MBGL_SHADER";
const char* circle::fragmentSource = R"MBGL_SHADER(
+
+#ifndef HAS_UNIFORM_u_color
varying highp vec4 color;
+#else
+uniform highp vec4 u_color;
+#endif
+
+#ifndef HAS_UNIFORM_u_radius
varying mediump float radius;
+#else
+uniform mediump float u_radius;
+#endif
+
+#ifndef HAS_UNIFORM_u_blur
varying lowp float blur;
+#else
+uniform lowp float u_blur;
+#endif
+
+#ifndef HAS_UNIFORM_u_opacity
varying lowp float opacity;
+#else
+uniform lowp float u_opacity;
+#endif
+
+#ifndef HAS_UNIFORM_u_stroke_color
varying highp vec4 stroke_color;
+#else
+uniform highp vec4 u_stroke_color;
+#endif
+
+#ifndef HAS_UNIFORM_u_stroke_width
varying mediump float stroke_width;
+#else
+uniform mediump float u_stroke_width;
+#endif
+
+#ifndef HAS_UNIFORM_u_stroke_opacity
varying lowp float stroke_opacity;
+#else
+uniform lowp float u_stroke_opacity;
+#endif
varying vec3 v_data;
void main() {
-
-
-
-
-
-
-
+
+#ifdef HAS_UNIFORM_u_color
+ highp vec4 color = u_color;
+#endif
+
+#ifdef HAS_UNIFORM_u_radius
+ mediump float radius = u_radius;
+#endif
+
+#ifdef HAS_UNIFORM_u_blur
+ lowp float blur = u_blur;
+#endif
+
+#ifdef HAS_UNIFORM_u_opacity
+ lowp float opacity = u_opacity;
+#endif
+
+#ifdef HAS_UNIFORM_u_stroke_color
+ highp vec4 stroke_color = u_stroke_color;
+#endif
+
+#ifdef HAS_UNIFORM_u_stroke_width
+ mediump float stroke_width = u_stroke_width;
+#endif
+
+#ifdef HAS_UNIFORM_u_stroke_opacity
+ lowp float stroke_opacity = u_stroke_opacity;
+#endif
vec2 extrude = v_data.xy;
float extrude_length = length(extrude);
diff --git a/src/mbgl/shaders/fill.cpp b/src/mbgl/shaders/fill.cpp
index 0b775273d2..8f5f304014 100644
--- a/src/mbgl/shaders/fill.cpp
+++ b/src/mbgl/shaders/fill.cpp
@@ -11,28 +11,64 @@ attribute vec2 a_pos;
uniform mat4 u_matrix;
+
+#ifndef HAS_UNIFORM_u_color
uniform lowp float a_color_t;
attribute highp vec4 a_color;
varying highp vec4 color;
+#else
+uniform highp vec4 u_color;
+#endif
+
+#ifndef HAS_UNIFORM_u_opacity
uniform lowp float a_opacity_t;
attribute lowp vec2 a_opacity;
varying lowp float opacity;
+#else
+uniform lowp float u_opacity;
+#endif
void main() {
+
+#ifndef HAS_UNIFORM_u_color
color = unpack_mix_vec4(a_color, a_color_t);
+#else
+ highp vec4 color = u_color;
+#endif
+
+#ifndef HAS_UNIFORM_u_opacity
opacity = unpack_mix_vec2(a_opacity, a_opacity_t);
+#else
+ lowp float opacity = u_opacity;
+#endif
gl_Position = u_matrix * vec4(a_pos, 0, 1);
}
)MBGL_SHADER";
const char* fill::fragmentSource = R"MBGL_SHADER(
+
+#ifndef HAS_UNIFORM_u_color
varying highp vec4 color;
+#else
+uniform highp vec4 u_color;
+#endif
+
+#ifndef HAS_UNIFORM_u_opacity
varying lowp float opacity;
+#else
+uniform lowp float u_opacity;
+#endif
void main() {
-
-
+
+#ifdef HAS_UNIFORM_u_color
+ highp vec4 color = u_color;
+#endif
+
+#ifdef HAS_UNIFORM_u_opacity
+ lowp float opacity = u_opacity;
+#endif
gl_FragColor = color * opacity;
diff --git a/src/mbgl/shaders/fill_extrusion.cpp b/src/mbgl/shaders/fill_extrusion.cpp
index ea1c80545e..ad14e4f32e 100644
--- a/src/mbgl/shaders/fill_extrusion.cpp
+++ b/src/mbgl/shaders/fill_extrusion.cpp
@@ -18,21 +18,51 @@ attribute float a_edgedistance;
varying vec4 v_color;
+
+#ifndef HAS_UNIFORM_u_base
uniform lowp float a_base_t;
attribute lowp vec2 a_base;
varying lowp float base;
+#else
+uniform lowp float u_base;
+#endif
+
+#ifndef HAS_UNIFORM_u_height
uniform lowp float a_height_t;
attribute lowp vec2 a_height;
varying lowp float height;
+#else
+uniform lowp float u_height;
+#endif
+
+#ifndef HAS_UNIFORM_u_color
uniform lowp float a_color_t;
attribute highp vec4 a_color;
varying highp vec4 color;
+#else
+uniform highp vec4 u_color;
+#endif
void main() {
+
+#ifndef HAS_UNIFORM_u_base
base = unpack_mix_vec2(a_base, a_base_t);
+#else
+ lowp float base = u_base;
+#endif
+
+#ifndef HAS_UNIFORM_u_height
height = unpack_mix_vec2(a_height, a_height_t);
+#else
+ lowp float height = u_height;
+#endif
+
+#ifndef HAS_UNIFORM_u_color
color = unpack_mix_vec4(a_color, a_color_t);
+#else
+ highp vec4 color = u_color;
+#endif
base = max(0.0, base);
height = max(0.0, height);
@@ -76,14 +106,38 @@ void main() {
)MBGL_SHADER";
const char* fill_extrusion::fragmentSource = R"MBGL_SHADER(
varying vec4 v_color;
+
+#ifndef HAS_UNIFORM_u_base
varying lowp float base;
+#else
+uniform lowp float u_base;
+#endif
+
+#ifndef HAS_UNIFORM_u_height
varying lowp float height;
+#else
+uniform lowp float u_height;
+#endif
+
+#ifndef HAS_UNIFORM_u_color
varying highp vec4 color;
+#else
+uniform highp vec4 u_color;
+#endif
void main() {
-
-
-
+
+#ifdef HAS_UNIFORM_u_base
+ lowp float base = u_base;
+#endif
+
+#ifdef HAS_UNIFORM_u_height
+ lowp float height = u_height;
+#endif
+
+#ifdef HAS_UNIFORM_u_color
+ highp vec4 color = u_color;
+#endif
gl_FragColor = v_color;
diff --git a/src/mbgl/shaders/fill_extrusion_pattern.cpp b/src/mbgl/shaders/fill_extrusion_pattern.cpp
index 49be73b713..2681973af6 100644
--- a/src/mbgl/shaders/fill_extrusion_pattern.cpp
+++ b/src/mbgl/shaders/fill_extrusion_pattern.cpp
@@ -30,16 +30,36 @@ varying vec2 v_pos_b;
varying vec4 v_lighting;
varying float v_directional;
+
+#ifndef HAS_UNIFORM_u_base
uniform lowp float a_base_t;
attribute lowp vec2 a_base;
varying lowp float base;
+#else
+uniform lowp float u_base;
+#endif
+
+#ifndef HAS_UNIFORM_u_height
uniform lowp float a_height_t;
attribute lowp vec2 a_height;
varying lowp float height;
+#else
+uniform lowp float u_height;
+#endif
void main() {
+
+#ifndef HAS_UNIFORM_u_base
base = unpack_mix_vec2(a_base, a_base_t);
+#else
+ lowp float base = u_base;
+#endif
+
+#ifndef HAS_UNIFORM_u_height
height = unpack_mix_vec2(a_height, a_height_t);
+#else
+ lowp float height = u_height;
+#endif
base = max(0.0, base);
height = max(0.0, height);
@@ -82,12 +102,28 @@ varying vec2 v_pos_a;
varying vec2 v_pos_b;
varying vec4 v_lighting;
+
+#ifndef HAS_UNIFORM_u_base
varying lowp float base;
+#else
+uniform lowp float u_base;
+#endif
+
+#ifndef HAS_UNIFORM_u_height
varying lowp float height;
+#else
+uniform lowp float u_height;
+#endif
void main() {
-
-
+
+#ifdef HAS_UNIFORM_u_base
+ lowp float base = u_base;
+#endif
+
+#ifdef HAS_UNIFORM_u_height
+ lowp float height = u_height;
+#endif
vec2 imagecoord = mod(v_pos_a, 1.0);
vec2 pos = mix(u_pattern_tl_a / u_texsize, u_pattern_br_a / u_texsize, imagecoord);
diff --git a/src/mbgl/shaders/fill_outline.cpp b/src/mbgl/shaders/fill_outline.cpp
index 91b5db49ba..18a4d8c0a8 100644
--- a/src/mbgl/shaders/fill_outline.cpp
+++ b/src/mbgl/shaders/fill_outline.cpp
@@ -14,16 +14,36 @@ uniform vec2 u_world;
varying vec2 v_pos;
+
+#ifndef HAS_UNIFORM_u_outline_color
uniform lowp float a_outline_color_t;
attribute highp vec4 a_outline_color;
varying highp vec4 outline_color;
+#else
+uniform highp vec4 u_outline_color;
+#endif
+
+#ifndef HAS_UNIFORM_u_opacity
uniform lowp float a_opacity_t;
attribute lowp vec2 a_opacity;
varying lowp float opacity;
+#else
+uniform lowp float u_opacity;
+#endif
void main() {
+
+#ifndef HAS_UNIFORM_u_outline_color
outline_color = unpack_mix_vec4(a_outline_color, a_outline_color_t);
+#else
+ highp vec4 outline_color = u_outline_color;
+#endif
+
+#ifndef HAS_UNIFORM_u_opacity
opacity = unpack_mix_vec2(a_opacity, a_opacity_t);
+#else
+ lowp float opacity = u_opacity;
+#endif
gl_Position = u_matrix * vec4(a_pos, 0, 1);
v_pos = (gl_Position.xy / gl_Position.w + 1.0) / 2.0 * u_world;
@@ -31,14 +51,30 @@ void main() {
)MBGL_SHADER";
const char* fill_outline::fragmentSource = R"MBGL_SHADER(
+
+#ifndef HAS_UNIFORM_u_outline_color
varying highp vec4 outline_color;
+#else
+uniform highp vec4 u_outline_color;
+#endif
+
+#ifndef HAS_UNIFORM_u_opacity
varying lowp float opacity;
+#else
+uniform lowp float u_opacity;
+#endif
varying vec2 v_pos;
void main() {
-
-
+
+#ifdef HAS_UNIFORM_u_outline_color
+ highp vec4 outline_color = u_outline_color;
+#endif
+
+#ifdef HAS_UNIFORM_u_opacity
+ lowp float opacity = u_opacity;
+#endif
float dist = length(v_pos - gl_FragCoord.xy);
float alpha = 1.0 - smoothstep(0.0, 1.0, dist);
diff --git a/src/mbgl/shaders/fill_outline_pattern.cpp b/src/mbgl/shaders/fill_outline_pattern.cpp
index 6ee1f4c696..68e69c2135 100644
--- a/src/mbgl/shaders/fill_outline_pattern.cpp
+++ b/src/mbgl/shaders/fill_outline_pattern.cpp
@@ -23,12 +23,22 @@ varying vec2 v_pos_a;
varying vec2 v_pos_b;
varying vec2 v_pos;
+
+#ifndef HAS_UNIFORM_u_opacity
uniform lowp float a_opacity_t;
attribute lowp vec2 a_opacity;
varying lowp float opacity;
+#else
+uniform lowp float u_opacity;
+#endif
void main() {
+
+#ifndef HAS_UNIFORM_u_opacity
opacity = unpack_mix_vec2(a_opacity, a_opacity_t);
+#else
+ lowp float opacity = u_opacity;
+#endif
gl_Position = u_matrix * vec4(a_pos, 0, 1);
@@ -53,10 +63,18 @@ varying vec2 v_pos_a;
varying vec2 v_pos_b;
varying vec2 v_pos;
+
+#ifndef HAS_UNIFORM_u_opacity
varying lowp float opacity;
+#else
+uniform lowp float u_opacity;
+#endif
void main() {
-
+
+#ifdef HAS_UNIFORM_u_opacity
+ lowp float opacity = u_opacity;
+#endif
vec2 imagecoord = mod(v_pos_a, 1.0);
vec2 pos = mix(u_pattern_tl_a / u_texsize, u_pattern_br_a / u_texsize, imagecoord);
diff --git a/src/mbgl/shaders/fill_pattern.cpp b/src/mbgl/shaders/fill_pattern.cpp
index a81339bb25..f6f9e2fbff 100644
--- a/src/mbgl/shaders/fill_pattern.cpp
+++ b/src/mbgl/shaders/fill_pattern.cpp
@@ -21,12 +21,22 @@ attribute vec2 a_pos;
varying vec2 v_pos_a;
varying vec2 v_pos_b;
+
+#ifndef HAS_UNIFORM_u_opacity
uniform lowp float a_opacity_t;
attribute lowp vec2 a_opacity;
varying lowp float opacity;
+#else
+uniform lowp float u_opacity;
+#endif
void main() {
+
+#ifndef HAS_UNIFORM_u_opacity
opacity = unpack_mix_vec2(a_opacity, a_opacity_t);
+#else
+ lowp float opacity = u_opacity;
+#endif
gl_Position = u_matrix * vec4(a_pos, 0, 1);
@@ -48,10 +58,18 @@ uniform sampler2D u_image;
varying vec2 v_pos_a;
varying vec2 v_pos_b;
+
+#ifndef HAS_UNIFORM_u_opacity
varying lowp float opacity;
+#else
+uniform lowp float u_opacity;
+#endif
void main() {
-
+
+#ifdef HAS_UNIFORM_u_opacity
+ lowp float opacity = u_opacity;
+#endif
vec2 imagecoord = mod(v_pos_a, 1.0);
vec2 pos = mix(u_pattern_tl_a / u_texsize, u_pattern_br_a / u_texsize, imagecoord);
diff --git a/src/mbgl/shaders/line.cpp b/src/mbgl/shaders/line.cpp
index e101cf6ee1..dce6046257 100644
--- a/src/mbgl/shaders/line.cpp
+++ b/src/mbgl/shaders/line.cpp
@@ -33,26 +33,76 @@ varying vec2 v_normal;
varying vec2 v_width2;
varying float v_gamma_scale;
+
+#ifndef HAS_UNIFORM_u_color
uniform lowp float a_color_t;
attribute highp vec4 a_color;
varying highp vec4 color;
+#else
+uniform highp vec4 u_color;
+#endif
+
+#ifndef HAS_UNIFORM_u_blur
uniform lowp float a_blur_t;
attribute lowp vec2 a_blur;
varying lowp float blur;
+#else
+uniform lowp float u_blur;
+#endif
+
+#ifndef HAS_UNIFORM_u_opacity
uniform lowp float a_opacity_t;
attribute lowp vec2 a_opacity;
varying lowp float opacity;
+#else
+uniform lowp float u_opacity;
+#endif
+
+#ifndef HAS_UNIFORM_u_gapwidth
uniform lowp float a_gapwidth_t;
attribute mediump vec2 a_gapwidth;
+#else
+uniform mediump float u_gapwidth;
+#endif
+
+#ifndef HAS_UNIFORM_u_offset
uniform lowp float a_offset_t;
attribute lowp vec2 a_offset;
+#else
+uniform lowp float u_offset;
+#endif
void main() {
+
+#ifndef HAS_UNIFORM_u_color
color = unpack_mix_vec4(a_color, a_color_t);
+#else
+ highp vec4 color = u_color;
+#endif
+
+#ifndef HAS_UNIFORM_u_blur
blur = unpack_mix_vec2(a_blur, a_blur_t);
+#else
+ lowp float blur = u_blur;
+#endif
+
+#ifndef HAS_UNIFORM_u_opacity
opacity = unpack_mix_vec2(a_opacity, a_opacity_t);
+#else
+ lowp float opacity = u_opacity;
+#endif
+
+#ifndef HAS_UNIFORM_u_gapwidth
mediump float gapwidth = unpack_mix_vec2(a_gapwidth, a_gapwidth_t);
+#else
+ mediump float gapwidth = u_gapwidth;
+#endif
+
+#ifndef HAS_UNIFORM_u_offset
lowp float offset = unpack_mix_vec2(a_offset, a_offset_t);
+#else
+ lowp float offset = u_offset;
+#endif
vec2 a_extrude = a_data.xy - 128.0;
float a_direction = mod(a_data.z, 4.0) - 1.0;
@@ -103,18 +153,42 @@ void main() {
)MBGL_SHADER";
const char* line::fragmentSource = R"MBGL_SHADER(
+
+#ifndef HAS_UNIFORM_u_color
varying highp vec4 color;
+#else
+uniform highp vec4 u_color;
+#endif
+
+#ifndef HAS_UNIFORM_u_blur
varying lowp float blur;
+#else
+uniform lowp float u_blur;
+#endif
+
+#ifndef HAS_UNIFORM_u_opacity
varying lowp float opacity;
+#else
+uniform lowp float u_opacity;
+#endif
varying vec2 v_width2;
varying vec2 v_normal;
varying float v_gamma_scale;
void main() {
-
-
-
+
+#ifdef HAS_UNIFORM_u_color
+ highp vec4 color = u_color;
+#endif
+
+#ifdef HAS_UNIFORM_u_blur
+ lowp float blur = u_blur;
+#endif
+
+#ifdef HAS_UNIFORM_u_opacity
+ lowp float opacity = u_opacity;
+#endif
// Calculate the distance of the pixel from the line in pixels.
float dist = length(v_normal) * v_width2.s;
diff --git a/src/mbgl/shaders/line_pattern.cpp b/src/mbgl/shaders/line_pattern.cpp
index a413d98e9f..ded4c76825 100644
--- a/src/mbgl/shaders/line_pattern.cpp
+++ b/src/mbgl/shaders/line_pattern.cpp
@@ -36,22 +36,62 @@ varying vec2 v_width2;
varying float v_linesofar;
varying float v_gamma_scale;
+
+#ifndef HAS_UNIFORM_u_blur
uniform lowp float a_blur_t;
attribute lowp vec2 a_blur;
varying lowp float blur;
+#else
+uniform lowp float u_blur;
+#endif
+
+#ifndef HAS_UNIFORM_u_opacity
uniform lowp float a_opacity_t;
attribute lowp vec2 a_opacity;
varying lowp float opacity;
+#else
+uniform lowp float u_opacity;
+#endif
+
+#ifndef HAS_UNIFORM_u_offset
uniform lowp float a_offset_t;
attribute lowp vec2 a_offset;
+#else
+uniform lowp float u_offset;
+#endif
+
+#ifndef HAS_UNIFORM_u_gapwidth
uniform lowp float a_gapwidth_t;
attribute mediump vec2 a_gapwidth;
+#else
+uniform mediump float u_gapwidth;
+#endif
void main() {
+
+#ifndef HAS_UNIFORM_u_blur
blur = unpack_mix_vec2(a_blur, a_blur_t);
+#else
+ lowp float blur = u_blur;
+#endif
+
+#ifndef HAS_UNIFORM_u_opacity
opacity = unpack_mix_vec2(a_opacity, a_opacity_t);
+#else
+ lowp float opacity = u_opacity;
+#endif
+
+#ifndef HAS_UNIFORM_u_offset
lowp float offset = unpack_mix_vec2(a_offset, a_offset_t);
+#else
+ lowp float offset = u_offset;
+#endif
+
+#ifndef HAS_UNIFORM_u_gapwidth
mediump float gapwidth = unpack_mix_vec2(a_gapwidth, a_gapwidth_t);
+#else
+ mediump float gapwidth = u_gapwidth;
+#endif
vec2 a_extrude = a_data.xy - 128.0;
float a_direction = mod(a_data.z, 4.0) - 1.0;
@@ -119,12 +159,28 @@ varying vec2 v_width2;
varying float v_linesofar;
varying float v_gamma_scale;
+
+#ifndef HAS_UNIFORM_u_blur
varying lowp float blur;
+#else
+uniform lowp float u_blur;
+#endif
+
+#ifndef HAS_UNIFORM_u_opacity
varying lowp float opacity;
+#else
+uniform lowp float u_opacity;
+#endif
void main() {
-
-
+
+#ifdef HAS_UNIFORM_u_blur
+ lowp float blur = u_blur;
+#endif
+
+#ifdef HAS_UNIFORM_u_opacity
+ lowp float opacity = u_opacity;
+#endif
// Calculate the distance of the pixel from the line in pixels.
float dist = length(v_normal) * v_width2.s;
diff --git a/src/mbgl/shaders/line_sdf.cpp b/src/mbgl/shaders/line_sdf.cpp
index 4f6cf814f9..b37bf688d4 100644
--- a/src/mbgl/shaders/line_sdf.cpp
+++ b/src/mbgl/shaders/line_sdf.cpp
@@ -41,26 +41,76 @@ varying vec2 v_tex_a;
varying vec2 v_tex_b;
varying float v_gamma_scale;
+
+#ifndef HAS_UNIFORM_u_color
uniform lowp float a_color_t;
attribute highp vec4 a_color;
varying highp vec4 color;
+#else
+uniform highp vec4 u_color;
+#endif
+
+#ifndef HAS_UNIFORM_u_blur
uniform lowp float a_blur_t;
attribute lowp vec2 a_blur;
varying lowp float blur;
+#else
+uniform lowp float u_blur;
+#endif
+
+#ifndef HAS_UNIFORM_u_opacity
uniform lowp float a_opacity_t;
attribute lowp vec2 a_opacity;
varying lowp float opacity;
+#else
+uniform lowp float u_opacity;
+#endif
+
+#ifndef HAS_UNIFORM_u_gapwidth
uniform lowp float a_gapwidth_t;
attribute mediump vec2 a_gapwidth;
+#else
+uniform mediump float u_gapwidth;
+#endif
+
+#ifndef HAS_UNIFORM_u_offset
uniform lowp float a_offset_t;
attribute lowp vec2 a_offset;
+#else
+uniform lowp float u_offset;
+#endif
void main() {
+
+#ifndef HAS_UNIFORM_u_color
color = unpack_mix_vec4(a_color, a_color_t);
+#else
+ highp vec4 color = u_color;
+#endif
+
+#ifndef HAS_UNIFORM_u_blur
blur = unpack_mix_vec2(a_blur, a_blur_t);
+#else
+ lowp float blur = u_blur;
+#endif
+
+#ifndef HAS_UNIFORM_u_opacity
opacity = unpack_mix_vec2(a_opacity, a_opacity_t);
+#else
+ lowp float opacity = u_opacity;
+#endif
+
+#ifndef HAS_UNIFORM_u_gapwidth
mediump float gapwidth = unpack_mix_vec2(a_gapwidth, a_gapwidth_t);
+#else
+ mediump float gapwidth = u_gapwidth;
+#endif
+
+#ifndef HAS_UNIFORM_u_offset
lowp float offset = unpack_mix_vec2(a_offset, a_offset_t);
+#else
+ lowp float offset = u_offset;
+#endif
vec2 a_extrude = a_data.xy - 128.0;
float a_direction = mod(a_data.z, 4.0) - 1.0;
@@ -125,14 +175,38 @@ varying vec2 v_tex_a;
varying vec2 v_tex_b;
varying float v_gamma_scale;
+
+#ifndef HAS_UNIFORM_u_color
varying highp vec4 color;
+#else
+uniform highp vec4 u_color;
+#endif
+
+#ifndef HAS_UNIFORM_u_blur
varying lowp float blur;
+#else
+uniform lowp float u_blur;
+#endif
+
+#ifndef HAS_UNIFORM_u_opacity
varying lowp float opacity;
+#else
+uniform lowp float u_opacity;
+#endif
void main() {
-
-
-
+
+#ifdef HAS_UNIFORM_u_color
+ highp vec4 color = u_color;
+#endif
+
+#ifdef HAS_UNIFORM_u_blur
+ lowp float blur = u_blur;
+#endif
+
+#ifdef HAS_UNIFORM_u_opacity
+ lowp float opacity = u_opacity;
+#endif
// Calculate the distance of the pixel from the line in pixels.
float dist = length(v_normal) * v_width2.s;
diff --git a/src/mbgl/shaders/symbol_icon.cpp b/src/mbgl/shaders/symbol_icon.cpp
index b6fbed428e..bc570cf361 100644
--- a/src/mbgl/shaders/symbol_icon.cpp
+++ b/src/mbgl/shaders/symbol_icon.cpp
@@ -19,9 +19,14 @@ uniform mediump float u_size_t; // used to interpolate between zoom stops when s
uniform mediump float u_size; // used when size is both zoom and feature constant
uniform mediump float u_layout_size; // used when size is feature constant
+
+#ifndef HAS_UNIFORM_u_opacity
uniform lowp float a_opacity_t;
attribute lowp vec2 a_opacity;
varying lowp float opacity;
+#else
+uniform lowp float u_opacity;
+#endif
// matrix is for the vertex position.
uniform mat4 u_matrix;
@@ -37,7 +42,12 @@ varying vec2 v_tex;
varying vec2 v_fade_tex;
void main() {
+
+#ifndef HAS_UNIFORM_u_opacity
opacity = unpack_mix_vec2(a_opacity, a_opacity_t);
+#else
+ lowp float opacity = u_opacity;
+#endif
vec2 a_pos = a_pos_offset.xy;
vec2 a_offset = a_pos_offset.zw;
@@ -97,13 +107,21 @@ const char* symbol_icon::fragmentSource = R"MBGL_SHADER(
uniform sampler2D u_texture;
uniform sampler2D u_fadetexture;
+
+#ifndef HAS_UNIFORM_u_opacity
varying lowp float opacity;
+#else
+uniform lowp float u_opacity;
+#endif
varying vec2 v_tex;
varying vec2 v_fade_tex;
void main() {
-
+
+#ifdef HAS_UNIFORM_u_opacity
+ lowp float opacity = u_opacity;
+#endif
lowp float alpha = texture2D(u_fadetexture, v_fade_tex).a * opacity;
gl_FragColor = texture2D(u_texture, v_tex) * alpha;
diff --git a/src/mbgl/shaders/symbol_sdf.cpp b/src/mbgl/shaders/symbol_sdf.cpp
index 0c39c5f4ac..cce6b769a6 100644
--- a/src/mbgl/shaders/symbol_sdf.cpp
+++ b/src/mbgl/shaders/symbol_sdf.cpp
@@ -27,21 +27,46 @@ uniform mediump float u_size_t; // used to interpolate between zoom stops when s
uniform mediump float u_size; // used when size is both zoom and feature constant
uniform mediump float u_layout_size; // used when size is feature constant
+
+#ifndef HAS_UNIFORM_u_fill_color
uniform lowp float a_fill_color_t;
attribute highp vec4 a_fill_color;
varying highp vec4 fill_color;
+#else
+uniform highp vec4 u_fill_color;
+#endif
+
+#ifndef HAS_UNIFORM_u_halo_color
uniform lowp float a_halo_color_t;
attribute highp vec4 a_halo_color;
varying highp vec4 halo_color;
+#else
+uniform highp vec4 u_halo_color;
+#endif
+
+#ifndef HAS_UNIFORM_u_opacity
uniform lowp float a_opacity_t;
attribute lowp vec2 a_opacity;
varying lowp float opacity;
+#else
+uniform lowp float u_opacity;
+#endif
+
+#ifndef HAS_UNIFORM_u_halo_width
uniform lowp float a_halo_width_t;
attribute lowp vec2 a_halo_width;
varying lowp float halo_width;
+#else
+uniform lowp float u_halo_width;
+#endif
+
+#ifndef HAS_UNIFORM_u_halo_blur
uniform lowp float a_halo_blur_t;
attribute lowp vec2 a_halo_blur;
varying lowp float halo_blur;
+#else
+uniform lowp float u_halo_blur;
+#endif
// matrix is for the vertex position.
uniform mat4 u_matrix;
@@ -61,11 +86,36 @@ varying vec4 v_data0;
varying vec2 v_data1;
void main() {
+
+#ifndef HAS_UNIFORM_u_fill_color
fill_color = unpack_mix_vec4(a_fill_color, a_fill_color_t);
+#else
+ highp vec4 fill_color = u_fill_color;
+#endif
+
+#ifndef HAS_UNIFORM_u_halo_color
halo_color = unpack_mix_vec4(a_halo_color, a_halo_color_t);
+#else
+ highp vec4 halo_color = u_halo_color;
+#endif
+
+#ifndef HAS_UNIFORM_u_opacity
opacity = unpack_mix_vec2(a_opacity, a_opacity_t);
+#else
+ lowp float opacity = u_opacity;
+#endif
+
+#ifndef HAS_UNIFORM_u_halo_width
halo_width = unpack_mix_vec2(a_halo_width, a_halo_width_t);
+#else
+ lowp float halo_width = u_halo_width;
+#endif
+
+#ifndef HAS_UNIFORM_u_halo_blur
halo_blur = unpack_mix_vec2(a_halo_blur, a_halo_blur_t);
+#else
+ lowp float halo_blur = u_halo_blur;
+#endif
vec2 a_pos = a_pos_offset.xy;
vec2 a_offset = a_pos_offset.zw;
@@ -170,11 +220,36 @@ const char* symbol_sdf::fragmentSource = R"MBGL_SHADER(
#define EDGE_GAMMA 0.105/DEVICE_PIXEL_RATIO
uniform bool u_is_halo;
+
+#ifndef HAS_UNIFORM_u_fill_color
varying highp vec4 fill_color;
+#else
+uniform highp vec4 u_fill_color;
+#endif
+
+#ifndef HAS_UNIFORM_u_halo_color
varying highp vec4 halo_color;
+#else
+uniform highp vec4 u_halo_color;
+#endif
+
+#ifndef HAS_UNIFORM_u_opacity
varying lowp float opacity;
+#else
+uniform lowp float u_opacity;
+#endif
+
+#ifndef HAS_UNIFORM_u_halo_width
varying lowp float halo_width;
+#else
+uniform lowp float u_halo_width;
+#endif
+
+#ifndef HAS_UNIFORM_u_halo_blur
varying lowp float halo_blur;
+#else
+uniform lowp float u_halo_blur;
+#endif
uniform sampler2D u_texture;
uniform sampler2D u_fadetexture;
@@ -185,11 +260,26 @@ varying vec4 v_data0;
varying vec2 v_data1;
void main() {
-
-
-
-
-
+
+#ifdef HAS_UNIFORM_u_fill_color
+ highp vec4 fill_color = u_fill_color;
+#endif
+
+#ifdef HAS_UNIFORM_u_halo_color
+ highp vec4 halo_color = u_halo_color;
+#endif
+
+#ifdef HAS_UNIFORM_u_opacity
+ lowp float opacity = u_opacity;
+#endif
+
+#ifdef HAS_UNIFORM_u_halo_width
+ lowp float halo_width = u_halo_width;
+#endif
+
+#ifdef HAS_UNIFORM_u_halo_blur
+ lowp float halo_blur = u_halo_blur;
+#endif
vec2 tex = v_data0.xy;
vec2 fade_tex = v_data0.zw;