diff options
Diffstat (limited to 'src/mbgl/shaders/raster.cpp')
-rw-r--r-- | src/mbgl/shaders/raster.cpp | 211 |
1 files changed, 132 insertions, 79 deletions
diff --git a/src/mbgl/shaders/raster.cpp b/src/mbgl/shaders/raster.cpp index 98291bfec6..e28cb5b726 100644 --- a/src/mbgl/shaders/raster.cpp +++ b/src/mbgl/shaders/raster.cpp @@ -1,90 +1,143 @@ // NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. #include <mbgl/shaders/raster.hpp> +#include <mbgl/util/compression.hpp> + +#include <cstdint> namespace mbgl { namespace shaders { const char* raster::name = "raster"; -const char* raster::vertexSource = R"MBGL_SHADER( -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; -} - -)MBGL_SHADER"; -const char* raster::fragmentSource = R"MBGL_SHADER( -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 -} - -)MBGL_SHADER"; +const char* raster::vertexSource = [] () { + static const uint8_t compressed[] = { + 0x78, 0xda, 0x75, 0x92, 0xcb, 0x4e, 0xc3, 0x40, + 0x0c, 0x45, 0xf7, 0xf9, 0x0a, 0x2f, 0x13, 0x28, + 0x6d, 0x83, 0x00, 0x81, 0x22, 0x96, 0x5d, 0xb0, + 0x41, 0x2c, 0x2a, 0xc1, 0xae, 0x9a, 0x26, 0x4e, + 0x63, 0x69, 0x32, 0x53, 0xe6, 0x51, 0x40, 0x88, + 0x7f, 0xc7, 0x4e, 0x9a, 0x36, 0xe5, 0x91, 0x4d, + 0x24, 0x3f, 0xce, 0xbd, 0xb6, 0x27, 0x1a, 0xaa, + 0xad, 0x6b, 0xa1, 0x55, 0xe1, 0x0a, 0xe2, 0x8a, + 0x7f, 0x8e, 0xde, 0x8b, 0x24, 0xee, 0xc3, 0x3b, + 0x2c, 0x2f, 0x39, 0x1c, 0xf4, 0x6a, 0xab, 0x1c, + 0x9a, 0x70, 0xcc, 0xd4, 0xda, 0xaa, 0xc0, 0x29, + 0x5f, 0x2a, 0x8d, 0xff, 0x66, 0xd7, 0xb1, 0xae, + 0xd1, 0xf5, 0x45, 0x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, + 0x1a, 0x39, 0x7c, 0x6b, 0xd0, 0x00, 0x1f, 0xb0, + 0x42, 0xc7, 0x33, 0x4f, 0x07, 0xe6, 0xb2, 0x21, + 0x56, 0x63, 0xb0, 0xf6, 0xb6, 0x93, 0xf4, 0xaa, + 0xe5, 0x1b, 0x29, 0x1d, 0x51, 0xf4, 0x24, 0xb2, + 0x78, 0x59, 0x2e, 0x1e, 0x97, 0xf0, 0x36, 0x5e, + 0x99, 0x2c, 0xcb, 0x46, 0x16, 0x25, 0x3d, 0xb8, + 0x94, 0xa5, 0x8d, 0x67, 0x98, 0x0c, 0x12, 0x0c, + 0xe6, 0x8b, 0x34, 0x5d, 0x4f, 0x6b, 0x2b, 0xaa, + 0xbb, 0xa3, 0x22, 0x31, 0xdb, 0x89, 0x74, 0x69, + 0x8d, 0x27, 0x1f, 0xf8, 0x6d, 0xf5, 0xae, 0xfa, + 0xf3, 0xf3, 0x25, 0xd3, 0x34, 0x3d, 0x79, 0x27, + 0x30, 0xeb, 0xb6, 0x37, 0x9d, 0x67, 0x70, 0x01, + 0xf3, 0xe9, 0x75, 0xc6, 0x81, 0xd3, 0xe7, 0x07, + 0x19, 0x9c, 0x4b, 0xa6, 0x38, 0x82, 0x72, 0x01, + 0xed, 0x91, 0x67, 0x3f, 0xde, 0xb2, 0x54, 0x9f, + 0x3c, 0xfc, 0xaf, 0xe4, 0x1b, 0x93, 0x50, 0x12, + 0x27 + }; + static std::string decompressed = util::decompress(std::string(reinterpret_cast<const char*>(compressed), sizeof(compressed))); + return decompressed.c_str(); +}(); +const char* raster::fragmentSource = [] () { + static const uint8_t compressed[] = { + 0x78, 0xda, 0x8d, 0x53, 0x4d, 0x6f, 0x9c, 0x30, + 0x10, 0xbd, 0xf3, 0x2b, 0x46, 0xca, 0x05, 0x12, + 0x87, 0x85, 0xdd, 0xf6, 0x84, 0x52, 0x29, 0xca, + 0x26, 0x52, 0x2f, 0x4d, 0xb5, 0xad, 0xda, 0x23, + 0xf2, 0x82, 0x61, 0x2d, 0x01, 0x5e, 0xd9, 0x86, + 0xec, 0x6e, 0x95, 0xff, 0xde, 0x31, 0x98, 0x8f, + 0xec, 0x47, 0x12, 0x4e, 0xc3, 0xcc, 0xf3, 0x7b, + 0x33, 0xcf, 0xe3, 0xba, 0xe2, 0x99, 0x90, 0x25, + 0x64, 0x85, 0xa0, 0x1a, 0xea, 0x38, 0xa3, 0x29, + 0x8b, 0x75, 0xe4, 0xd4, 0x47, 0x79, 0xb1, 0xa5, + 0x09, 0xd7, 0xfb, 0xb1, 0xa0, 0x68, 0xb9, 0x2d, + 0x98, 0x9c, 0x2f, 0xb1, 0xc8, 0x4b, 0x9a, 0xb3, + 0xe0, 0x9d, 0x5a, 0x18, 0x39, 0x0d, 0x95, 0x7b, + 0x5e, 0xe5, 0xd0, 0xb0, 0x64, 0x0e, 0x4d, 0xbc, + 0x15, 0x2a, 0x38, 0x97, 0x44, 0xe4, 0x89, 0xf6, + 0x5a, 0xf2, 0x7c, 0xa3, 0x2b, 0xa6, 0x54, 0x5c, + 0x88, 0x97, 0xe8, 0xbd, 0xfa, 0x06, 0xa3, 0x33, + 0x0c, 0x8a, 0xea, 0x5a, 0x52, 0xcd, 0x45, 0x85, + 0x03, 0x26, 0x5a, 0xc8, 0x53, 0x92, 0x44, 0x54, + 0x5a, 0x52, 0xa5, 0x4f, 0x00, 0xd8, 0xdb, 0xc2, + 0x50, 0x6c, 0x79, 0x15, 0xbf, 0x30, 0xa3, 0xa4, + 0x50, 0xa1, 0x11, 0x3c, 0x85, 0x92, 0xf2, 0xca, + 0xf5, 0xe0, 0x9f, 0xe3, 0x00, 0x7e, 0xb3, 0x19, + 0x48, 0x46, 0x53, 0xa0, 0x55, 0x0a, 0x89, 0x14, + 0x4a, 0xdd, 0x1a, 0x33, 0x21, 0x11, 0x85, 0x90, + 0x0a, 0x32, 0x29, 0x4a, 0xd0, 0x1b, 0xd6, 0x1e, + 0x6a, 0x31, 0x5b, 0x2a, 0x59, 0xa5, 0x41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9f, 0x5f, 0xfb, 0x5e, 0xbd, 0x5f, 0xf7, + 0x89, 0x23, 0xa6, 0x69, 0x3c, 0x1d, 0xf8, 0x5f, + 0xbb, 0xd3, 0x47, 0x2f, 0x02, 0xe5, 0xb1, 0x34, + 0x32, 0x8c, 0xaf, 0x6e, 0x34, 0xbf, 0x6e, 0x1f, + 0x60, 0x8c, 0x71, 0xef, 0xf0, 0xf1, 0xeb, 0x25, + 0xf0, 0x71, 0xc6, 0x8b, 0xa6, 0x8c, 0x98, 0xb8, + 0x48, 0x68, 0xd4, 0x08, 0x7c, 0x26, 0xd5, 0x1b, + 0x9f, 0x17, 0xf1, 0x13, 0xda, 0xf4, 0x60, 0xf7, + 0xcd, 0x2c, 0x9f, 0x6b, 0x96, 0x6e, 0xec, 0x9c, + 0x8c, 0x9a, 0xa4, 0xb7, 0xd2, 0xee, 0x1c, 0xe9, + 0x03, 0xc3, 0x76, 0xc5, 0xb3, 0x94, 0x65, 0xf0, + 0xfc, 0xe7, 0x71, 0xb5, 0x5c, 0xdd, 0xff, 0x8d, + 0xbf, 0xff, 0xf8, 0xf5, 0xf3, 0xf1, 0xe1, 0xf7, + 0xf3, 0xea, 0xa2, 0x4e, 0xe8, 0x9b, 0xa7, 0x7b, + 0xc5, 0xaa, 0x94, 0x67, 0xce, 0xab, 0xf3, 0x1f, + 0x04, 0xbd, 0xc0, 0x04 + }; + static std::string decompressed = util::decompress(std::string(reinterpret_cast<const char*>(compressed), sizeof(compressed))); + return decompressed.c_str(); +}(); } // namespace shaders } // namespace mbgl |