[core] add shader defines for enabling/disabling attributes/uniforms for DDS
This commit is contained in:
committed by
John Firebaugh
parent
eaa8f23672
commit
b141707b8d
@@ -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
|
||||
`;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
@@ -81,12 +101,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_pattern_br_a, imagecoord);
|
||||
|
||||
@@ -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 = smoothstep(1.0, 0.0, dist);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -52,10 +62,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_pattern_br_a, imagecoord);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -47,10 +57,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_pattern_br_a, imagecoord);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
@@ -118,12 +158,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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user