[core] Share shaders with gl-js

This commit is contained in:
John Firebaugh
2016-05-23 15:26:26 -07:00
parent 4e2c743eba
commit 45c5b2a66c
31 changed files with 18 additions and 686 deletions

View File

@@ -16,6 +16,8 @@ else
export XCPRETTY ?= | xcpretty
endif
default: test-$(HOST_PLATFORM)
ifneq (,$(wildcard .git/.))
.mason:
git submodule update --init
@@ -23,7 +25,8 @@ else
.mason: ;
endif
default: test-$(HOST_PLATFORM)
node_modules: package.json
npm update # Install dependencies but don't run our own install script.
GYP = deps/run_gyp --depth=. -Goutput_dir=.
@@ -31,7 +34,7 @@ CONFIG_DEPENDENCIES = .mason configure
# Depend on gyp includes plus directories, so that projects are regenerated when
# files are added or removed.
GYP_DEPENDENCIES = mbgl.gypi test/test.gypi bin/*.gypi $(shell find src include -type d)
GYP_DEPENDENCIES = mbgl.gypi test/test.gypi bin/*.gypi $(shell find src include -type d) node_modules
#### OS X targets ##############################################################
@@ -179,9 +182,6 @@ apackage:
NODE_PRE_GYP = $(shell npm bin)/node-pre-gyp
NODE_OUTPUT_PATH = build/node-$(HOST_PLATFORM)-$(shell uname -m)
node_modules: package.json
npm update # Install dependencies but don't run our own install script.
$(NODE_OUTPUT_PATH)/config.gypi: platform/$(HOST_PLATFORM)/scripts/configure.sh $(CONFIG_DEPENDENCIES)
./configure $< $@ $(HOST_PLATFORM) $(shell uname -m)

View File

@@ -138,7 +138,7 @@
'<!@(find <(DEPTH)/src -name "*.h")',
'<!@(find <(DEPTH)/include -name "*.hpp")',
'<!@(find <(DEPTH)/include -name "*.h")',
'<!@(find <(DEPTH)/src -name "*.glsl")',
'<!@(find -H <(DEPTH)/node_modules/mapbox-gl-shaders -name "*.glsl")',
'<(SHARED_INTERMEDIATE_DIR)/include/mbgl/util/version.hpp',
],

View File

@@ -19,6 +19,7 @@
"devDependencies": {
"aws-sdk": "^2.3.5",
"express": "^4.11.1",
"mapbox-gl-shaders": "mapbox/mapbox-gl-shaders#10941bb6f0b2b11c8bba83c3faaa094a62ad56d7",
"mapbox-gl-test-suite": "mapbox/mapbox-gl-test-suite#b3441d9a285ffbe9b876677acb13d7df07e5b975",
"node-gyp": "^3.3.1",
"request": "^2.72.0",

View File

@@ -62,7 +62,8 @@ workflows:
#!/bin/bash
set -eu -o pipefail
apt-get install -y pkg-config python-pip python-dev build-essential
curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash -
apt-get install -y pkg-config python-pip python-dev build-essential nodejs
pip install awscli
aws s3 cp s3://mapbox/android/signing-credentials/secring.gpg platform/android/MapboxGLAndroidSDK/secring.gpg

View File

@@ -1,24 +0,0 @@
uniform float u_zoom;
uniform float u_maxzoom;
varying float v_max_zoom;
varying float v_placement_zoom;
void main() {
float alpha = 0.5;
gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0) * alpha;
if (v_placement_zoom > u_zoom) {
gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0) * alpha;
}
if (u_zoom >= v_max_zoom) {
gl_FragColor = vec4(0.0, 0.0, 0.0, 1.0) * alpha * 0.25;
}
if (v_placement_zoom >= u_maxzoom) {
gl_FragColor = vec4(0.0, 0.0, 1.0, 1.0) * alpha * 0.2;
}
}

View File

@@ -1,16 +0,0 @@
attribute vec2 a_pos;
attribute vec2 a_extrude;
attribute vec2 a_data;
uniform mat4 u_matrix;
uniform float u_scale;
varying float v_max_zoom;
varying float v_placement_zoom;
void main() {
gl_Position = u_matrix * vec4(a_pos + a_extrude / u_scale, 0.0, 1.0);
v_max_zoom = a_data.x;
v_placement_zoom = a_data.y;
}

View File

@@ -1,10 +0,0 @@
uniform vec4 u_color;
uniform float u_blur;
uniform float u_size;
varying vec2 v_extrude;
void main() {
float t = smoothstep(1.0 - u_blur, 1.0, length(v_extrude));
gl_FragColor = u_color * (1.0 - t);
}

View File

@@ -1,23 +0,0 @@
// set by gl_util
uniform float u_size;
attribute vec2 a_pos;
uniform mat4 u_matrix;
uniform mat4 u_exmatrix;
varying vec2 v_extrude;
void main(void) {
// unencode the extrusion vector that we snuck into the a_pos vector
v_extrude = vec2(mod(a_pos, 2.0) * 2.0 - 1.0);
vec4 extrude = u_exmatrix * vec4(v_extrude * u_size, 0, 0);
// multiply a_pos by 0.5, since we had it * 2 in order to sneak
// in extrusion data
gl_Position = u_matrix * vec4(floor(a_pos * 0.5), 0, 1);
// gl_Position is divided by gl_Position.w after this shader runs.
// Multiply the extrude by it so that it isn't affected by it.
gl_Position += extrude * gl_Position.w;
}

View File

@@ -1,6 +1,6 @@
#include <mbgl/shader/collision_box_shader.hpp>
#include <mbgl/shader/box.vertex.hpp>
#include <mbgl/shader/box.fragment.hpp>
#include <mbgl/shader/collisionbox.vertex.hpp>
#include <mbgl/shader/collisionbox.fragment.hpp>
#include <mbgl/gl/gl.hpp>
#include <cstdio>
@@ -8,7 +8,7 @@
using namespace mbgl;
CollisionBoxShader::CollisionBoxShader(gl::GLObjectStore& glObjectStore)
: Shader("collisionbox", shaders::box::vertex, shaders::box::fragment, glObjectStore) {
: Shader("collisionbox", shaders::collisionbox::vertex, shaders::collisionbox::fragment, glObjectStore) {
a_extrude = MBGL_CHECK_ERROR(glGetAttribLocation(getID(), "a_extrude"));
a_data = MBGL_CHECK_ERROR(glGetAttribLocation(getID(), "a_data"));
}

View File

@@ -1,11 +0,0 @@
uniform sampler2D u_texture;
uniform sampler2D u_fadetexture;
uniform float u_opacity;
varying vec2 v_tex;
varying vec2 v_fade_tex;
void main() {
float alpha = texture2D(u_fadetexture, v_fade_tex).a * u_opacity;
gl_FragColor = texture2D(u_texture, v_tex) * alpha;
}

View File

@@ -1,42 +0,0 @@
attribute vec2 a_pos;
attribute vec2 a_offset;
attribute vec4 a_data1;
attribute vec4 a_data2;
// matrix is for the vertex position, exmatrix is for rotating and projecting
// the extrusion vector.
uniform mat4 u_matrix;
uniform mat4 u_exmatrix;
uniform float u_zoom;
uniform bool u_skewed;
uniform float u_extra;
uniform vec2 u_texsize;
varying vec2 v_tex;
varying vec2 v_fade_tex;
void main() {
vec2 a_tex = a_data1.xy;
float a_labelminzoom = a_data1[2];
float a_angle = a_data1[3];
vec2 a_zoom = a_data2.st;
float a_minzoom = a_zoom[0];
float a_maxzoom = a_zoom[1];
// u_zoom is the current zoom level adjusted for the change in font size
float z = 2.0 - step(a_minzoom, u_zoom) - (1.0 - step(a_maxzoom, u_zoom));
if (u_skewed) {
vec4 extrude = u_exmatrix * vec4(a_offset / 64.0, 0, 0);
gl_Position = u_matrix * vec4(a_pos + extrude.xy, 0, 1);
gl_Position.z += z * gl_Position.w;
} else {
vec4 extrude = u_exmatrix * vec4(a_offset / 64.0, z, 0);
gl_Position = u_matrix * vec4(a_pos, 0, 1) + extrude;
}
v_tex = a_tex / u_texsize;
v_fade_tex = vec2(a_labelminzoom / 255.0, 0.0);
}

View File

@@ -1,19 +0,0 @@
uniform vec2 u_linewidth;
uniform vec4 u_color;
uniform float u_blur;
varying vec2 v_normal;
varying float v_gamma_scale;
void main() {
// Calculate the distance of the pixel from the line in pixels.
float dist = length(v_normal) * u_linewidth.s;
// Calculate the antialiasing fade factor. This is either when fading in
// the line in case of an offset line (v_linewidth.t) or when fading out
// (v_linewidth.s)
float blur = u_blur * v_gamma_scale;
float alpha = clamp(min(dist - (u_linewidth.t - blur), u_linewidth.s - dist) / blur, 0.0, 1.0);
gl_FragColor = u_color * alpha;
}

View File

@@ -1,65 +0,0 @@
// floor(127 / 2) == 63.0
// the maximum allowed miter limit is 2.0 at the moment. the extrude normal is
// stored in a byte (-128..127). we scale regular normals up to length 63, but
// there are also "special" normals that have a bigger length (of up to 126 in
// this case).
// #define scale 63.0
#define scale 0.015873016
attribute vec2 a_pos;
attribute vec4 a_data;
uniform mat4 u_matrix;
// shared
uniform float u_ratio;
uniform vec2 u_linewidth;
uniform float u_offset;
uniform float u_extra;
uniform mat2 u_antialiasingmatrix;
varying vec2 v_normal;
varying float v_gamma_scale;
void main() {
vec2 a_extrude = a_data.xy - 128.0;
float a_direction = mod(a_data.z, 4.0) - 1.0;
// We store the texture normals in the most insignificant bit
// transform y so that 0 => -1 and 1 => 1
// In the texture normal, x is 0 if the normal points straight up/down and 1 if it's a round cap
// y is 1 if the normal points up, and -1 if it points down
vec2 normal = mod(a_pos, 2.0);
normal.y = sign(normal.y - 0.5);
v_normal = normal;
// Scale the extrusion vector down to a normal and then up by the line width
// of this vertex.
vec2 dist = u_linewidth.s * a_extrude * scale;
// Calculate the offset when drawing a line that is to the side of the actual line.
// We do this by creating a vector that points towards the extrude, but rotate
// it when we're drawing round end points (a_direction = -1 or 1) since their
// extrude vector points in another direction.
float u = 0.5 * a_direction;
float t = 1.0 - abs(u);
vec2 offset = u_offset * a_extrude * scale * normal.y * mat2(t, -u, u, t);
// Remove the texture normal bit of the position before scaling it with the
// model/view matrix. Add the extrusion vector *after* the model/view matrix
// because we're extruding the line in pixel space, regardless of the current
// tile's zoom level.
gl_Position = u_matrix * vec4(floor(a_pos * 0.5) + (offset + dist) / u_ratio, 0.0, 1.0);
// position of y on the screen
float y = gl_Position.y / gl_Position.w;
// how much features are squished in the y direction by the tilt
float squish_scale = length(a_extrude) / length(u_antialiasingmatrix * a_extrude);
// how much features are squished in all directions by the perspectiveness
float perspective_scale = 1.0 / (1.0 - min(y * u_extra, 0.90));
v_gamma_scale = perspective_scale * squish_scale;
}

View File

@@ -1,41 +0,0 @@
uniform vec2 u_linewidth;
uniform float u_blur;
uniform vec2 u_pattern_size_a;
uniform vec2 u_pattern_tl_a;
uniform vec2 u_pattern_br_a;
uniform vec2 u_pattern_size_b;
uniform vec2 u_pattern_tl_b;
uniform vec2 u_pattern_br_b;
uniform float u_fade;
uniform float u_opacity;
uniform sampler2D u_image;
varying vec2 v_normal;
varying float v_linesofar;
varying float v_gamma_scale;
void main() {
// Calculate the distance of the pixel from the line in pixels.
float dist = length(v_normal) * u_linewidth.s;
// Calculate the antialiasing fade factor. This is either when fading in
// the line in case of an offset line (v_linewidth.t) or when fading out
// (v_linewidth.s)
float blur = u_blur * v_gamma_scale;
float alpha = clamp(min(dist - (u_linewidth.t - blur), u_linewidth.s - dist) / blur, 0.0, 1.0);
float x_a = mod(v_linesofar / u_pattern_size_a.x, 1.0);
float y_a = 0.5 + (v_normal.y * u_linewidth.s / u_pattern_size_a.y);
vec2 pos_a = mix(u_pattern_tl_a, u_pattern_br_a, vec2(x_a, y_a));
float x_b = mod(v_linesofar / u_pattern_size_b.x, 1.0);
float y_b = 0.5 + (v_normal.y * u_linewidth.s / u_pattern_size_b.y);
vec2 pos_b = mix(u_pattern_tl_b, u_pattern_br_b, vec2(x_b, y_b));
vec4 color = mix(texture2D(u_image, pos_a), texture2D(u_image, pos_b), u_fade);
alpha *= u_opacity;
gl_FragColor = color * alpha;
}

View File

@@ -1,76 +0,0 @@
// floor(127 / 2) == 63.0
// the maximum allowed miter limit is 2.0 at the moment. the extrude normal is
// stored in a byte (-128..127). we scale regular normals up to length 63, but
// there are also "special" normals that have a bigger length (of up to 126 in
// this case).
// #define scale 63.0
#define scale 0.015873016
// We scale the distance before adding it to the buffers so that we can store
// long distances for long segments. Use this value to unscale the distance.
#define LINE_DISTANCE_SCALE 2.0
attribute vec2 a_pos;
attribute vec4 a_data;
// matrix is for the vertex position, exmatrix is for rotating and projecting
// the extrusion vector.
uniform mat4 u_matrix;
uniform mat4 u_exmatrix;
// shared
uniform float u_ratio;
uniform vec2 u_linewidth;
uniform float u_offset;
uniform vec4 u_color;
uniform float u_extra;
uniform mat2 u_antialiasingmatrix;
varying vec2 v_normal;
varying float v_linesofar;
varying float v_gamma_scale;
void main() {
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;
// We store the texture normals in the most insignificant bit
// transform y so that 0 => -1 and 1 => 1
// In the texture normal, x is 0 if the normal points straight up/down and 1 if it's a round cap
// y is 1 if the normal points up, and -1 if it points down
vec2 normal = mod(a_pos, 2.0);
normal.y = sign(normal.y - 0.5);
v_normal = normal;
// Scale the extrusion vector down to a normal and then up by the line width
// of this vertex.
vec2 dist = u_linewidth.s * a_extrude * scale;
// Calculate the offset when drawing a line that is to the side of the actual line.
// We do this by creating a vector that points towards the extrude, but rotate
// it when we're drawing round end points (a_direction = -1 or 1) since their
// extrude vector points in another direction.
float u = 0.5 * a_direction;
float t = 1.0 - abs(u);
vec2 offset = u_offset * a_extrude * scale * normal.y * mat2(t, -u, u, t);
// Remove the texture normal bit of the position before scaling it with the
// model/view matrix. Add the extrusion vector *after* the model/view matrix
// because we're extruding the line in pixel space, regardless of the current
// tile's zoom level.
gl_Position = u_matrix * vec4(floor(a_pos / 2.0) + (offset + dist) / u_ratio, 0.0, 1.0);
v_linesofar = a_linesofar;
// position of y on the screen
float y = gl_Position.y / gl_Position.w;
// how much features are squished in the y direction by the tilt
float squish_scale = length(a_extrude) / length(u_antialiasingmatrix * a_extrude);
// how much features are squished in all directions by the perspectiveness
float perspective_scale = 1.0 / (1.0 - y * u_extra);
v_gamma_scale = perspective_scale * squish_scale;
}

View File

@@ -1,29 +0,0 @@
uniform vec2 u_linewidth;
uniform vec4 u_color;
uniform float u_blur;
uniform sampler2D u_image;
uniform float u_sdfgamma;
uniform float u_mix;
varying vec2 v_normal;
varying vec2 v_tex_a;
varying vec2 v_tex_b;
varying float v_gamma_scale;
void main() {
// Calculate the distance of the pixel from the line in pixels.
float dist = length(v_normal) * u_linewidth.s;
// Calculate the antialiasing fade factor. This is either when fading in
// the line in case of an offset line (v_linewidth.t) or when fading out
// (v_linewidth.s)
float blur = u_blur * v_gamma_scale;
float alpha = clamp(min(dist - (u_linewidth.t - blur), u_linewidth.s - dist) / blur, 0.0, 1.0);
float sdfdist_a = texture2D(u_image, v_tex_a).a;
float sdfdist_b = texture2D(u_image, v_tex_b).a;
float sdfdist = mix(sdfdist_a, sdfdist_b, u_mix);
alpha *= smoothstep(0.5 - u_sdfgamma, 0.5 + u_sdfgamma, sdfdist);
gl_FragColor = u_color * alpha;
}

View File

@@ -1,82 +0,0 @@
// floor(127 / 2) == 63.0
// the maximum allowed miter limit is 2.0 at the moment. the extrude normal is
// stored in a byte (-128..127). we scale regular normals up to length 63, but
// there are also "special" normals that have a bigger length (of up to 126 in
// this case).
// #define scale 63.0
#define scale 0.015873016
// We scale the distance before adding it to the buffers so that we can store
// long distances for long segments. Use this value to unscale the distance.
#define LINE_DISTANCE_SCALE 2.0
attribute vec2 a_pos;
attribute vec4 a_data;
// matrix is for the vertex position, exmatrix is for rotating and projecting
// the extrusion vector.
uniform mat4 u_matrix;
uniform mat4 u_exmatrix;
// shared
uniform float u_ratio;
uniform vec2 u_linewidth;
uniform float u_offset;
uniform vec2 u_patternscale_a;
uniform float u_tex_y_a;
uniform vec2 u_patternscale_b;
uniform float u_tex_y_b;
uniform float u_extra;
uniform mat2 u_antialiasingmatrix;
varying vec2 v_normal;
varying vec2 v_tex_a;
varying vec2 v_tex_b;
varying float v_gamma_scale;
void main() {
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;
// We store the texture normals in the most insignificant bit
// transform y so that 0 => -1 and 1 => 1
// In the texture normal, x is 0 if the normal points straight up/down and 1 if it's a round cap
// y is 1 if the normal points up, and -1 if it points down
vec2 normal = mod(a_pos, 2.0);
normal.y = sign(normal.y - 0.5);
v_normal = normal;
// Scale the extrusion vector down to a normal and then up by the line width
// of this vertex.
vec2 dist = u_linewidth.s * a_extrude * scale;
// Calculate the offset when drawing a line that is to the side of the actual line.
// We do this by creating a vector that points towards the extrude, but rotate
// it when we're drawing round end points (a_direction = -1 or 1) since their
// extrude vector points in another direction.
float u = 0.5 * a_direction;
float t = 1.0 - abs(u);
vec2 offset = u_offset * a_extrude * scale * normal.y * mat2(t, -u, u, t);
// Remove the texture normal bit of the position before scaling it with the
// model/view matrix. Add the extrusion vector *after* the model/view matrix
// because we're extruding the line in pixel space, regardless of the current
// tile's zoom level.
gl_Position = u_matrix * vec4(floor(a_pos * 0.5) + (offset + dist) / u_ratio, 0.0, 1.0);
v_tex_a = vec2(a_linesofar * u_patternscale_a.x, normal.y * u_patternscale_a.y + u_tex_y_a);
v_tex_b = vec2(a_linesofar * u_patternscale_b.x, normal.y * u_patternscale_b.y + u_tex_y_b);
// position of y on the screen
float y = gl_Position.y / gl_Position.w;
// how much features are squished in the y direction by the tilt
float squish_scale = length(a_extrude) / length(u_antialiasingmatrix * a_extrude);
// how much features are squished in all directions by the perspectiveness
float perspective_scale = 1.0 / (1.0 - min(y * u_extra, 0.9));
v_gamma_scale = perspective_scale * squish_scale;
}

View File

@@ -1,6 +1,6 @@
#include <mbgl/shader/linesdf_shader.hpp>
#include <mbgl/shader/linesdf.vertex.hpp>
#include <mbgl/shader/linesdf.fragment.hpp>
#include <mbgl/shader/linesdfpattern.vertex.hpp>
#include <mbgl/shader/linesdfpattern.fragment.hpp>
#include <mbgl/gl/gl.hpp>
#include <cstdio>
@@ -8,7 +8,7 @@
using namespace mbgl;
LineSDFShader::LineSDFShader(gl::GLObjectStore& glObjectStore)
: Shader("line", shaders::linesdf::vertex, shaders::linesdf::fragment, glObjectStore) {
: Shader("linesdfpattern", shaders::linesdfpattern::vertex, shaders::linesdfpattern::fragment, glObjectStore) {
a_data = MBGL_CHECK_ERROR(glGetAttribLocation(getID(), "a_data"));
}

View File

@@ -1,9 +0,0 @@
uniform vec4 u_color;
varying vec2 v_pos;
void main() {
float dist = length(v_pos - gl_FragCoord.xy);
float alpha = smoothstep(1.0, 0.0, dist);
gl_FragColor = u_color * alpha;
}

View File

@@ -1,10 +0,0 @@
attribute vec2 a_pos;
uniform mat4 u_matrix;
uniform vec2 u_world;
varying vec2 v_pos;
void main() {
gl_Position = u_matrix * vec4(a_pos, 0, 1);
v_pos = (gl_Position.xy / gl_Position.w + 1.0) / 2.0 * u_world;
}

View File

@@ -1,30 +0,0 @@
uniform float u_opacity;
uniform vec2 u_pattern_tl_a;
uniform vec2 u_pattern_br_a;
uniform vec2 u_pattern_tl_b;
uniform vec2 u_pattern_br_b;
uniform float u_mix;
uniform sampler2D u_image;
varying vec2 v_pos_a;
varying vec2 v_pos_b;
varying vec2 v_pos;
void main() {
vec2 imagecoord = mod(v_pos_a, 1.0);
vec2 pos = mix(u_pattern_tl_a, u_pattern_br_a, imagecoord);
vec4 color1 = texture2D(u_image, pos);
vec2 imagecoord_b = mod(v_pos_b, 1.0);
vec2 pos2 = mix(u_pattern_tl_b, u_pattern_br_b, imagecoord_b);
vec4 color2 = texture2D(u_image, pos2);
// find distance to outline for alpha interpolation
float dist = length(v_pos - gl_FragCoord.xy);
float alpha = smoothstep(1.0, 0.0, dist);
gl_FragColor = mix(color1, color2, u_mix) * alpha * u_opacity;
}

View File

@@ -1,21 +0,0 @@
uniform vec2 u_patternscale_a;
uniform vec2 u_patternscale_b;
uniform vec2 u_offset_a;
uniform vec2 u_offset_b;
attribute vec2 a_pos;
uniform mat4 u_matrix;
uniform vec2 u_world;
varying vec2 v_pos_a;
varying vec2 v_pos_b;
varying vec2 v_pos;
void main() {
gl_Position = u_matrix * vec4(a_pos, 0, 1);
v_pos_a = u_patternscale_a * a_pos + u_offset_a;
v_pos_b = u_patternscale_b * a_pos + u_offset_b;
v_pos = (gl_Position.xy/gl_Position.w + 1.0) / 2.0 * u_world;
}

View File

@@ -1,24 +0,0 @@
uniform float u_opacity;
uniform vec2 u_pattern_tl_a;
uniform vec2 u_pattern_br_a;
uniform vec2 u_pattern_tl_b;
uniform vec2 u_pattern_br_b;
uniform float u_mix;
uniform sampler2D u_image;
varying vec2 v_pos_a;
varying vec2 v_pos_b;
void main() {
vec2 imagecoord = mod(v_pos_a, 1.0);
vec2 pos = mix(u_pattern_tl_a, u_pattern_br_a, imagecoord);
vec4 color1 = texture2D(u_image, pos);
vec2 imagecoord_b = mod(v_pos_b, 1.0);
vec2 pos2 = mix(u_pattern_tl_b, u_pattern_br_b, imagecoord_b);
vec4 color2 = texture2D(u_image, pos2);
gl_FragColor = mix(color1, color2, u_mix) * u_opacity;
}

View File

@@ -1,17 +0,0 @@
uniform mat4 u_matrix;
uniform vec2 u_patternscale_a;
uniform vec2 u_patternscale_b;
uniform vec2 u_offset_a;
uniform vec2 u_offset_b;
attribute vec2 a_pos;
varying vec2 v_pos_a;
varying vec2 v_pos_b;
void main() {
gl_Position = u_matrix * vec4(a_pos, 0, 1);
v_pos_a = u_patternscale_a * a_pos + u_offset_a;
v_pos_b = u_patternscale_b * a_pos + u_offset_b;
}

View File

@@ -1,5 +0,0 @@
uniform vec4 u_color;
void main() {
gl_FragColor = u_color;
}

View File

@@ -1,7 +0,0 @@
attribute vec2 a_pos;
uniform mat4 u_matrix;
void main() {
gl_Position = u_matrix * vec4(a_pos, 0, 1);
}

View File

@@ -1,6 +1,6 @@
#include <mbgl/shader/plain_shader.hpp>
#include <mbgl/shader/plain.vertex.hpp>
#include <mbgl/shader/plain.fragment.hpp>
#include <mbgl/shader/fill.vertex.hpp>
#include <mbgl/shader/fill.fragment.hpp>
#include <mbgl/gl/gl.hpp>
#include <cstdio>
@@ -8,7 +8,7 @@
using namespace mbgl;
PlainShader::PlainShader(gl::GLObjectStore& glObjectStore)
: Shader("plain", shaders::plain::vertex, shaders::plain::fragment, glObjectStore) {
: Shader("fill", shaders::fill::vertex, shaders::fill::fragment, glObjectStore) {
}
void PlainShader::bind(GLbyte* offset) {

View File

@@ -1,36 +0,0 @@
uniform sampler2D u_image;
uniform float u_opacity;
varying vec2 v_pos;
uniform float u_brightness_low;
uniform float u_brightness_high;
uniform float u_saturation_factor;
uniform float u_contrast_factor;
uniform vec3 u_spin_weights;
void main() {
vec4 color = texture2D(u_image, v_pos) * u_opacity;
vec3 rgb = color.rgb;
// spin
rgb = vec3(
dot(rgb, u_spin_weights.xyz),
dot(rgb, u_spin_weights.zxy),
dot(rgb, u_spin_weights.yzx));
// saturation
float average = (color.r + color.g + color.b) / 3.0;
rgb += (average - rgb) * u_saturation_factor;
// contrast
rgb = (rgb - 0.5) * u_contrast_factor + 0.5;
// brightness
vec3 u_high_vec = vec3(u_brightness_low, u_brightness_low, u_brightness_low);
vec3 u_low_vec = vec3(u_brightness_high, u_brightness_high, u_brightness_high);
gl_FragColor = vec4(mix(u_high_vec, u_low_vec, rgb), color.a);
}

View File

@@ -1,13 +0,0 @@
uniform mat4 u_matrix;
uniform float u_buffer;
attribute vec2 a_pos;
varying vec2 v_pos;
void main() {
gl_Position = u_matrix * vec4(a_pos, 0, 1);
float dimension = (8192.0 + 2.0 * u_buffer);
v_pos = (a_pos / dimension) + (u_buffer / dimension);
}

View File

@@ -1,17 +0,0 @@
uniform sampler2D u_texture;
uniform sampler2D u_fadetexture;
uniform vec4 u_color;
uniform float u_buffer;
uniform float u_gamma;
varying vec2 v_tex;
varying vec2 v_fade_tex;
varying float v_gamma_scale;
void main() {
float dist = texture2D(u_texture, v_tex).a;
float fade_alpha = texture2D(u_fadetexture, v_fade_tex).a;
float gamma = u_gamma * v_gamma_scale;
float alpha = smoothstep(u_buffer - gamma, u_buffer + gamma, dist) * fade_alpha;
gl_FragColor = u_color * alpha;
}

View File

@@ -1,43 +0,0 @@
attribute vec2 a_pos;
attribute vec2 a_offset;
attribute vec4 a_data1;
attribute vec4 a_data2;
// matrix is for the vertex position, exmatrix is for rotating and projecting
// the extrusion vector.
uniform mat4 u_matrix;
uniform mat4 u_exmatrix;
uniform float u_zoom;
uniform bool u_skewed;
uniform vec2 u_texsize;
varying vec2 v_tex;
varying vec2 v_fade_tex;
varying float v_gamma_scale;
void main() {
vec2 a_tex = a_data1.xy;
float a_labelminzoom = a_data1[2];
float a_angle = a_data1[3];
vec2 a_zoom = a_data2.st;
float a_minzoom = a_zoom[0];
float a_maxzoom = a_zoom[1];
// u_zoom is the current zoom level adjusted for the change in font size
float show = step(a_minzoom, u_zoom) * (1.0 - step(a_maxzoom, u_zoom));
if (u_skewed) {
vec4 extrude = u_exmatrix * vec4(a_offset * show / 64.0, 0, 0);
gl_Position = u_matrix * vec4(a_pos + extrude.xy, 0, 1);
} else {
vec4 extrude = u_exmatrix * vec4(a_offset * show / 64.0, 0, 0);
gl_Position = u_matrix * vec4(a_pos, 0, 1) + extrude;
}
v_gamma_scale = (gl_Position.w - 0.5);
v_tex = a_tex / u_texsize;
v_fade_tex = vec2(a_labelminzoom / 255.0, 0.0);
}