diff --git a/drape/shaders/dashed_fragment_shader.fsh b/drape/shaders/dashed_fragment_shader.fsh index 9a1aefb669..c233b84576 100644 --- a/drape/shaders/dashed_fragment_shader.fsh +++ b/drape/shaders/dashed_fragment_shader.fsh @@ -1,14 +1,22 @@ varying vec2 v_colorTexCoord; -varying vec2 v_maskTexCoord; +varying vec2 v_halfLength; +varying highp vec2 v_maskTexCoord; uniform sampler2D u_colorTex; uniform sampler2D u_maskTex; uniform float u_opacity; +const float aaPixelsCount = 2.5; + void main(void) { vec4 color = texture2D(u_colorTex, v_colorTexCoord); vec4 mask = texture2D(u_maskTex, v_maskTexCoord); color.a = color.a * mask.a * u_opacity; - gl_FragColor = color; + + float currentW = abs(v_halfLength.x); + float diff = v_halfLength.y - currentW; + color.a *= mix(0.3, 1.0, clamp(diff / aaPixelsCount, 0.0, 1.0)); + + gl_FragColor = color; } diff --git a/drape/shaders/dashed_vertex_shader.vsh b/drape/shaders/dashed_vertex_shader.vsh index 841b05c998..4c95d2335a 100644 --- a/drape/shaders/dashed_vertex_shader.vsh +++ b/drape/shaders/dashed_vertex_shader.vsh @@ -1,26 +1,29 @@ attribute vec3 a_position; -attribute vec2 a_normal; +attribute vec3 a_normal; attribute vec2 a_colorTexCoord; -attribute vec2 a_maskTexCoord; +attribute highp vec2 a_maskTexCoord; uniform mat4 modelView; uniform mat4 projection; varying vec2 v_colorTexCoord; -varying vec2 v_maskTexCoord; +varying highp vec2 v_maskTexCoord; +varying vec2 v_halfLength; void main(void) { - float halfWidth = length(a_normal); + vec2 normal = a_normal.xy; + float halfWidth = length(normal); vec2 transformedAxisPos = (vec4(a_position.xy, 0.0, 1.0) * modelView).xy; if (halfWidth != 0.0) { - vec4 glbShiftPos = vec4(a_position.xy + a_normal, 0.0, 1.0); + vec4 glbShiftPos = vec4(a_position.xy + normal, 0.0, 1.0); vec2 shiftPos = (glbShiftPos * modelView).xy; transformedAxisPos = transformedAxisPos + normalize(shiftPos - transformedAxisPos) * halfWidth; } v_colorTexCoord = a_colorTexCoord; v_maskTexCoord = a_maskTexCoord; + v_halfLength = vec2(sign(a_normal.z) * halfWidth, abs(a_normal.z)); gl_Position = vec4(transformedAxisPos, a_position.z, 1.0) * projection; } diff --git a/drape/shaders/line_fragment_shader.fsh b/drape/shaders/line_fragment_shader.fsh index 6bef70eb4e..addcef8a99 100644 --- a/drape/shaders/line_fragment_shader.fsh +++ b/drape/shaders/line_fragment_shader.fsh @@ -4,14 +4,16 @@ varying vec2 v_halfLength; uniform sampler2D u_colorTex; uniform float u_opacity; -const float aaPixelsCount = 2.0; +const float aaPixelsCount = 2.5; void main(void) { vec4 color = texture2D(u_colorTex, v_colorTexCoord); color.a *= u_opacity; + float currentW = abs(v_halfLength.x); float diff = v_halfLength.y - currentW; color.a *= mix(0.3, 1.0, clamp(diff / aaPixelsCount, 0.0, 1.0)); + gl_FragColor = color; } diff --git a/drape/shaders/text_fragment_shader.fsh b/drape/shaders/text_fragment_shader.fsh index bd4178e504..2434e5d8b8 100755 --- a/drape/shaders/text_fragment_shader.fsh +++ b/drape/shaders/text_fragment_shader.fsh @@ -15,7 +15,7 @@ vec4 colorize(vec4 base, vec4 outline, float alpha) if (alpha > u_outlineGlyphParams.z) { float oFactor = smoothstep(u_outlineGlyphParams.w, u_outlineGlyphParams.z, alpha); - return mix(vec4(outline.rgb,0), outline, oFactor); + return vec4(outline.rgb, mix(0.0, outline.a, oFactor)); } if (alpha > u_outlineGlyphParams.y) { @@ -34,7 +34,7 @@ vec4 without_outline(vec4 base, float alpha) if (alpha > u_glyphParams.x) { float oFactor = smoothstep(u_glyphParams.x, u_glyphParams.y, alpha); - return mix(base, vec4(0, 0, 0, 0), oFactor); + return vec4(base.rgb, mix(base.a, 0.0, oFactor)); } return base; } diff --git a/drape/utils/vertex_decl.hpp b/drape/utils/vertex_decl.hpp index 794f4f0261..5bee5341a9 100644 --- a/drape/utils/vertex_decl.hpp +++ b/drape/utils/vertex_decl.hpp @@ -86,6 +86,8 @@ struct LineVertex : BaseVertex struct DashedLineVertex : BaseVertex { + using TNormal = glsl::vec3; + DashedLineVertex(); DashedLineVertex(TPosition const & position, TNormal const & normal, TTexCoord const & color, TTexCoord const & mask); diff --git a/drape_frontend/frontend_renderer.cpp b/drape_frontend/frontend_renderer.cpp index aca934d6dc..9f17efae3d 100755 --- a/drape_frontend/frontend_renderer.cpp +++ b/drape_frontend/frontend_renderer.cpp @@ -397,6 +397,7 @@ void FrontendRenderer::OnAddRenderGroup(TileKey const & tileKey, dp::GLState con drape_ptr && renderBucket) { AddToRenderGroup(m_renderGroups, state, move(renderBucket), tileKey); + m_renderGroups.back()->Appear(); } void FrontendRenderer::OnDeferRenderGroup(TileKey const & tileKey, dp::GLState const & state, @@ -413,6 +414,7 @@ void FrontendRenderer::OnActivateTile(TileKey const & tileKey) { m_renderGroups.push_back(move(*it)); it = m_deferredRenderGroups.erase(it); + m_renderGroups.back()->Appear(); } else { diff --git a/drape_frontend/line_shape.cpp b/drape_frontend/line_shape.cpp index c31037e714..35c599e19c 100644 --- a/drape_frontend/line_shape.cpp +++ b/drape_frontend/line_shape.cpp @@ -136,6 +136,11 @@ public: return 0; } + float GetSide(bool isLeft) const + { + return isLeft ? 1.0 : -1.0; + } + protected: vector const & GenerateCap(LineSegment const & segment, EPointType type, float sign, bool isStart) @@ -286,6 +291,9 @@ public: void SubmitCap(LineSegment const & segment, bool isStart) { + if (m_params.m_cap == dp::ButtCap) + return; + EPointType const type = isStart ? StartPoint : EndPoint; if (m_params.m_cap != dp::RoundCap) { @@ -298,11 +306,6 @@ public: } } - float GetSide(bool isLeft) - { - return isLeft ? 1.0 : -1.0; - } - private: void CreateRoundCap(glsl::vec2 const & pos) { @@ -344,6 +347,7 @@ private: class DashedLineBuilder : public BaseLineBuilder { using TBase = BaseLineBuilder; + using TNormal = gpu::LineVertex::TNormal; public: struct BuilderParams : BaseBuilderParams @@ -377,13 +381,15 @@ public: } void SubmitVertex(LineSegment const & segment, glsl::vec3 const & pivot, - glsl::vec2 const & normal, bool /*isLeft*/, float offsetFromStart) + glsl::vec2 const & normal, bool isLeft, float offsetFromStart) { float distance = GetProjectionLength(pivot.xy() + m_glbHalfWidth * normal, segment.m_points[StartPoint], segment.m_points[EndPoint]) - offsetFromStart; - m_geometry.emplace_back(V(pivot, GetHalfWidth() * normal, m_colorCoord, m_texCoordGen.GetTexCoordsByDistance(distance))); + float const halfWidth = GetHalfWidth(); + m_geometry.emplace_back(V(pivot, TNormal(halfWidth * normal, halfWidth * GetSide(isLeft)), + m_colorCoord, m_texCoordGen.GetTexCoordsByDistance(distance))); } void SubmitJoin(LineSegment const & seg1, LineSegment const & seg2) @@ -401,14 +407,15 @@ public: private: void SubmitJoinImpl(glsl::vec3 const & pivot, vector const & normals) { + float const halfWidth = GetHalfWidth(); size_t const trianglesCount = normals.size() / 3; for (int j = 0; j < trianglesCount; j++) { - size_t baseIndex = 3 * j; - glsl::vec2 texCoord = m_texCoordGen.GetTexCoords(0.0f); - m_joinGeom.push_back(V(pivot, normals[baseIndex + 0], m_colorCoord, texCoord)); - m_joinGeom.push_back(V(pivot, normals[baseIndex + 1], m_colorCoord, texCoord)); - m_joinGeom.push_back(V(pivot, normals[baseIndex + 2], m_colorCoord, texCoord)); + size_t const baseIndex = 3 * j; + glsl::vec2 const texCoord = m_texCoordGen.GetTexCoords(0.0f); + m_joinGeom.push_back(V(pivot, TNormal(normals[baseIndex + 0], halfWidth), m_colorCoord, texCoord)); + m_joinGeom.push_back(V(pivot, TNormal(normals[baseIndex + 1], halfWidth), m_colorCoord, texCoord)); + m_joinGeom.push_back(V(pivot, TNormal(normals[baseIndex + 2], halfWidth), m_colorCoord, texCoord)); } } diff --git a/drape_frontend/poi_symbol_shape.cpp b/drape_frontend/poi_symbol_shape.cpp index 0e815778f8..8218db5275 100644 --- a/drape_frontend/poi_symbol_shape.cpp +++ b/drape_frontend/poi_symbol_shape.cpp @@ -31,16 +31,16 @@ void PoiSymbolShape::Draw(ref_ptr batcher, ref_ptrGetOpacity(); + if (m_disappearAnimation != nullptr) return m_disappearAnimation->GetOpacity(); @@ -86,16 +89,31 @@ double RenderGroup::GetOpacity() const bool RenderGroup::IsAnimating() const { - if (m_disappearAnimation == nullptr || m_disappearAnimation->IsFinished()) - return false; + if (m_appearAnimation && !m_appearAnimation->IsFinished()) + return true; - return true; + if (m_disappearAnimation && !m_disappearAnimation->IsFinished()) + return true; + + return false; +} + +void RenderGroup::Appear() +{ + if (m_state.GetDepthLayer() == dp::GLState::OverlayLayer) + { + m_appearAnimation = make_unique(0.25 /* duration */, 0.0 /* delay */, + 0.0 /* startOpacity */, 1.0 /* endOpacity */); + } } void RenderGroup::Disappear() { - m_disappearAnimation = make_unique(0.2 /* duration */, 0.25 /* delay */, - 1.0 /* startOpacity */, 0.0 /* endOpacity */); + if (m_state.GetDepthLayer() == dp::GLState::OverlayLayer) + { + m_disappearAnimation = make_unique(0.2 /* duration */, 0.05 /* delay */, + 1.0 /* startOpacity */, 0.0 /* endOpacity */); + } } bool RenderGroupComparator::operator()(drape_ptr const & l, drape_ptr const & r) diff --git a/drape_frontend/render_group.hpp b/drape_frontend/render_group.hpp index 87981509aa..5b40029da4 100755 --- a/drape_frontend/render_group.hpp +++ b/drape_frontend/render_group.hpp @@ -63,11 +63,14 @@ public: void UpdateAnimation() override; double GetOpacity() const; bool IsAnimating() const; + + void Appear(); void Disappear(); private: vector > m_renderBuckets; unique_ptr m_disappearAnimation; + unique_ptr m_appearAnimation; mutable bool m_pendingOnDelete; diff --git a/drape_frontend/visual_params.cpp b/drape_frontend/visual_params.cpp index 2408919374..a7cd14a54b 100644 --- a/drape_frontend/visual_params.cpp +++ b/drape_frontend/visual_params.cpp @@ -42,9 +42,9 @@ void VisualParams::Init(double vs, uint32_t tileSize, vector const & a // Here we set up glyphs rendering parameters separately for high-res and low-res screens. if (vs <= 1.0) - g_VizParams.m_glyphVisualParams = { 0.48, 0.625, 0.64, 0.95, 0.48, 0.625 }; + g_VizParams.m_glyphVisualParams = { 0.43, 0.6, 0.615, 0.95, 0.43, 0.6 }; else - g_VizParams.m_glyphVisualParams = { 0.41, 0.565, 0.57, 0.95, 0.45, 0.6 }; + g_VizParams.m_glyphVisualParams = { 0.4, 0.575, 0.58, 0.95, 0.4, 0.575 }; RISE_INITED; }