From cf31a809207d6cd27255ce68eb07e53b8dc898fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20Ka=CC=88fer?= Date: Wed, 5 Feb 2014 19:03:44 +0100 Subject: [PATCH] textured fills & enforce vao program with templates --- bin/style.js | 4 +- include/llmr/geometry/vao.hpp | 27 +++++----- include/llmr/map/tile.hpp | 3 +- include/llmr/renderer/fill_bucket.hpp | 32 +++--------- include/llmr/renderer/line_bucket.hpp | 2 +- include/llmr/renderer/painter.hpp | 9 ++-- include/llmr/renderer/shader-fill.hpp | 21 -------- include/llmr/renderer/shader-line.hpp | 2 +- include/llmr/renderer/shader-outline.hpp | 2 +- include/llmr/renderer/shader-pattern.hpp | 2 + include/llmr/renderer/shader-plain.hpp | 2 +- include/llmr/shader/shaders.hpp | 1 - resources/style.pbf | Bin 1032 -> 1050 bytes src/renderer/fill_bucket.cpp | 21 ++++++++ src/renderer/painter.cpp | 64 +++++++++++------------ src/renderer/shader-fill.cpp | 28 ---------- src/renderer/shader-line.cpp | 2 +- src/renderer/shader-outline.cpp | 2 +- src/renderer/shader-pattern.cpp | 5 ++ src/renderer/shader-plain.cpp | 2 +- src/shader/fill.fragment.glsl | 5 -- src/shader/fill.vertex.glsl | 7 --- src/shader/shaders.cpp | 4 -- src/style/resources.cpp | 45 ++++++++-------- 24 files changed, 114 insertions(+), 178 deletions(-) delete mode 100644 include/llmr/renderer/shader-fill.hpp delete mode 100644 src/renderer/shader-fill.cpp delete mode 100644 src/shader/fill.fragment.glsl delete mode 100644 src/shader/fill.vertex.glsl diff --git a/bin/style.js b/bin/style.js index ae2c353d2..4099b420d 100644 --- a/bin/style.js +++ b/bin/style.js @@ -83,7 +83,7 @@ module.exports = { "type": "fill", "color": "#c8df9f", "antialias": true, - // "image": "park" + "image": "park" }, "wood": { "type": "fill", @@ -96,7 +96,7 @@ module.exports = { "color": "#bae0e9", "stroke": "#73b6e6", "antialias": true, - // "image": "water_etsy" + "image": "water_etsy" }, "building": { "type": "fill", diff --git a/include/llmr/geometry/vao.hpp b/include/llmr/geometry/vao.hpp index d99ae6c78..6d710d831 100644 --- a/include/llmr/geometry/vao.hpp +++ b/include/llmr/geometry/vao.hpp @@ -7,28 +7,26 @@ namespace llmr { +template class VertexArrayObject { public: - template - void bind(Shader& shader, VertexBuffer& vertex_buffer, char *vertex_offset) { + template + void bind(Shader& shader, Buffer& buffer, char *offset) { if (!vao) { glGenVertexArrays(1, &vao); glBindVertexArray(vao); - vertex_buffer.bind(); - shader.bind_vertex(vertex_offset); + buffer.bind(); + shader.bind(offset); - program = shader.program; - buffer = &vertex_buffer; - offset = vertex_offset; - } else if (program != shader.program) { - throw std::runtime_error("trying to bind VAO to different program"); - } else if (buffer != &vertex_buffer) { + buffer_ptr = &buffer; + offset_ptr = offset; + } else if (buffer_ptr != &buffer) { throw std::runtime_error("trying to bind VAO to another buffer"); - } else if (offset != vertex_offset) { + } else if (offset_ptr != offset) { throw std::runtime_error("trying to bind VAO to another offset"); } else { - // This is the correct program for this VAO. + // We have been given the correct information. glBindVertexArray(vao); } } @@ -44,9 +42,8 @@ private: // For debug reasons, we're storing the bind information so that we can // detect errors and report - GLuint program = 0; - void *buffer = NULL; - char *offset = 0; + void *buffer_ptr = NULL; + char *offset_ptr = 0; }; } diff --git a/include/llmr/map/tile.hpp b/include/llmr/map/tile.hpp index a6457a58a..2569764cc 100644 --- a/include/llmr/map/tile.hpp +++ b/include/llmr/map/tile.hpp @@ -22,6 +22,7 @@ class VectorTile; class VectorTileLayer; class FillBuffer; class LineBuffer; +class PlainShader; class Tile : public std::enable_shared_from_this { public: @@ -73,7 +74,7 @@ public: // Holds the actual geometries in this tile. DebugFontBuffer debugFontBuffer; - VertexArrayObject debugFontArray; + VertexArrayObject debugFontArray; std::shared_ptr fillBuffer; std::shared_ptr lineBuffer; diff --git a/include/llmr/renderer/fill_bucket.hpp b/include/llmr/renderer/fill_bucket.hpp index 6c54107c3..e980125b1 100644 --- a/include/llmr/renderer/fill_bucket.hpp +++ b/include/llmr/renderer/fill_bucket.hpp @@ -18,6 +18,8 @@ namespace llmr { class Style; class FillBuffer; class BucketDescription; +class OutlineShader; +class PlainShader; struct Coordinate; struct pbf; @@ -31,8 +33,8 @@ public: void addGeometry(const std::vector& line); uint32_t size() const; - template void drawElements(Shader& shader); - template void drawVertices(Shader& shader); + void drawElements(PlainShader& shader); + void drawVertices(OutlineShader& shader); public: const BucketGeometryDescription geom_desc; @@ -41,7 +43,7 @@ private: std::shared_ptr buffer; struct group { - VertexArrayObject array; + VertexArrayObject array; uint32_t vertex_length; uint32_t elements_length; @@ -56,32 +58,10 @@ private: uint32_t vertex_start; uint32_t elements_start; uint32_t length; - VertexArrayObject array; + VertexArrayObject array; std::vector groups; }; - -template -void FillBucket::drawElements(Shader& shader) { - char *vertex_index = BUFFER_OFFSET(vertex_start * 2 * sizeof(int16_t)); - char *elements_index = BUFFER_OFFSET(elements_start * 3 * sizeof(int16_t)); - for (group& group : groups) { - group.array.bind(shader, *buffer, vertex_index); - glDrawElements(GL_TRIANGLES, group.elements_length * 3 - 3, GL_UNSIGNED_SHORT, elements_index); - vertex_index += group.vertex_length * 2 * sizeof(uint16_t); - elements_index += group.elements_length * 3 * sizeof(uint16_t); - } -} - -template -void FillBucket::drawVertices(Shader& shader) { - // Draw the entire line - char *vertex_index = BUFFER_OFFSET(vertex_start * 2 * sizeof(int16_t)); - array.bind(shader, *buffer, vertex_index); - glDrawArrays(GL_LINE_STRIP, 0, length); -} - - } #endif diff --git a/include/llmr/renderer/line_bucket.hpp b/include/llmr/renderer/line_bucket.hpp index 677adbdd4..7d61af15e 100644 --- a/include/llmr/renderer/line_bucket.hpp +++ b/include/llmr/renderer/line_bucket.hpp @@ -37,7 +37,7 @@ private: std::shared_ptr buffer; uint32_t start; uint32_t length; - VertexArrayObject array; + VertexArrayObject array; }; } diff --git a/include/llmr/renderer/painter.hpp b/include/llmr/renderer/painter.hpp index b638fcca1..b991c9592 100644 --- a/include/llmr/renderer/painter.hpp +++ b/include/llmr/renderer/painter.hpp @@ -7,7 +7,6 @@ #include #include -#include #include #include #include @@ -58,7 +57,6 @@ private: mat4 matrix; mat4 exMatrix; - std::unique_ptr fillShader; std::unique_ptr plainShader; std::unique_ptr outlineShader; std::unique_ptr lineShader; @@ -77,7 +75,8 @@ private: 4096, 4096 }; - VertexArrayObject tileStencilArray; + VertexArrayObject coveringPlainArray; + VertexArrayObject coveringPatternArray; // Set up the tile boundary lines we're using to draw the tile outlines. VertexBuffer tileBorderBuffer = { @@ -88,7 +87,7 @@ private: 0, 0 }; - VertexArrayObject tileBorderArray; + VertexArrayObject tileBorderArray; // Set up the matte buffer we're using to draw the filling background. VertexBuffer matteBuffer = { @@ -103,7 +102,7 @@ private: 16384, 16384 }; - VertexArrayObject matteArray; + VertexArrayObject matteArray; }; } diff --git a/include/llmr/renderer/shader-fill.hpp b/include/llmr/renderer/shader-fill.hpp deleted file mode 100644 index beff61592..000000000 --- a/include/llmr/renderer/shader-fill.hpp +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef LLMR_RENDERER_SHADER_FILL -#define LLMR_RENDERER_SHADER_FILL - -#include "shader.hpp" - -namespace llmr { - -class FillShader : public Shader { -public: - FillShader(); - - void bind_vertex(char *offset); - - int32_t a_pos; - int32_t u_matrix; - int32_t u_color; -}; - -} - -#endif diff --git a/include/llmr/renderer/shader-line.hpp b/include/llmr/renderer/shader-line.hpp index f33e26e51..00e50c1b1 100644 --- a/include/llmr/renderer/shader-line.hpp +++ b/include/llmr/renderer/shader-line.hpp @@ -9,7 +9,7 @@ class LineShader : public Shader { public: LineShader(); - void bind_vertex(char *offset); + void bind(char *offset); int32_t a_pos; int32_t a_extrude; diff --git a/include/llmr/renderer/shader-outline.hpp b/include/llmr/renderer/shader-outline.hpp index eda1bb88b..c584487e3 100644 --- a/include/llmr/renderer/shader-outline.hpp +++ b/include/llmr/renderer/shader-outline.hpp @@ -9,7 +9,7 @@ class OutlineShader : public Shader { public: OutlineShader(); - void bind_vertex(char *offset); + void bind(char *offset); int32_t a_pos; int32_t u_matrix; diff --git a/include/llmr/renderer/shader-pattern.hpp b/include/llmr/renderer/shader-pattern.hpp index 5b295cfff..26dac99fa 100644 --- a/include/llmr/renderer/shader-pattern.hpp +++ b/include/llmr/renderer/shader-pattern.hpp @@ -9,6 +9,8 @@ class PatternShader : public Shader { public: PatternShader(); + void bind(char *offset); + int32_t a_pos; int32_t u_matrix; int32_t u_color; diff --git a/include/llmr/renderer/shader-plain.hpp b/include/llmr/renderer/shader-plain.hpp index dd3a57102..d38ae5798 100644 --- a/include/llmr/renderer/shader-plain.hpp +++ b/include/llmr/renderer/shader-plain.hpp @@ -9,7 +9,7 @@ class PlainShader : public Shader { public: PlainShader(); - void bind_vertex(char *offset); + void bind(char *offset); int32_t a_pos; int32_t u_matrix; diff --git a/include/llmr/shader/shaders.hpp b/include/llmr/shader/shaders.hpp index 065b8d47f..d3007b2cc 100644 --- a/include/llmr/shader/shaders.hpp +++ b/include/llmr/shader/shaders.hpp @@ -11,7 +11,6 @@ struct shader_source { }; enum { - FILL_SHADER, LINE_SHADER, OUTLINE_SHADER, PATTERN_SHADER, diff --git a/resources/style.pbf b/resources/style.pbf index 69475487d5afbc5de084fa8754d05505ae815014..d87f896d1a0fb748df9b35975d0a89243905cc9b 100644 GIT binary patch delta 75 zcmeC+n8mSS50l0nCNB1r)U?FXoDv~vE|!ACqHHA&4kjTM28ITE-T(9NpKt;TPQJ&a c#Hc=*ky)C@iK{%ZB(*3$wWPRmvJCSZ0Ahs~p#T5? delta 79 zcmbQm(ZR7{50la(); plainShader = std::make_unique(); outlineShader = std::make_unique(); lineShader = std::make_unique(); @@ -94,7 +92,7 @@ void Painter::drawClippingMask() { glStencilOp(GL_REPLACE, GL_KEEP, GL_KEEP); - tileStencilArray.bind(*plainShader, tileStencilBuffer, BUFFER_OFFSET(0)); + coveringPlainArray.bind(*plainShader, tileStencilBuffer, BUFFER_OFFSET(0)); // Draw the clipping mask glUniform4f(plainShader->u_color, 1.0f, 0.0f, 1.0f, 1.0f); @@ -195,11 +193,11 @@ void Painter::renderFill(FillBucket& bucket, const std::string& layer_name, cons glColorMask(false, false, false, false); // Draw the actual triangle fan into the stencil buffer. - glUseProgram(fillShader->program); - glUniformMatrix4fv(fillShader->u_matrix, 1, GL_FALSE, matrix.data()); + glUseProgram(plainShader->program); + glUniformMatrix4fv(plainShader->u_matrix, 1, GL_FALSE, matrix.data()); // Draw all groups - bucket.drawElements(*fillShader); + bucket.drawElements(*plainShader); // Now that we have the stencil mask in the stencil buffer, we can start // writing to the color buffer. @@ -243,42 +241,40 @@ void Painter::renderFill(FillBucket& bucket, const std::string& layer_name, cons glStencilFunc(GL_NOTEQUAL, 0x0, 0x3F); if (properties.image.size() && style.sprite) { - // TODO: - // // Draw texture fill - // ImagePosition imagePos = style.sprite->getPosition(properties.image, true); + // Draw texture fill + ImagePosition imagePos = style.sprite->getPosition(properties.image, true); - // double factor = 8.0 / pow(2, transform.getIntegerZoom() - id.z); - // double mix = fmod(transform.getZoom(), 1.0); - // vec2 imageSize { imagePos.size.x * factor, imagePos.size.y * factor }; + double factor = 8.0 / pow(2, transform.getIntegerZoom() - id.z); + double mix = fmod(transform.getZoom(), 1.0); + vec2 imageSize { imagePos.size.x * factor, imagePos.size.y * factor }; - // vec2 offset { - // fmod(id.x * 4096, imageSize.x), - // fmod(id.y * 4096, imageSize.y) - // }; + vec2 offset { + fmod(id.x * 4096, imageSize.x), + fmod(id.y * 4096, imageSize.y) + }; - // switchShader(patternShader); - // glUniformMatrix4fv(patternShader->u_matrix, 1, GL_FALSE, matrix.data()); - // glUniform2f(patternShader->u_pattern_size, imageSize.x, imageSize.y); - // glUniform2f(patternShader->u_offset, offset.x, offset.y); - // glUniform2f(patternShader->u_pattern_tl, imagePos.tl.x, imagePos.tl.y); - // glUniform2f(patternShader->u_pattern_br, imagePos.br.x, imagePos.br.y); - // glUniform4fv(patternShader->u_color, 1, fill_color.data()); - // glUniform1f(patternShader->u_mix, mix); - // style.sprite->bind(true); + glUseProgram(patternShader->program); + glUniformMatrix4fv(patternShader->u_matrix, 1, GL_FALSE, matrix.data()); + glUniform2f(patternShader->u_pattern_size, imageSize.x, imageSize.y); + glUniform2f(patternShader->u_offset, offset.x, offset.y); + glUniform2f(patternShader->u_pattern_tl, imagePos.tl.x, imagePos.tl.y); + glUniform2f(patternShader->u_pattern_br, imagePos.br.x, imagePos.br.y); + glUniform4fv(patternShader->u_color, 1, fill_color.data()); + glUniform1f(patternShader->u_mix, mix); + style.sprite->bind(true); - // // Draw a rectangle that covers the entire viewport. - // tileStencilBuffer.bind(); - // glVertexAttribPointer(patternShader->a_pos, 2, GL_SHORT, false, 0, BUFFER_OFFSET(0)); - // glDrawArrays(GL_TRIANGLES, 0, tileStencilBuffer.length()); + // Draw a rectangle that covers the entire viewport. + coveringPatternArray.bind(*patternShader, tileStencilBuffer, BUFFER_OFFSET(0)); + glDrawArrays(GL_TRIANGLES, 0, tileStencilBuffer.length()); } else { // Draw filling rectangle. - glUseProgram(fillShader->program); - glUniformMatrix4fv(fillShader->u_matrix, 1, GL_FALSE, matrix.data()); - glUniform4fv(fillShader->u_color, 1, fill_color.data()); + glUseProgram(plainShader->program); + glUniformMatrix4fv(plainShader->u_matrix, 1, GL_FALSE, matrix.data()); + glUniform4fv(plainShader->u_color, 1, fill_color.data()); // Draw a rectangle that covers the entire viewport. - tileStencilArray.bind(*plainShader, tileStencilBuffer, BUFFER_OFFSET(0)); + coveringPlainArray.bind(*plainShader, tileStencilBuffer, BUFFER_OFFSET(0)); glDrawArrays(GL_TRIANGLES, 0, tileStencilBuffer.length()); } @@ -407,7 +403,7 @@ void Painter::renderBackground() { glUniformMatrix4fv(plainShader->u_matrix, 1, GL_FALSE, matrix.data()); // Draw the clipping mask - tileStencilArray.bind(*plainShader, tileStencilBuffer, BUFFER_OFFSET(0)); + coveringPlainArray.bind(*plainShader, tileStencilBuffer, BUFFER_OFFSET(0)); glUniform4fv(plainShader->u_color, 1, white.data()); glDrawArrays(GL_TRIANGLES, 0, tileStencilBuffer.length()); } diff --git a/src/renderer/shader-fill.cpp b/src/renderer/shader-fill.cpp deleted file mode 100644 index 12e851de8..000000000 --- a/src/renderer/shader-fill.cpp +++ /dev/null @@ -1,28 +0,0 @@ -#include -#include -#include - -#include - -using namespace llmr; - -FillShader::FillShader() - : Shader( - shaders[FILL_SHADER].vertex, - shaders[FILL_SHADER].fragment - ) { - if (!valid) { - fprintf(stderr, "invalid fill shader\n"); - return; - } - - a_pos = glGetAttribLocation(program, "a_pos"); - - u_matrix = glGetUniformLocation(program, "u_matrix"); - u_color = glGetUniformLocation(program, "u_color"); -} - -void FillShader::bind_vertex(char *offset) { - glEnableVertexAttribArray(a_pos); - glVertexAttribPointer(a_pos, 2, GL_SHORT, false, 0, offset); -} diff --git a/src/renderer/shader-line.cpp b/src/renderer/shader-line.cpp index cbd2d15d7..feed1626e 100644 --- a/src/renderer/shader-line.cpp +++ b/src/renderer/shader-line.cpp @@ -31,7 +31,7 @@ LineShader::LineShader() u_gamma = glGetUniformLocation(program, "u_gamma"); } -void LineShader::bind_vertex(char *offset) { +void LineShader::bind(char *offset) { glEnableVertexAttribArray(a_pos); glVertexAttribPointer(a_pos, 2, GL_SHORT, false, 8, offset); diff --git a/src/renderer/shader-outline.cpp b/src/renderer/shader-outline.cpp index 6add2d231..82d24b316 100644 --- a/src/renderer/shader-outline.cpp +++ b/src/renderer/shader-outline.cpp @@ -23,7 +23,7 @@ OutlineShader::OutlineShader() u_world = glGetUniformLocation(program, "u_world"); } -void OutlineShader::bind_vertex(char *offset) { +void OutlineShader::bind(char *offset) { glEnableVertexAttribArray(a_pos); glVertexAttribPointer(a_pos, 2, GL_SHORT, false, 0, offset); } diff --git a/src/renderer/shader-pattern.cpp b/src/renderer/shader-pattern.cpp index 4f3c252f4..22afd677e 100644 --- a/src/renderer/shader-pattern.cpp +++ b/src/renderer/shader-pattern.cpp @@ -26,3 +26,8 @@ PatternShader::PatternShader() u_pattern_br = glGetUniformLocation(program, "u_pattern_br"); u_mix = glGetUniformLocation(program, "u_mix"); } + +void PatternShader::bind(char *offset) { + glEnableVertexAttribArray(a_pos); + glVertexAttribPointer(a_pos, 2, GL_SHORT, false, 0, offset); +} diff --git a/src/renderer/shader-plain.cpp b/src/renderer/shader-plain.cpp index 33cf17227..e9d06540b 100644 --- a/src/renderer/shader-plain.cpp +++ b/src/renderer/shader-plain.cpp @@ -22,7 +22,7 @@ PlainShader::PlainShader() u_color = glGetUniformLocation(program, "u_color"); } -void PlainShader::bind_vertex(char *offset) { +void PlainShader::bind(char *offset) { glEnableVertexAttribArray(a_pos); glVertexAttribPointer(a_pos, 2, GL_SHORT, false, 0, offset); } diff --git a/src/shader/fill.fragment.glsl b/src/shader/fill.fragment.glsl deleted file mode 100644 index 8df552c17..000000000 --- a/src/shader/fill.fragment.glsl +++ /dev/null @@ -1,5 +0,0 @@ -uniform vec4 u_color; - -void main() { - gl_FragColor = u_color; -} diff --git a/src/shader/fill.vertex.glsl b/src/shader/fill.vertex.glsl deleted file mode 100644 index 866c3cd2f..000000000 --- a/src/shader/fill.vertex.glsl +++ /dev/null @@ -1,7 +0,0 @@ -attribute vec2 a_pos; - -uniform mat4 u_matrix; - -void main() { - gl_Position = u_matrix * vec4(a_pos, 0, 1); -} diff --git a/src/shader/shaders.cpp b/src/shader/shaders.cpp index 3d0b98bc6..94d1759fe 100644 --- a/src/shader/shaders.cpp +++ b/src/shader/shaders.cpp @@ -4,10 +4,6 @@ using namespace llmr; const shader_source llmr::shaders[SHADER_COUNT] = { - { - "attribute vec2 a_pos;\n\nuniform mat4 u_matrix;\n\nvoid main() {\n gl_Position = u_matrix * vec4(a_pos, 0, 1);\n}\n", - "uniform vec4 u_color;\n\nvoid main() {\n gl_FragColor = u_color;\n}\n", - }, { "// these are the shaders for rendering antialiased lines\n\n// floor(127 / 2) == 63.0\n// the maximum allowed miter limit is 2.0 at the moment. the extrude normal is\n// stored in a byte (-128..127). we scale regular normals up to length 63, but\n// there are also \"special\" normals that have a bigger length (of up to 126 in\n// this case).\n#define scale 63.0\n\nattribute vec2 a_pos;\nattribute vec2 a_extrude;\nattribute float a_linesofar;\n\n// matrix is for the vertex position, exmatrix is for rotating and projecting\n// the extrusion vector.\nuniform mat4 u_matrix;\nuniform mat4 u_exmatrix;\n\n\nuniform float u_debug;\n\n// shared\nuniform float u_ratio;\nuniform vec2 u_linewidth;\nuniform vec4 u_color;\nuniform float u_point;\n\nvarying vec2 v_normal;\nvarying float v_linesofar;\n\nvoid main() {\n // We store the texture normals in the most insignificant bit\n // transform y so that 0 => -1 and 1 => 1\n // In the texture normal, x is 0 if the normal points straight up/down and 1 if it's a round cap\n // y is 1 if the normal points up, and -1 if it points down\n vec2 normal = mod(a_pos, 2.0);\n normal.y = sign(normal.y - 0.5);\n v_normal = normal;\n\n // Scale the extrusion vector down to a normal and then up by the line width\n // of this vertex.\n vec2 extrude = a_extrude / scale;\n vec2 dist = u_linewidth.s * extrude * (1.0 - u_point);\n\n // If the x coordinate is the maximum integer, we move the z coordinates out\n // of the view plane so that the triangle gets clipped. This makes it easier\n // for us to create degenerate triangle strips.\n float z = step(32767.0, a_pos.x);\n\n // When drawing points, skip every other vertex\n z += u_point * step(1.0, v_normal.y);\n\n // Remove the texture normal bit of the position before scaling it with the\n // model/view matrix. Add the extrusion vector *after* the model/view matrix\n // because we're extruding the line in pixel space, regardless of the current\n // tile's zoom level.\n gl_Position = u_matrix * vec4(floor(a_pos / 2.0), 0.0, 1.0) + u_exmatrix * vec4(dist, z, 0.0);\n v_linesofar = a_linesofar * u_ratio;\n\n\n gl_PointSize = 2.0 * u_linewidth.s - 1.0;\n}\n", "// shared\nuniform float u_debug;\nuniform vec2 u_linewidth;\nuniform vec4 u_color;\nuniform float u_point;\nuniform float u_gamma;\n\nuniform vec2 u_dasharray;\n\nvarying vec2 v_normal;\nvarying float v_linesofar;\n\nvoid main() {\n // Calculate the distance of the pixel from the line in pixels.\n float dist = length(v_normal) * (1.0 - u_point) + u_point * length(gl_PointCoord * 2.0 - 1.0);\n\n dist *= u_linewidth.s;\n\n // Calculate the antialiasing fade factor. This is either when fading in\n // the line in case of an offset line (v_linewidth.t) or when fading out\n // (v_linewidth.s)\n float alpha = clamp(min(dist - (u_linewidth.t - 1.0), u_linewidth.s - dist) * u_gamma, 0.0, 1.0);\n\n // Calculate the antialiasing fade factor based on distance to the dash.\n // Only affects alpha when line is dashed\n float pos = mod(v_linesofar, u_dasharray.x + u_dasharray.y);\n alpha *= max(step(0.0, -u_dasharray.y), clamp(min(pos, u_dasharray.x - pos), 0.0, 1.0));\n\n gl_FragColor = u_color * alpha;\n\n if (u_debug > 0.0) {\n gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0);\n }\n}\n", diff --git a/src/style/resources.cpp b/src/style/resources.cpp index 9380bf025..def1933ff 100644 --- a/src/style/resources.cpp +++ b/src/style/resources.cpp @@ -47,27 +47,28 @@ const unsigned char resources::style[] = { 12, 114, 111, 97, 100, 95, 114, 101, 103, 117, 108, 97, 114, 18, 24, 10, 10, 114, 111, 97, 100, 95, 108, 97, 114, 103, 101, 18, 10, 114, 111, 97, 100, 95, 108, 97, 114, 103, 101, 18, 18, 10, 7, 97, 108, 99, 111, 104, - 111, 108, 18, 7, 97, 108, 99, 111, 104, 111, 108, 26, 202, 2, 10, 7, - 100, 101, 102, 97, 117, 108, 116, 18, 21, 10, 4, 112, 97, 114, 107, 34, - 8, 8, 2, 18, 4, 0, 0, 128, 63, 45, 255, 159, 223, 200, 18, 31, - 10, 4, 119, 111, 111, 100, 34, 8, 8, 2, 18, 4, 0, 0, 128, 63, - 45, 255, 102, 170, 51, 58, 8, 8, 2, 18, 4, 205, 204, 204, 61, 18, - 27, 10, 5, 119, 97, 116, 101, 114, 34, 8, 8, 2, 18, 4, 0, 0, - 128, 63, 45, 255, 233, 224, 186, 53, 255, 230, 182, 115, 18, 51, 10, 8, - 98, 117, 105, 108, 100, 105, 110, 103, 34, 8, 8, 2, 18, 4, 0, 0, - 128, 63, 45, 255, 0, 0, 0, 58, 24, 8, 4, 18, 20, 0, 0, 80, - 65, 0, 0, 0, 0, 205, 204, 204, 61, 0, 0, 0, 0, 205, 204, 204, - 61, 26, 41, 10, 12, 114, 111, 97, 100, 95, 108, 105, 109, 105, 116, 101, - 100, 29, 255, 187, 187, 187, 34, 20, 8, 3, 18, 16, 0, 0, 0, 0, - 0, 0, 128, 63, 0, 0, 240, 65, 0, 0, 128, 63, 26, 65, 10, 12, - 114, 111, 97, 100, 95, 114, 101, 103, 117, 108, 97, 114, 29, 255, 153, 153, - 153, 34, 44, 8, 3, 18, 40, 0, 0, 0, 0, 0, 0, 0, 63, 0, - 0, 80, 65, 0, 0, 0, 63, 0, 0, 128, 65, 0, 0, 0, 64, 0, - 0, 160, 65, 0, 0, 0, 66, 0, 0, 240, 65, 0, 0, 0, 66, 26, - 71, 10, 10, 114, 111, 97, 100, 95, 108, 97, 114, 103, 101, 29, 255, 102, - 102, 102, 34, 52, 8, 3, 18, 48, 0, 0, 0, 0, 0, 0, 0, 63, - 0, 0, 48, 65, 0, 0, 0, 63, 0, 0, 80, 65, 0, 0, 128, 63, - 0, 0, 128, 65, 0, 0, 128, 64, 0, 0, 160, 65, 0, 0, 128, 66, - 0, 0, 240, 65, 0, 0, 128, 66 + 111, 108, 18, 7, 97, 108, 99, 111, 104, 111, 108, 26, 220, 2, 10, 7, + 100, 101, 102, 97, 117, 108, 116, 18, 27, 10, 4, 112, 97, 114, 107, 34, + 8, 8, 2, 18, 4, 0, 0, 128, 63, 45, 255, 159, 223, 200, 66, 4, + 112, 97, 114, 107, 18, 31, 10, 4, 119, 111, 111, 100, 34, 8, 8, 2, + 18, 4, 0, 0, 128, 63, 45, 255, 102, 170, 51, 58, 8, 8, 2, 18, + 4, 205, 204, 204, 61, 18, 39, 10, 5, 119, 97, 116, 101, 114, 34, 8, + 8, 2, 18, 4, 0, 0, 128, 63, 45, 255, 233, 224, 186, 53, 255, 230, + 182, 115, 66, 10, 119, 97, 116, 101, 114, 95, 101, 116, 115, 121, 18, 51, + 10, 8, 98, 117, 105, 108, 100, 105, 110, 103, 34, 8, 8, 2, 18, 4, + 0, 0, 128, 63, 45, 255, 0, 0, 0, 58, 24, 8, 4, 18, 20, 0, + 0, 80, 65, 0, 0, 0, 0, 205, 204, 204, 61, 0, 0, 0, 0, 205, + 204, 204, 61, 26, 41, 10, 12, 114, 111, 97, 100, 95, 108, 105, 109, 105, + 116, 101, 100, 29, 255, 187, 187, 187, 34, 20, 8, 3, 18, 16, 0, 0, + 0, 0, 0, 0, 128, 63, 0, 0, 240, 65, 0, 0, 128, 63, 26, 65, + 10, 12, 114, 111, 97, 100, 95, 114, 101, 103, 117, 108, 97, 114, 29, 255, + 153, 153, 153, 34, 44, 8, 3, 18, 40, 0, 0, 0, 0, 0, 0, 0, + 63, 0, 0, 80, 65, 0, 0, 0, 63, 0, 0, 128, 65, 0, 0, 0, + 64, 0, 0, 160, 65, 0, 0, 0, 66, 0, 0, 240, 65, 0, 0, 0, + 66, 26, 71, 10, 10, 114, 111, 97, 100, 95, 108, 97, 114, 103, 101, 29, + 255, 102, 102, 102, 34, 52, 8, 3, 18, 48, 0, 0, 0, 0, 0, 0, + 0, 63, 0, 0, 48, 65, 0, 0, 0, 63, 0, 0, 80, 65, 0, 0, + 128, 63, 0, 0, 128, 65, 0, 0, 128, 64, 0, 0, 160, 65, 0, 0, + 128, 66, 0, 0, 240, 65, 0, 0, 128, 66 }; const unsigned long resources::style_size = sizeof(resources::style);