diff options
Diffstat (limited to 'src/mbgl/shaders/fill_extrusion.cpp')
-rw-r--r-- | src/mbgl/shaders/fill_extrusion.cpp | 321 |
1 files changed, 168 insertions, 153 deletions
diff --git a/src/mbgl/shaders/fill_extrusion.cpp b/src/mbgl/shaders/fill_extrusion.cpp index 5bb2b9cd07..cff544acc1 100644 --- a/src/mbgl/shaders/fill_extrusion.cpp +++ b/src/mbgl/shaders/fill_extrusion.cpp @@ -1,164 +1,179 @@ // NOTE: DO NOT CHANGE THIS FILE. IT IS AUTOMATICALLY GENERATED. #include <mbgl/shaders/fill_extrusion.hpp> +#include <mbgl/util/compression.hpp> + +#include <cstdint> namespace mbgl { namespace shaders { const char* fill_extrusion::name = "fill_extrusion"; -const char* fill_extrusion::vertexSource = R"MBGL_SHADER( -uniform mat4 u_matrix; -uniform vec3 u_lightcolor; -uniform lowp vec3 u_lightpos; -uniform lowp float u_lightintensity; - -attribute vec2 a_pos; -attribute vec4 a_normal_ed; - -varying vec4 v_color; - - -#ifndef HAS_UNIFORM_u_base -uniform lowp float a_base_t; -attribute lowp vec2 a_base; -varying lowp float base; -#else -uniform lowp float u_base; -#endif - - -#ifndef HAS_UNIFORM_u_height -uniform lowp float a_height_t; -attribute lowp vec2 a_height; -varying lowp float height; -#else -uniform lowp float u_height; -#endif - - - -#ifndef HAS_UNIFORM_u_color -uniform lowp float a_color_t; -attribute highp vec4 a_color; -varying highp vec4 color; -#else -uniform highp vec4 u_color; -#endif - - -void main() { - -#ifndef HAS_UNIFORM_u_base - base = unpack_mix_vec2(a_base, a_base_t); -#else - lowp float base = u_base; -#endif - - -#ifndef HAS_UNIFORM_u_height - height = unpack_mix_vec2(a_height, a_height_t); -#else - lowp float height = u_height; -#endif - - -#ifndef HAS_UNIFORM_u_color - color = unpack_mix_vec4(a_color, a_color_t); -#else - highp vec4 color = u_color; -#endif - - - vec3 normal = a_normal_ed.xyz; - - base = max(0.0, base); - height = max(0.0, height); - - float t = mod(normal.x, 2.0); - - gl_Position = u_matrix * vec4(a_pos, t > 0.0 ? height : base, 1); - - // Relative luminance (how dark/bright is the surface color?) - float colorvalue = color.r * 0.2126 + color.g * 0.7152 + color.b * 0.0722; - - v_color = vec4(0.0, 0.0, 0.0, 1.0); - - // Add slight ambient lighting so no extrusions are totally black - vec4 ambientlight = vec4(0.03, 0.03, 0.03, 1.0); - color += ambientlight; - - // Calculate cos(theta), where theta is the angle between surface normal and diffuse light ray - float directional = clamp(dot(normal / 16384.0, u_lightpos), 0.0, 1.0); - - // Adjust directional so that - // the range of values for highlight/shading is narrower - // with lower light intensity - // and with lighter/brighter surface colors - directional = mix((1.0 - u_lightintensity), max((1.0 - colorvalue + u_lightintensity), 1.0), directional); - - // Add gradient along z axis of side surfaces - if (normal.y != 0.0) { - directional *= clamp((t + base) * pow(height / 150.0, 0.5), mix(0.7, 0.98, 1.0 - u_lightintensity), 1.0); - } - - // Assign final color based on surface + ambient light color, diffuse light directional, and light color - // with lower bounds adjusted to hue of light - // so that shading is tinted with the complementary (opposite) color to the light color - v_color.r += clamp(color.r * directional * u_lightcolor.r, mix(0.0, 0.3, 1.0 - u_lightcolor.r), 1.0); - v_color.g += clamp(color.g * directional * u_lightcolor.g, mix(0.0, 0.3, 1.0 - u_lightcolor.g), 1.0); - v_color.b += clamp(color.b * directional * u_lightcolor.b, mix(0.0, 0.3, 1.0 - u_lightcolor.b), 1.0); -} - -)MBGL_SHADER"; -const char* fill_extrusion::fragmentSource = R"MBGL_SHADER( -varying vec4 v_color; - -#ifndef HAS_UNIFORM_u_base -varying lowp float base; -#else -uniform lowp float u_base; -#endif - - -#ifndef HAS_UNIFORM_u_height -varying lowp float height; -#else -uniform lowp float u_height; -#endif - - -#ifndef HAS_UNIFORM_u_color -varying highp vec4 color; -#else -uniform highp vec4 u_color; -#endif - - -void main() { - -#ifdef HAS_UNIFORM_u_base - lowp float base = u_base; -#endif - - -#ifdef HAS_UNIFORM_u_height - lowp float height = u_height; -#endif - - -#ifdef HAS_UNIFORM_u_color - highp vec4 color = u_color; -#endif - - - gl_FragColor = v_color; - -#ifdef OVERDRAW_INSPECTOR - gl_FragColor = vec4(1.0); -#endif -} - -)MBGL_SHADER"; +const char* fill_extrusion::vertexSource = [] () { + static const uint8_t compressed[] = { + 0x78, 0xda, 0x8d, 0x56, 0xdb, 0x8e, 0xdb, 0x36, + 0x10, 0x7d, 0xf7, 0x57, 0x4c, 0x91, 0x17, 0x39, + 0xab, 0xfa, 0xb6, 0xde, 0x6c, 0xda, 0xc5, 0x26, + 0x08, 0x0a, 0x14, 0xed, 0x43, 0xda, 0x22, 0x45, + 0x9f, 0x05, 0xca, 0xa2, 0x24, 0x26, 0x14, 0x29, + 0x50, 0x94, 0x2f, 0x29, 0xf2, 0xef, 0x19, 0xde, + 0x74, 0x5b, 0xd9, 0xc8, 0x3e, 0x78, 0x2d, 0xce, + 0x70, 0xe6, 0xcc, 0x39, 0x33, 0x23, 0xb7, 0x82, + 0xe5, 0x52, 0x55, 0x50, 0x11, 0xbd, 0x87, 0x36, + 0xc1, 0x7f, 0x8a, 0x9d, 0x9f, 0x16, 0xad, 0x3f, + 0x3e, 0xd2, 0xc3, 0x3d, 0x1e, 0x73, 0x56, 0x94, + 0xfa, 0x20, 0xb9, 0x54, 0xbd, 0x89, 0xcb, 0x53, + 0x3d, 0xb2, 0xd7, 0xb2, 0x99, 0x58, 0x73, 0x2e, + 0x89, 0x0e, 0x66, 0x26, 0x34, 0x15, 0x0d, 0xd3, + 0x97, 0xa7, 0xc5, 0x82, 0x68, 0x4c, 0x93, 0xb6, + 0x9a, 0x9a, 0x00, 0x3b, 0x20, 0x89, 0xbd, 0x3b, + 0x3a, 0xdd, 0xe3, 0xa9, 0xc0, 0x48, 0x84, 0x27, + 0x34, 0xc3, 0x2b, 0x47, 0xa2, 0x2e, 0x4c, 0x14, + 0xce, 0x74, 0x4c, 0x3c, 0x98, 0xc5, 0xe2, 0x15, + 0xcb, 0x45, 0x46, 0x73, 0xf8, 0xe3, 0xc3, 0xbf, + 0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, 0xa6, 0x32, 0x59, 0x00, + 0x53, 0x39, 0x8c, 0xa3, 0x1d, 0x75, 0x37, 0x91, + 0xe8, 0x33, 0x18, 0xce, 0xd5, 0xf9, 0xf2, 0xf5, + 0x69, 0x31, 0x14, 0xa1, 0x22, 0xe7, 0x68, 0xb3, + 0xda, 0xc4, 0xf6, 0x19, 0xb3, 0x8d, 0x38, 0xea, + 0x8c, 0xee, 0x64, 0xe9, 0xaf, 0x3a, 0x12, 0xac, + 0x83, 0xcc, 0x22, 0x17, 0x7c, 0x75, 0x8e, 0x61, + 0xb7, 0xda, 0x04, 0x97, 0x82, 0x27, 0xff, 0x48, + 0xdc, 0x20, 0x4c, 0x0a, 0x8b, 0xd2, 0x2d, 0x2b, + 0x78, 0x0d, 0xbe, 0x4e, 0x5c, 0x22, 0x31, 0x46, + 0x78, 0x07, 0x18, 0x1e, 0xde, 0x87, 0x8c, 0xbf, + 0x82, 0xeb, 0x80, 0x6d, 0x08, 0xb3, 0x5e, 0xc3, + 0x27, 0xca, 0x89, 0x66, 0x47, 0x1c, 0xb0, 0xb6, + 0x62, 0x82, 0x88, 0x03, 0x85, 0xa8, 0x94, 0x27, + 0xc8, 0x88, 0xfa, 0xb2, 0x4e, 0x95, 0xbd, 0xc7, + 0x1a, 0xd0, 0x25, 0x85, 0xa6, 0x55, 0x39, 0x41, + 0xbb, 0xa5, 0xe4, 0xfd, 0x72, 0x80, 0xd5, 0x9e, + 0x1c, 0x09, 0x6f, 0x4d, 0xc9, 0xf6, 0x61, 0xa5, + 0x10, 0xcc, 0x66, 0xb5, 0xdb, 0xee, 0xde, 0xc0, + 0x9d, 0x3f, 0x2a, 0xec, 0xd1, 0xe3, 0xf6, 0x61, + 0xd7, 0x1d, 0xa5, 0xf6, 0x68, 0xf3, 0xb8, 0xdb, + 0x79, 0x44, 0x7e, 0x9d, 0x61, 0x18, 0x5b, 0x89, + 0x65, 0xa7, 0xff, 0xd8, 0xf6, 0x0c, 0x20, 0xf4, + 0x0f, 0x59, 0x06, 0x8d, 0x5d, 0xa8, 0x40, 0xaa, + 0x94, 0x51, 0xa1, 0xc1, 0xaf, 0xd7, 0x02, 0x1a, + 0x89, 0x02, 0x01, 0x3d, 0x6b, 0xd5, 0x36, 0x48, + 0x52, 0x03, 0x44, 0x51, 0xd0, 0x52, 0x13, 0xce, + 0x2f, 0x90, 0x72, 0x6c, 0x8b, 0xa0, 0xe4, 0x3e, + 0x5c, 0xe6, 0x5e, 0x95, 0x90, 0xf8, 0xde, 0x26, + 0xed, 0x3e, 0x5d, 0xee, 0xbe, 0xbd, 0xee, 0x9e, + 0x47, 0x17, 0x7b, 0x58, 0xbf, 0x11, 0x7e, 0x68, + 0x91, 0x54, 0x43, 0x54, 0x13, 0x21, 0x71, 0x9a, + 0x2c, 0x63, 0x38, 0x95, 0xd4, 0x20, 0x30, 0x4f, + 0x81, 0x4f, 0x22, 0x0a, 0x4e, 0x21, 0xa5, 0xfa, + 0x44, 0xa9, 0xe8, 0xd8, 0xf5, 0x7d, 0x45, 0x44, + 0x06, 0xd8, 0x71, 0x79, 0x8b, 0x6d, 0xe4, 0x90, + 0x29, 0x72, 0x19, 0x50, 0x9e, 0x31, 0x45, 0x0f, + 0x46, 0x7f, 0xdb, 0x83, 0x07, 0x4e, 0xaa, 0x3a, + 0xca, 0xa4, 0xf6, 0xed, 0x02, 0x6b, 0xd8, 0xbe, + 0xb9, 0x7f, 0xbb, 0x37, 0xa4, 0xf5, 0xef, 0xa4, + 0xe5, 0x15, 0x1a, 0x3f, 0xb7, 0xcd, 0x38, 0x20, + 0xb2, 0xa7, 0x4b, 0xa2, 0x83, 0x87, 0x01, 0xab, + 0x10, 0x2d, 0x05, 0x99, 0x83, 0x95, 0xb9, 0x01, + 0x5c, 0x5c, 0x76, 0x60, 0x6c, 0xec, 0x75, 0x53, + 0x92, 0xcc, 0xd0, 0x8e, 0x95, 0x09, 0xa2, 0x94, + 0x3c, 0x51, 0x15, 0x2e, 0x9f, 0x98, 0x2e, 0xc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 0x81, 0x37, 0x7c, 0xcb, 0xc1, + 0xa0, 0x93, 0x6c, 0x49, 0xbe, 0x35, 0x4c, 0x0b, + 0x1e, 0x64, 0x55, 0x73, 0x5a, 0x21, 0x3c, 0x7c, + 0xaf, 0x42, 0x24, 0xeb, 0xda, 0xac, 0x40, 0xa4, + 0xcc, 0x55, 0xa3, 0xa5, 0xf5, 0x9a, 0xa2, 0xf1, + 0x1b, 0x65, 0x65, 0x27, 0xd6, 0xb1, 0xdd, 0x6f, + 0xa8, 0x91, 0x18, 0xa3, 0x5f, 0x77, 0x2b, 0x15, + 0xe8, 0xb6, 0xec, 0xdf, 0x4f, 0xd8, 0xf6, 0x3e, + 0x23, 0xae, 0x43, 0xa6, 0x62, 0x9a, 0xa9, 0xb8, + 0x9d, 0xa9, 0xf8, 0x81, 0x4c, 0xc5, 0x6c, 0xa6, + 0x74, 0x9a, 0x29, 0xbd, 0x9d, 0x29, 0xfd, 0x81, + 0x4c, 0x69, 0x97, 0xe9, 0xdb, 0xe2, 0x3b, 0xe2, + 0x90, 0x8c, 0xa9 + }; + static std::string decompressed = util::decompress(std::string(reinterpret_cast<const char*>(compressed), sizeof(compressed))); + return decompressed.c_str(); +}(); +const char* fill_extrusion::fragmentSource = [] () { + static const uint8_t compressed[] = { + 0x78, 0xda, 0x7d, 0x52, 0xbb, 0x0a, 0xc2, 0x30, + 0x14, 0xdd, 0xf3, 0x15, 0x17, 0x5c, 0x74, 0x11, + 0x05, 0x37, 0x71, 0x10, 0xb5, 0xe8, 0xa0, 0x95, + 0xfa, 0x1a, 0x43, 0xb4, 0x49, 0x1b, 0x88, 0x89, + 0x54, 0x1b, 0x11, 0xf1, 0xdf, 0x6d, 0x9a, 0x50, + 0x35, 0x5a, 0x33, 0xde, 0xf3, 0xe2, 0x1c, 0xa2, + 0x49, 0x76, 0xe3, 0x32, 0x01, 0x4d, 0x0f, 0x3d, + 0xd0, 0xf8, 0xa0, 0x84, 0xca, 0xfa, 0x08, 0x35, + 0x38, 0x93, 0x31, 0x65, 0x30, 0x1d, 0xae, 0xf0, + 0x66, 0x31, 0x0b, 0xc2, 0x68, 0x8e, 0x73, 0xbc, + 0x27, 0x67, 0x8a, 0xb4, 0x53, 0x08, 0x75, 0x3d, + 0x01, 0x13, 0x8a, 0x5c, 0xc0, 0xdc, 0xfb, 0xa8, + 0x41, 0x45, 0x01, 0xe7, 0x92, 0x33, 0x95, 0x1d, + 0xdf, 0x61, 0x2b, 0x34, 0x04, 0x19, 0x73, 0x86, + 0xea, 0xdc, 0x53, 0xca, 0x93, 0xf4, 0xf2, 0xcb, + 0xdf, 0x22, 0x7f, 0x13, 0x5e, 0x94, 0xbf, 0x19, + 0x65, 0xbf, 0x2a, 0x22, 0x2d, 0x34, 0x27, 0x5b, + 0xdd, 0x15, 0xff, 0x4c, 0x78, 0xc3, 0x73, 0x5c, + 0x31, 0x5c, 0x80, 0x56, 0x3c, 0x86, 0x23, 0xe1, + 0xb2, 0xd9, 0x82, 0x3b, 0x82, 0xe2, 0x99, 0xcc, + 0x9a, 0xd1, 0x0c, 0xec, 0x0d, 0x06, 0x83, 0xaf, + 0x61, 0xea, 0x4d, 0xdc, 0x36, 0x9e, 0x8d, 0xbd, + 0x96, 0x46, 0x7e, 0xff, 0x7a, 0x2b, 0x3b, 0x81, + 0xc1, 0xfd, 0xfa, 0xa5, 0x91, 0x5f, 0xd3, 0x10, + 0x13, 0x81, 0x83, 0x8c, 0x24, 0x23, 0x47, 0xfa, + 0xf8, 0x26, 0x26, 0x20, 0xdc, 0x4e, 0xa2, 0x71, + 0x34, 0xdc, 0xe1, 0xd9, 0x62, 0xb5, 0x9c, 0x8c, + 0xd6, 0x61, 0xf4, 0x53, 0x56, 0x04, 0x35, 0xbb, + 0xed, 0x4e, 0xab, 0x72, 0x7f, 0xa0, 0x27, 0xc6, + 0x6e, 0xcd, 0x58 + }; + static std::string decompressed = util::decompress(std::string(reinterpret_cast<const char*>(compressed), sizeof(compressed))); + return decompressed.c_str(); +}(); } // namespace shaders } // namespace mbgl |