summaryrefslogtreecommitdiff
path: root/src/mbgl/shaders/hillshade_prepare.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl/shaders/hillshade_prepare.cpp')
-rw-r--r--src/mbgl/shaders/hillshade_prepare.cpp249
1 files changed, 160 insertions, 89 deletions
diff --git a/src/mbgl/shaders/hillshade_prepare.cpp b/src/mbgl/shaders/hillshade_prepare.cpp
index 8d0571f6a4..d45942b476 100644
--- a/src/mbgl/shaders/hillshade_prepare.cpp
+++ b/src/mbgl/shaders/hillshade_prepare.cpp
@@ -1,100 +1,171 @@
// NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED.
#include <mbgl/shaders/hillshade_prepare.hpp>
+#include <mbgl/util/compression.hpp>
+
+#include <cstdint>
namespace mbgl {
namespace shaders {
const char* hillshade_prepare::name = "hillshade_prepare";
-const char* hillshade_prepare::vertexSource = R"MBGL_SHADER(
-uniform mat4 u_matrix;
-
-attribute vec2 a_pos;
-attribute vec2 a_texture_pos;
-
-varying vec2 v_pos;
-
-void main() {
- gl_Position = u_matrix * vec4(a_pos, 0, 1);
- v_pos = (a_texture_pos / 8192.0) / 2.0 + 0.25;
-}
-
-)MBGL_SHADER";
-const char* hillshade_prepare::fragmentSource = R"MBGL_SHADER(
-#ifdef GL_ES
-precision highp float;
-#endif
-
-uniform sampler2D u_image;
-varying vec2 v_pos;
-uniform vec2 u_dimension;
-uniform float u_zoom;
-uniform float u_maxzoom;
-
-float getElevation(vec2 coord, float bias) {
- // Convert encoded elevation value to meters
- vec4 data = texture2D(u_image, coord) * 255.0;
- return (data.r + data.g * 256.0 + data.b * 256.0 * 256.0) / 4.0;
-}
-
-void main() {
- vec2 epsilon = 1.0 / u_dimension;
-
- // queried pixels:
- // +-----------+
- // | | | |
- // | a | b | c |
- // | | | |
- // +-----------+
- // | | | |
- // | d | e | f |
- // | | | |
- // +-----------+
- // | | | |
- // | g | h | i |
- // | | | |
- // +-----------+
-
- float a = getElevation(v_pos + vec2(-epsilon.x, -epsilon.y), 0.0);
- float b = getElevation(v_pos + vec2(0, -epsilon.y), 0.0);
- float c = getElevation(v_pos + vec2(epsilon.x, -epsilon.y), 0.0);
- float d = getElevation(v_pos + vec2(-epsilon.x, 0), 0.0);
- float e = getElevation(v_pos, 0.0);
- float f = getElevation(v_pos + vec2(epsilon.x, 0), 0.0);
- float g = getElevation(v_pos + vec2(-epsilon.x, epsilon.y), 0.0);
- float h = getElevation(v_pos + vec2(0, epsilon.y), 0.0);
- float i = getElevation(v_pos + vec2(epsilon.x, epsilon.y), 0.0);
-
- // here we divide the x and y slopes by 8 * pixel size
- // where pixel size (aka meters/pixel) is:
- // circumference of the world / (pixels per tile * number of tiles)
- // which is equivalent to: 8 * 40075016.6855785 / (512 * pow(2, u_zoom))
- // which can be reduced to: pow(2, 19.25619978527 - u_zoom)
- // we want to vertically exaggerate the hillshading though, because otherwise
- // it is barely noticeable at low zooms. to do this, we multiply this by some
- // scale factor pow(2, (u_zoom - u_maxzoom) * a) where a is an arbitrary value
- // Here we use a=0.3 which works out to the expression below. see
- // nickidlugash's awesome breakdown for more info
- // https://github.com/mapbox/mapbox-gl-js/pull/5286#discussion_r148419556
- float exaggeration = u_zoom < 2.0 ? 0.4 : u_zoom < 4.5 ? 0.35 : 0.3;
-
- vec2 deriv = vec2(
- (c + f + f + i) - (a + d + d + g),
- (g + h + h + i) - (a + b + b + c)
- ) / pow(2.0, (u_zoom - u_maxzoom) * exaggeration + 19.2562 - u_zoom);
-
- gl_FragColor = clamp(vec4(
- deriv.x / 2.0 + 0.5,
- deriv.y / 2.0 + 0.5,
- 1.0,
- 1.0), 0.0, 1.0);
-
-#ifdef OVERDRAW_INSPECTOR
- gl_FragColor = vec4(1.0);
-#endif
-}
-
-)MBGL_SHADER";
+const char* hillshade_prepare::vertexSource = [] () {
+ static const uint8_t compressed[] = {
+ 0x78, 0xda, 0x65, 0x4d, 0x51, 0x0a, 0xc2, 0x30,
+ 0x14, 0xfb, 0xef, 0x29, 0xf2, 0xb9, 0xe9, 0x98,
+ 0x5b, 0x99, 0xa0, 0x14, 0xef, 0xe0, 0x0d, 0x46,
+ 0xd5, 0x3a, 0x1e, 0xb8, 0x76, 0x74, 0xed, 0x98,
+ 0x88, 0x77, 0xf7, 0xd9, 0xa1, 0x20, 0xbe, 0x9f,
+ 0x84, 0x24, 0x2f, 0x89, 0x96, 0xae, 0xce, 0xf7,
+ 0xe8, 0x75, 0x68, 0x10, 0x5b, 0x06, 0x4f, 0xb3,
+ 0x12, 0x42, 0x07, 0x26, 0xa7, 0x18, 0x0c, 0x26,
+ 0x73, 0x96, 0xd0, 0xed, 0xe0, 0x46, 0xf5, 0xaf,
+ 0x06, 0x33, 0x87, 0xe8, 0xcd, 0xe2, 0x8a, 0x49,
+ 0xfb, 0x3b, 0xd9, 0x6e, 0x31, 0xa7, 0x8f, 0xe8,
+ 0xe8, 0xc2, 0xf5, 0x64, 0xb3, 0x1c, 0x0f, 0x01,
+ 0xbe, 0xee, 0xd6, 0x1e, 0xdd, 0x48, 0x81, 0x9c,
+ 0xc5, 0xe1, 0x3b, 0x8a, 0xd5, 0xfb, 0xaf, 0xc9,
+ 0xd2, 0x54, 0x81, 0xaa, 0x40, 0x9d, 0xab, 0x94,
+ 0x4f, 0x4d, 0x9c, 0xcc, 0x7e, 0xf6, 0xb0, 0xc1,
+ 0xae, 0xde, 0xcb, 0xb2, 0xca, 0x99, 0x31, 0x60,
+ 0x8d, 0xaa, 0x94, 0x5b, 0x25, 0x9e, 0xe2, 0x05,
+ 0x6f, 0x64, 0x43, 0x2f
+ };
+ static std::string decompressed = util::decompress(std::string(reinterpret_cast<const char*>(compressed), sizeof(compressed)));
+ return decompressed.c_str();
+}();
+const char* hillshade_prepare::fragmentSource = [] () {
+ static const uint8_t compressed[] = {
+ 0x78, 0xda, 0xad, 0x56, 0x6d, 0x6f, 0xdb, 0x36,
+ 0x10, 0xfe, 0xee, 0x5f, 0x71, 0x40, 0x3e, 0x4c,
+ 0x5e, 0x1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68, 0x41,
+ 0x8c, 0xd2, 0xd3, 0x28, 0x9a, 0x7a, 0xca, 0xfa,
+ 0xbe, 0xb3, 0xbb, 0xb5, 0x2f, 0x64, 0x18, 0xfd,
+ 0x67, 0x29, 0x9f, 0x04, 0x75, 0xec, 0x1b, 0x39,
+ 0x1e, 0x3b, 0xd8, 0xfb, 0x5d, 0xc8, 0xd5, 0x5b,
+ 0xcd, 0x8a, 0x1b, 0x25, 0x29, 0xd5, 0xd7, 0x90,
+ 0x49, 0xfa, 0xea, 0xb1, 0x9f, 0x1d, 0xcb, 0xd1,
+ 0x7f, 0x17, 0x55, 0xb8, 0x25, 0xa3, 0xb1, 0x5b,
+ 0xf8, 0x51, 0x98, 0xcc, 0x3e, 0x3b, 0xdc, 0x1d,
+ 0x3e, 0xa4, 0xbd, 0xfe, 0xe4, 0x4f, 0x3f, 0x7d,
+ 0x66, 0xee, 0x27, 0xd9, 0x3f, 0xea, 0xbf, 0xca,
+ 0xde, 0xfd, 0x71, 0x77, 0x7f, 0x7b, 0xff, 0xc3,
+ 0x9f, 0xab, 0x9f, 0x7f, 0x7d, 0xff, 0xdb, 0xdd,
+ 0xcd, 0xef, 0xef, 0xee, 0x0f, 0x79, 0xe6, 0x7c,
+ 0xea, 0x15, 0xfd, 0x97, 0xda, 0xa7, 0xc9, 0xbf,
+ 0xfe, 0xd0, 0xd7, 0x60
+ };
+ static std::string decompressed = util::decompress(std::string(reinterpret_cast<const char*>(compressed), sizeof(compressed)));
+ return decompressed.c_str();
+}();
} // namespace shaders
} // namespace mbgl