summaryrefslogtreecommitdiff
path: root/src/mbgl/shaders/line.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl/shaders/line.cpp')
-rw-r--r--src/mbgl/shaders/line.cpp96
1 files changed, 10 insertions, 86 deletions
diff --git a/src/mbgl/shaders/line.cpp b/src/mbgl/shaders/line.cpp
index 59fa9f0cf2..dc4aa774dc 100644
--- a/src/mbgl/shaders/line.cpp
+++ b/src/mbgl/shaders/line.cpp
@@ -7,60 +7,6 @@ namespace shaders {
const char* line::name = "line";
const char* line::vertexSource = R"MBGL_SHADER(
-#ifdef GL_ES
-precision highp float;
-#else
-
-#if !defined(lowp)
-#define lowp
-#endif
-
-#if !defined(mediump)
-#define mediump
-#endif
-
-#if !defined(highp)
-#define highp
-#endif
-
-#endif
-
-float evaluate_zoom_function_1(const vec4 values, const float t) {
- if (t < 1.0) {
- return mix(values[0], values[1], t);
- } else if (t < 2.0) {
- return mix(values[1], values[2], t - 1.0);
- } else {
- return mix(values[2], values[3], t - 2.0);
- }
-}
-vec4 evaluate_zoom_function_4(const vec4 value0, const vec4 value1, const vec4 value2, const vec4 value3, const float t) {
- if (t < 1.0) {
- return mix(value0, value1, t);
- } else if (t < 2.0) {
- return mix(value1, value2, t - 1.0);
- } else {
- return mix(value2, value3, t - 2.0);
- }
-}
-
-// The offset depends on how many pixels are between the world origin and the edge of the tile:
-// vec2 offset = mod(pixel_coord, size)
-//
-// At high zoom levels there are a ton of pixels between the world origin and the edge of the tile.
-// The glsl spec only guarantees 16 bits of precision for highp floats. We need more than that.
-//
-// The pixel_coord is passed in as two 16 bit values:
-// pixel_coord_upper = floor(pixel_coord / 2^16)
-// pixel_coord_lower = mod(pixel_coord, 2^16)
-//
-// The offset is calculated in a series of steps that should preserve this precision:
-vec2 get_pattern_pos(const vec2 pixel_coord_upper, const vec2 pixel_coord_lower,
- const vec2 pattern_size, const float tile_units_to_pixels, const vec2 pos) {
-
- vec2 offset = mod(mod(mod(pixel_coord_upper, pattern_size) * 256.0, pattern_size) * 256.0 + pixel_coord_lower, pattern_size);
- return (tile_units_to_pixels * pos + offset) / pattern_size;
-}
// the distance over which the line edge fades out.
@@ -88,32 +34,27 @@ varying vec2 v_width2;
varying float v_gamma_scale;
uniform lowp float a_color_t;
-attribute lowp vec4 a_color_min;
-attribute lowp vec4 a_color_max;
+attribute lowp vec4 a_color;
varying lowp vec4 color;
uniform lowp float a_blur_t;
-attribute lowp float a_blur_min;
-attribute lowp float a_blur_max;
+attribute lowp vec2 a_blur;
varying lowp float blur;
uniform lowp float a_opacity_t;
-attribute lowp float a_opacity_min;
-attribute lowp float a_opacity_max;
+attribute lowp vec2 a_opacity;
varying lowp float opacity;
uniform lowp float a_gapwidth_t;
-attribute mediump float a_gapwidth_min;
-attribute mediump float a_gapwidth_max;
+attribute mediump vec2 a_gapwidth;
varying mediump float gapwidth;
uniform lowp float a_offset_t;
-attribute lowp float a_offset_min;
-attribute lowp float a_offset_max;
+attribute lowp vec2 a_offset;
varying lowp float offset;
void main() {
- color = mix(a_color_min, a_color_max, a_color_t);
- blur = mix(a_blur_min, a_blur_max, a_blur_t);
- opacity = mix(a_opacity_min, a_opacity_max, a_opacity_t);
- gapwidth = mix(a_gapwidth_min, a_gapwidth_max, a_gapwidth_t);
- offset = mix(a_offset_min, a_offset_max, a_offset_t);
+ color = unpack_mix_vec4(a_color, a_color_t);
+ blur = unpack_mix_vec2(a_blur, a_blur_t);
+ opacity = unpack_mix_vec2(a_opacity, a_opacity_t);
+ gapwidth = unpack_mix_vec2(a_gapwidth, a_gapwidth_t);
+ offset = unpack_mix_vec2(a_offset, a_offset_t);
vec2 a_extrude = a_data.xy - 128.0;
float a_direction = mod(a_data.z, 4.0) - 1.0;
@@ -164,23 +105,6 @@ void main() {
)MBGL_SHADER";
const char* line::fragmentSource = R"MBGL_SHADER(
-#ifdef GL_ES
-precision mediump float;
-#else
-
-#if !defined(lowp)
-#define lowp
-#endif
-
-#if !defined(mediump)
-#define mediump
-#endif
-
-#if !defined(highp)
-#define highp
-#endif
-
-#endif
varying lowp vec4 color;
varying lowp float blur;
varying lowp float opacity;