summaryrefslogtreecommitdiff
path: root/src/mbgl/shaders/raster.cpp
diff options
context:
space:
mode:
authorLangston Smith <langston.smith@mapbox.com>2018-01-04 11:15:50 -0800
committerGitHub <noreply@github.com>2018-01-04 11:15:50 -0800
commit2ea955d2751ba6459f99a0695e53505c0a11702b (patch)
treef54450918b634a2eea1bd2c4ebc671bf1bb06106 /src/mbgl/shaders/raster.cpp
parentf2ec6ae326bad79fea2b06a21151a2835522572a (diff)
parentc62b0af24fc76b4bb2eb34100611dd3ee9ee5536 (diff)
downloadqtlocation-mapboxgl-2ea955d2751ba6459f99a0695e53505c0a11702b.tar.gz
Merge branch 'master' into ls-android-readme-tweaksupstream/ls-android-readme-tweaks
Diffstat (limited to 'src/mbgl/shaders/raster.cpp')
-rw-r--r--src/mbgl/shaders/raster.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/mbgl/shaders/raster.cpp b/src/mbgl/shaders/raster.cpp
index eb7a2db240..98291bfec6 100644
--- a/src/mbgl/shaders/raster.cpp
+++ b/src/mbgl/shaders/raster.cpp
@@ -20,7 +20,12 @@ varying vec2 v_pos1;
void main() {
gl_Position = u_matrix * vec4(a_pos, 0, 1);
- v_pos0 = (((a_texture_pos / 32767.0) - 0.5) / u_buffer_scale ) + 0.5;
+ // We are using Int16 for texture position coordinates to give us enough precision for
+ // fractional coordinates. We use 8192 to scale the texture coordinates in the buffer
+ // as an arbitrarily high number to preserve adequate precision when rendering.
+ // This is also the same value as the EXTENT we are using for our tile buffer pos coordinates,
+ // so math for modifying either is consistent.
+ v_pos0 = (((a_texture_pos / 8192.0) - 0.5) / u_buffer_scale ) + 0.5;
v_pos1 = (v_pos0 * u_scale_parent) + u_tl_parent;
}
@@ -45,6 +50,12 @@ void main() {
// read and cross-fade colors from the main and parent tiles
vec4 color0 = texture2D(u_image0, v_pos0);
vec4 color1 = texture2D(u_image1, v_pos1);
+ if (color0.a > 0.0) {
+ color0.rgb = color0.rgb / color0.a;
+ }
+ if (color1.a > 0.0) {
+ color1.rgb = color1.rgb / color1.a;
+ }
vec4 color = mix(color0, color1, u_fade_t);
color.a *= u_opacity;
vec3 rgb = color.rgb;