[core] Simplify generate-shaders.js
We moved the #pragma ⇢ #ifndef logic into gl-js.
This commit is contained in:
@@ -3,14 +3,11 @@
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
const inputPath = 'mapbox-gl-js/src/shaders';
|
||||
const shaders = require('../mapbox-gl-js/src/shaders');
|
||||
const outputPath = 'src/mbgl/shaders';
|
||||
|
||||
require('./style-code');
|
||||
|
||||
const vertexPrelude = fs.readFileSync(path.join(inputPath, '_prelude.vertex.glsl'));
|
||||
const fragmentPrelude = fs.readFileSync(path.join(inputPath, '_prelude.fragment.glsl'));
|
||||
|
||||
writeIfModified(path.join(outputPath, 'preludes.hpp'), `// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED.
|
||||
|
||||
#pragma once
|
||||
@@ -33,84 +30,21 @@ namespace mbgl {
|
||||
namespace shaders {
|
||||
|
||||
const char* vertexPrelude = R"MBGL_SHADER(
|
||||
${vertexPrelude}
|
||||
${shaders.prelude.vertexSource}
|
||||
)MBGL_SHADER";
|
||||
const char* fragmentPrelude = R"MBGL_SHADER(
|
||||
${fragmentPrelude}
|
||||
${shaders.prelude.fragmentSource}
|
||||
)MBGL_SHADER";
|
||||
|
||||
} // namespace shaders
|
||||
} // namespace mbgl
|
||||
`);
|
||||
|
||||
[
|
||||
'circle',
|
||||
'collision_box',
|
||||
'debug',
|
||||
'extrusion_texture',
|
||||
'fill',
|
||||
'fill_extrusion',
|
||||
'fill_extrusion_pattern',
|
||||
'fill_outline',
|
||||
'fill_outline_pattern',
|
||||
'fill_pattern',
|
||||
'line',
|
||||
'line_pattern',
|
||||
'line_sdf',
|
||||
'raster',
|
||||
'symbol_icon',
|
||||
'symbol_sdf'
|
||||
].forEach(function (shaderName) {
|
||||
const re = / *#pragma mapbox: ([\w]+) ([\w]+) ([\w]+) ([\w]+)/g;
|
||||
const fragmentPragmas = new Set();
|
||||
for (const key in shaders) {
|
||||
if (key === 'prelude')
|
||||
continue;
|
||||
|
||||
let fragmentSource = fs.readFileSync(path.join(inputPath, shaderName + '.fragment.glsl'), 'utf8');
|
||||
let vertexSource = fs.readFileSync(path.join(inputPath, shaderName + '.vertex.glsl'), 'utf8');
|
||||
|
||||
fragmentSource = fragmentSource.replace(re, (match, operation, precision, type, name) => {
|
||||
fragmentPragmas.add(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" ? `
|
||||
#ifndef 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" ? `
|
||||
#ifndef 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`;
|
||||
}
|
||||
});
|
||||
const shaderName = key.replace(/[A-Z]+/g, (match) => `_${match.toLowerCase()}`);
|
||||
|
||||
writeIfModified(path.join(outputPath, `${shaderName}.hpp`), `// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED.
|
||||
|
||||
@@ -139,13 +73,13 @@ namespace shaders {
|
||||
|
||||
const char* ${shaderName}::name = "${shaderName}";
|
||||
const char* ${shaderName}::vertexSource = R"MBGL_SHADER(
|
||||
${vertexSource}
|
||||
${shaders[key].vertexSource}
|
||||
)MBGL_SHADER";
|
||||
const char* ${shaderName}::fragmentSource = R"MBGL_SHADER(
|
||||
${fragmentSource}
|
||||
${shaders[key].fragmentSource}
|
||||
)MBGL_SHADER";
|
||||
|
||||
} // namespace shaders
|
||||
} // namespace mbgl
|
||||
`);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ varying highp vec4 color;
|
||||
uniform highp vec4 u_color;
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef HAS_UNIFORM_u_radius
|
||||
uniform lowp float a_radius_t;
|
||||
attribute mediump vec2 a_radius;
|
||||
@@ -32,6 +33,7 @@ varying mediump float radius;
|
||||
uniform mediump float u_radius;
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef HAS_UNIFORM_u_blur
|
||||
uniform lowp float a_blur_t;
|
||||
attribute lowp vec2 a_blur;
|
||||
@@ -40,6 +42,7 @@ varying lowp float blur;
|
||||
uniform lowp float u_blur;
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
uniform lowp float a_opacity_t;
|
||||
attribute lowp vec2 a_opacity;
|
||||
@@ -48,6 +51,7 @@ varying lowp float opacity;
|
||||
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;
|
||||
@@ -56,6 +60,7 @@ varying highp vec4 stroke_color;
|
||||
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;
|
||||
@@ -64,6 +69,7 @@ varying mediump float stroke_width;
|
||||
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;
|
||||
@@ -72,52 +78,60 @@ varying lowp float stroke_opacity;
|
||||
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);
|
||||
|
||||
@@ -164,74 +178,88 @@ varying highp vec4 color;
|
||||
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);
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ varying highp vec4 color;
|
||||
uniform highp vec4 u_color;
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
uniform lowp float a_opacity_t;
|
||||
attribute lowp vec2 a_opacity;
|
||||
@@ -28,20 +29,23 @@ varying lowp float opacity;
|
||||
uniform lowp float u_opacity;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -54,22 +58,26 @@ varying highp vec4 color;
|
||||
uniform highp vec4 u_color;
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
varying lowp float opacity;
|
||||
#else
|
||||
uniform lowp float u_opacity;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
|
||||
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;
|
||||
|
||||
#ifdef OVERDRAW_INSPECTOR
|
||||
|
||||
@@ -27,6 +27,7 @@ varying lowp float base;
|
||||
uniform lowp float u_base;
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef HAS_UNIFORM_u_height
|
||||
uniform lowp float a_height_t;
|
||||
attribute lowp vec2 a_height;
|
||||
@@ -36,6 +37,7 @@ uniform lowp float u_height;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#ifndef HAS_UNIFORM_u_color
|
||||
uniform lowp float a_color_t;
|
||||
attribute highp vec4 a_color;
|
||||
@@ -44,26 +46,30 @@ varying highp vec4 color;
|
||||
uniform highp vec4 u_color;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
|
||||
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);
|
||||
|
||||
@@ -113,32 +119,38 @@ varying lowp float base;
|
||||
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() {
|
||||
|
||||
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;
|
||||
|
||||
#ifdef OVERDRAW_INSPECTOR
|
||||
|
||||
@@ -39,6 +39,7 @@ varying lowp float base;
|
||||
uniform lowp float u_base;
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef HAS_UNIFORM_u_height
|
||||
uniform lowp float a_height_t;
|
||||
attribute lowp vec2 a_height;
|
||||
@@ -47,20 +48,23 @@ varying lowp float height;
|
||||
uniform lowp float u_height;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
|
||||
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);
|
||||
|
||||
@@ -109,22 +113,26 @@ varying lowp float base;
|
||||
uniform lowp float u_base;
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef HAS_UNIFORM_u_height
|
||||
varying lowp float height;
|
||||
#else
|
||||
uniform lowp float u_height;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
|
||||
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);
|
||||
vec4 color1 = texture2D(u_image, pos);
|
||||
|
||||
@@ -23,6 +23,7 @@ varying highp vec4 outline_color;
|
||||
uniform highp vec4 u_outline_color;
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
uniform lowp float a_opacity_t;
|
||||
attribute lowp vec2 a_opacity;
|
||||
@@ -31,20 +32,23 @@ varying lowp float opacity;
|
||||
uniform lowp float u_opacity;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -58,24 +62,28 @@ varying highp vec4 outline_color;
|
||||
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);
|
||||
gl_FragColor = outline_color * (alpha * opacity);
|
||||
|
||||
@@ -32,14 +32,16 @@ varying lowp float opacity;
|
||||
uniform lowp float u_opacity;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
@@ -70,12 +72,14 @@ varying lowp float opacity;
|
||||
uniform lowp float u_opacity;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
|
||||
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);
|
||||
vec4 color1 = texture2D(u_image, pos);
|
||||
|
||||
@@ -30,14 +30,16 @@ varying lowp float opacity;
|
||||
uniform lowp float u_opacity;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
@@ -65,12 +67,14 @@ varying lowp float opacity;
|
||||
uniform lowp float u_opacity;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
|
||||
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);
|
||||
vec4 color1 = texture2D(u_image, pos);
|
||||
|
||||
@@ -41,6 +41,7 @@ varying highp vec4 color;
|
||||
uniform highp vec4 u_color;
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef HAS_UNIFORM_u_blur
|
||||
uniform lowp float a_blur_t;
|
||||
attribute lowp vec2 a_blur;
|
||||
@@ -49,6 +50,7 @@ varying lowp float blur;
|
||||
uniform lowp float u_blur;
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
uniform lowp float a_opacity_t;
|
||||
attribute lowp vec2 a_opacity;
|
||||
@@ -57,6 +59,7 @@ varying lowp float opacity;
|
||||
uniform lowp float u_opacity;
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef HAS_UNIFORM_u_gapwidth
|
||||
uniform lowp float a_gapwidth_t;
|
||||
attribute mediump vec2 a_gapwidth;
|
||||
@@ -64,6 +67,7 @@ attribute mediump vec2 a_gapwidth;
|
||||
uniform mediump float u_gapwidth;
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef HAS_UNIFORM_u_offset
|
||||
uniform lowp float a_offset_t;
|
||||
attribute lowp vec2 a_offset;
|
||||
@@ -71,6 +75,7 @@ attribute lowp vec2 a_offset;
|
||||
uniform lowp float u_offset;
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef HAS_UNIFORM_u_width
|
||||
uniform lowp float a_width_t;
|
||||
attribute mediump vec2 a_width;
|
||||
@@ -78,44 +83,51 @@ attribute mediump vec2 a_width;
|
||||
uniform mediump float u_width;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
|
||||
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
|
||||
|
||||
|
||||
#ifndef HAS_UNIFORM_u_width
|
||||
mediump float width = unpack_mix_vec2(a_width, a_width_t);
|
||||
#else
|
||||
mediump float width = u_width;
|
||||
#endif
|
||||
|
||||
|
||||
vec2 a_extrude = a_data.xy - 128.0;
|
||||
float a_direction = mod(a_data.z, 4.0) - 1.0;
|
||||
|
||||
@@ -172,36 +184,42 @@ varying highp vec4 color;
|
||||
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;
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@ varying lowp float blur;
|
||||
uniform lowp float u_blur;
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
uniform lowp float a_opacity_t;
|
||||
attribute lowp vec2 a_opacity;
|
||||
@@ -52,6 +53,7 @@ varying lowp float opacity;
|
||||
uniform lowp float u_opacity;
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef HAS_UNIFORM_u_offset
|
||||
uniform lowp float a_offset_t;
|
||||
attribute lowp vec2 a_offset;
|
||||
@@ -59,6 +61,7 @@ attribute lowp vec2 a_offset;
|
||||
uniform lowp float u_offset;
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef HAS_UNIFORM_u_gapwidth
|
||||
uniform lowp float a_gapwidth_t;
|
||||
attribute mediump vec2 a_gapwidth;
|
||||
@@ -66,6 +69,7 @@ attribute mediump vec2 a_gapwidth;
|
||||
uniform mediump float u_gapwidth;
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef HAS_UNIFORM_u_width
|
||||
uniform lowp float a_width_t;
|
||||
attribute mediump vec2 a_width;
|
||||
@@ -73,38 +77,44 @@ attribute mediump vec2 a_width;
|
||||
uniform mediump float u_width;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
|
||||
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
|
||||
|
||||
|
||||
#ifndef HAS_UNIFORM_u_width
|
||||
mediump float width = unpack_mix_vec2(a_width, a_width_t);
|
||||
#else
|
||||
mediump float width = u_width;
|
||||
#endif
|
||||
|
||||
|
||||
vec2 a_extrude = a_data.xy - 128.0;
|
||||
float a_direction = mod(a_data.z, 4.0) - 1.0;
|
||||
float a_linesofar = (floor(a_data.z / 4.0) + a_data.w * 64.0) * LINE_DISTANCE_SCALE;
|
||||
@@ -178,22 +188,26 @@ varying lowp float blur;
|
||||
uniform lowp float u_blur;
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
varying lowp float opacity;
|
||||
#else
|
||||
uniform lowp float u_opacity;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
|
||||
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;
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@ varying highp vec4 color;
|
||||
uniform highp vec4 u_color;
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef HAS_UNIFORM_u_blur
|
||||
uniform lowp float a_blur_t;
|
||||
attribute lowp vec2 a_blur;
|
||||
@@ -57,6 +58,7 @@ varying lowp float blur;
|
||||
uniform lowp float u_blur;
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
uniform lowp float a_opacity_t;
|
||||
attribute lowp vec2 a_opacity;
|
||||
@@ -65,6 +67,7 @@ varying lowp float opacity;
|
||||
uniform lowp float u_opacity;
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef HAS_UNIFORM_u_gapwidth
|
||||
uniform lowp float a_gapwidth_t;
|
||||
attribute mediump vec2 a_gapwidth;
|
||||
@@ -72,6 +75,7 @@ attribute mediump vec2 a_gapwidth;
|
||||
uniform mediump float u_gapwidth;
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef HAS_UNIFORM_u_offset
|
||||
uniform lowp float a_offset_t;
|
||||
attribute lowp vec2 a_offset;
|
||||
@@ -79,6 +83,7 @@ attribute lowp vec2 a_offset;
|
||||
uniform lowp float u_offset;
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef HAS_UNIFORM_u_width
|
||||
uniform lowp float a_width_t;
|
||||
attribute mediump vec2 a_width;
|
||||
@@ -87,6 +92,7 @@ varying mediump float width;
|
||||
uniform mediump float u_width;
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef HAS_UNIFORM_u_floorwidth
|
||||
uniform lowp float a_floorwidth_t;
|
||||
attribute lowp vec2 a_floorwidth;
|
||||
@@ -95,50 +101,58 @@ varying lowp float floorwidth;
|
||||
uniform lowp float u_floorwidth;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
|
||||
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
|
||||
|
||||
|
||||
#ifndef HAS_UNIFORM_u_width
|
||||
width = unpack_mix_vec2(a_width, a_width_t);
|
||||
#else
|
||||
mediump float width = u_width;
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef HAS_UNIFORM_u_floorwidth
|
||||
floorwidth = unpack_mix_vec2(a_floorwidth, a_floorwidth_t);
|
||||
#else
|
||||
lowp float floorwidth = u_floorwidth;
|
||||
#endif
|
||||
|
||||
|
||||
vec2 a_extrude = a_data.xy - 128.0;
|
||||
float a_direction = mod(a_data.z, 4.0) - 1.0;
|
||||
float a_linesofar = (floor(a_data.z / 4.0) + a_data.w * 64.0) * LINE_DISTANCE_SCALE;
|
||||
@@ -209,52 +223,62 @@ varying highp vec4 color;
|
||||
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
|
||||
|
||||
|
||||
#ifndef HAS_UNIFORM_u_width
|
||||
varying mediump float width;
|
||||
#else
|
||||
uniform mediump float u_width;
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef HAS_UNIFORM_u_floorwidth
|
||||
varying lowp float floorwidth;
|
||||
#else
|
||||
uniform lowp float u_floorwidth;
|
||||
#endif
|
||||
|
||||
void main() {
|
||||
|
||||
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
|
||||
|
||||
|
||||
#ifdef HAS_UNIFORM_u_width
|
||||
mediump float width = u_width;
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef HAS_UNIFORM_u_floorwidth
|
||||
lowp float floorwidth = u_floorwidth;
|
||||
#endif
|
||||
|
||||
|
||||
// Calculate the distance of the pixel from the line in pixels.
|
||||
float dist = length(v_normal) * v_width2.s;
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ varying lowp float opacity;
|
||||
uniform lowp float u_opacity;
|
||||
#endif
|
||||
|
||||
|
||||
uniform mat4 u_matrix;
|
||||
uniform mat4 u_label_plane_matrix;
|
||||
uniform mat4 u_gl_coord_matrix;
|
||||
@@ -45,13 +46,14 @@ 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;
|
||||
|
||||
@@ -125,15 +127,17 @@ varying lowp float opacity;
|
||||
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;
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ varying highp vec4 fill_color;
|
||||
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;
|
||||
@@ -42,6 +43,7 @@ varying highp vec4 halo_color;
|
||||
uniform highp vec4 u_halo_color;
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef HAS_UNIFORM_u_opacity
|
||||
uniform lowp float a_opacity_t;
|
||||
attribute lowp vec2 a_opacity;
|
||||
@@ -50,6 +52,7 @@ varying lowp float opacity;
|
||||
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;
|
||||
@@ -58,6 +61,7 @@ varying lowp float halo_width;
|
||||
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;
|
||||
@@ -66,6 +70,7 @@ varying lowp float halo_blur;
|
||||
uniform lowp float u_halo_blur;
|
||||
#endif
|
||||
|
||||
|
||||
uniform mat4 u_matrix;
|
||||
uniform mat4 u_label_plane_matrix;
|
||||
uniform mat4 u_gl_coord_matrix;
|
||||
@@ -84,37 +89,42 @@ 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;
|
||||
|
||||
@@ -215,30 +225,35 @@ varying highp vec4 fill_color;
|
||||
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;
|
||||
uniform highp float u_gamma_scale;
|
||||
@@ -248,27 +263,32 @@ 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;
|
||||
float gamma_scale = v_data1.x;
|
||||
|
||||
Reference in New Issue
Block a user