summaryrefslogtreecommitdiff
path: root/src/mbgl/shaders/raster.cpp
diff options
context:
space:
mode:
authorChris Loer <chris.loer@gmail.com>2018-09-19 13:21:02 -0700
committerChris Loer <chris.loer@mapbox.com>2018-09-19 16:19:28 -0700
commitf7a69d15ab1f43598caaa9498cc7e8aa7a11af0c (patch)
treed02c7a07078e91123e0763f8c7ac120cff223777 /src/mbgl/shaders/raster.cpp
parent9b09ec1e6a4de3acfddd8dcd83e9c8596c60e0e0 (diff)
downloadqtlocation-mapboxgl-f7a69d15ab1f43598caaa9498cc7e8aa7a11af0c.tar.gz
[docs] Include uncompressed shader source in .cpp comments
This is meant to (1) Make it easier for new developers to find the source (2) Make it easier to look at shader diffs when the GL JS pin changes
Diffstat (limited to 'src/mbgl/shaders/raster.cpp')
-rw-r--r--src/mbgl/shaders/raster.cpp83
1 files changed, 83 insertions, 0 deletions
diff --git a/src/mbgl/shaders/raster.cpp b/src/mbgl/shaders/raster.cpp
index b17d013546..67d7542516 100644
--- a/src/mbgl/shaders/raster.cpp
+++ b/src/mbgl/shaders/raster.cpp
@@ -10,5 +10,88 @@ const char* raster::name = "raster";
const char* raster::vertexSource = source() + 68497;
const char* raster::fragmentSource = source() + 69310;
+// Uncompressed source of raster.vertex.glsl:
+/*
+uniform mat4 u_matrix;
+uniform vec2 u_tl_parent;
+uniform float u_scale_parent;
+uniform float u_buffer_scale;
+
+attribute vec2 a_pos;
+attribute vec2 a_texture_pos;
+
+varying vec2 v_pos0;
+varying vec2 v_pos1;
+
+void main() {
+ gl_Position = u_matrix * vec4(a_pos, 0, 1);
+ // 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;
+}
+
+*/
+
+// Uncompressed source of raster.fragment.glsl:
+/*
+uniform float u_fade_t;
+uniform float u_opacity;
+uniform sampler2D u_image0;
+uniform sampler2D u_image1;
+varying vec2 v_pos0;
+varying vec2 v_pos1;
+
+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() {
+
+ // 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;
+
+ // 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, color.a);
+
+#ifdef OVERDRAW_INSPECTOR
+ gl_FragColor = vec4(1.0);
+#endif
+}
+
+*/
+
} // namespace shaders
} // namespace mbgl