summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladimir Agafonkin <agafonkin@gmail.com>2018-02-07 18:34:52 +0200
committerVladimir Agafonkin <agafonkin@gmail.com>2018-02-07 18:34:52 +0200
commit1c20291cd666ea82999dfd94b5550bea9dfa2995 (patch)
tree46c7f5ee8c9d67479d4215816388b7a0caa4fafa
parent2f801e03e7f781cfea3c1c48cb2e6843675a9ec1 (diff)
downloadqtlocation-mapboxgl-1c20291cd666ea82999dfd94b5550bea9dfa2995.tar.gz
update heatmap shaders
-rwxr-xr-xscripts/generate-shaders.js3
-rw-r--r--src/mbgl/shaders/heatmap.cpp27
2 files changed, 20 insertions, 10 deletions
diff --git a/scripts/generate-shaders.js b/scripts/generate-shaders.js
index 46c097d51a..b1eeffb8a0 100755
--- a/scripts/generate-shaders.js
+++ b/scripts/generate-shaders.js
@@ -7,9 +7,6 @@ const outputPath = 'src/mbgl/shaders';
var shaders = require('../mapbox-gl-js/src/shaders');
-delete shaders.heatmap;
-delete shaders.heatmapTexture;
-
require('./style-code');
writeIfModified(path.join(outputPath, 'preludes.hpp'), `// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED.
diff --git a/src/mbgl/shaders/heatmap.cpp b/src/mbgl/shaders/heatmap.cpp
index 52bc493fe2..19927cfcc6 100644
--- a/src/mbgl/shaders/heatmap.cpp
+++ b/src/mbgl/shaders/heatmap.cpp
@@ -17,9 +17,16 @@ uniform highp float u_weight;
#endif
+#ifndef HAS_UNIFORM_u_radius
+uniform lowp float a_radius_t;
+attribute mediump vec2 a_radius;
+#else
+uniform mediump float u_radius;
+#endif
+
+
uniform mat4 u_matrix;
uniform float u_extrude_scale;
-uniform float u_radius;
uniform float u_opacity;
uniform float u_intensity;
@@ -36,13 +43,20 @@ const highp float ZERO = 1.0 / 255.0 / 16.0;
#define GAUSS_COEF 0.3989422804014327
void main(void) {
-
+
#ifndef HAS_UNIFORM_u_weight
weight = unpack_mix_vec2(a_weight, a_weight_t);
#else
highp float weight = u_weight;
#endif
+
+#ifndef HAS_UNIFORM_u_radius
+ mediump float radius = unpack_mix_vec2(a_radius, a_radius_t);
+#else
+ mediump float radius = u_radius;
+#endif
+
// unencode the extrusion vector that we snuck into the a_pos vector
vec2 unscaled_extrude = vec2(mod(a_pos, 2.0) * 2.0 - 1.0);
@@ -60,12 +74,12 @@ void main(void) {
// S = sqrt(-2.0 * log(ZERO / (weight * u_intensity * GAUSS_COEF))) / 3.0
float S = sqrt(-2.0 * log(ZERO / weight / u_intensity / GAUSS_COEF)) / 3.0;
- // Pass the varying in units of u_radius
+ // Pass the varying in units of radius
v_extrude = S * unscaled_extrude;
- // Scale by u_radius and the zoom-based scale factor to produce actual
+ // Scale by radius and the zoom-based scale factor to produce actual
// mesh position
- vec2 extrude = v_extrude * u_radius * u_extrude_scale;
+ vec2 extrude = v_extrude * radius * u_extrude_scale;
// multiply a_pos by 0.5, since we had it * 2 in order to sneak
// in extrusion data
@@ -85,14 +99,13 @@ uniform highp float u_weight;
uniform highp float u_intensity;
-uniform highp float u_radius;
varying vec2 v_extrude;
// Gaussian kernel coefficient: 1 / sqrt(2 * PI)
#define GAUSS_COEF 0.3989422804014327
void main() {
-
+
#ifdef HAS_UNIFORM_u_weight
highp float weight = u_weight;
#endif