Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/drape
diff options
context:
space:
mode:
Diffstat (limited to 'drape')
-rw-r--r--drape/overlay_handle.cpp7
-rw-r--r--drape/overlay_handle.hpp3
-rw-r--r--drape/shaders/path_symbol_vertex_shader.vsh4
-rwxr-xr-xdrape/shaders/text_billboard_vertex_shader.vsh21
-rwxr-xr-xdrape/shaders/text_outlined_billboard_vertex_shader.vsh22
-rwxr-xr-xdrape/shaders/text_outlined_gui_vertex_shader.vsh2
-rwxr-xr-xdrape/shaders/text_outlined_vertex_shader.vsh2
-rw-r--r--drape/shaders/text_vertex_shader.vsh2
-rw-r--r--drape/shaders/texturing_billboard_vertex_shader.vsh20
-rw-r--r--drape/shaders/texturing_vertex_shader.vsh4
-rw-r--r--drape/utils/vertex_decl.cpp16
-rw-r--r--drape/utils/vertex_decl.hpp9
12 files changed, 62 insertions, 50 deletions
diff --git a/drape/overlay_handle.cpp b/drape/overlay_handle.cpp
index fae2487c67..92150dc112 100644
--- a/drape/overlay_handle.cpp
+++ b/drape/overlay_handle.cpp
@@ -29,7 +29,8 @@ OverlayHandle::OverlayHandle(FeatureID const & id,
, m_anchor(anchor)
, m_priority(priority)
, m_overlayRank(OverlayRank0)
- , m_extendingSize(0)
+ , m_extendingSize(0.0)
+ , m_pivotZ(0.0)
, m_isBillboard(isBillboard)
, m_isVisible(false)
{
@@ -69,7 +70,7 @@ m2::PointD OverlayHandle::GetPivot(ScreenBase const & screen, bool perspective)
result.y += size.y;
if (perspective)
- result = screen.PtoP3d(result);
+ result = screen.PtoP3d(result, -m_pivotZ / screen.GetScale());
return result;
}
@@ -174,7 +175,7 @@ m2::RectD OverlayHandle::GetPixelRectPerspective(ScreenBase const & screen) cons
if (m_isBillboard)
{
m2::PointD const pxPivot = GetPivot(screen, false);
- m2::PointD const pxPivotPerspective = screen.PtoP3d(pxPivot);
+ m2::PointD const pxPivotPerspective = screen.PtoP3d(pxPivot, -m_pivotZ / screen.GetScale());
m2::RectD pxRectPerspective = GetPixelRect(screen, false);
pxRectPerspective.Offset(-pxPivot);
diff --git a/drape/overlay_handle.hpp b/drape/overlay_handle.hpp
index 8cfda56e3e..214c599177 100644
--- a/drape/overlay_handle.hpp
+++ b/drape/overlay_handle.hpp
@@ -58,6 +58,8 @@ public:
virtual m2::RectD GetPixelRect(ScreenBase const & screen, bool perspective) const = 0;
virtual void GetPixelShape(ScreenBase const & screen, Rects & rects, bool perspective) const = 0;
+ void SetPivotZ(double pivotZ) { m_pivotZ = pivotZ; }
+
double GetExtendingSize() const { return m_extendingSize; }
void SetExtendingSize(double extendingSize) { m_extendingSize = extendingSize; }
m2::RectD GetExtendedPixelRect(ScreenBase const & screen) const;
@@ -96,6 +98,7 @@ protected:
int m_overlayRank;
double m_extendingSize;
+ double m_pivotZ;
steady_clock::time_point m_visibilityTimestamp;
diff --git a/drape/shaders/path_symbol_vertex_shader.vsh b/drape/shaders/path_symbol_vertex_shader.vsh
index ee0709bd23..38c6b7791a 100644
--- a/drape/shaders/path_symbol_vertex_shader.vsh
+++ b/drape/shaders/path_symbol_vertex_shader.vsh
@@ -1,4 +1,4 @@
-attribute vec3 a_position;
+attribute vec4 a_position;
attribute vec2 a_normal;
attribute vec2 a_colorTexCoords;
@@ -10,7 +10,7 @@ varying vec2 v_colorTexCoords;
void main(void)
{
- lowp vec4 pos = vec4(a_position, 1) * modelView;
+ lowp vec4 pos = vec4(a_position.xyz, 1) * modelView;
highp vec4 norm = vec4(a_normal, 0, 0) * modelView;
highp vec4 shiftedPos = norm + pos;
shiftedPos = shiftedPos * projection;
diff --git a/drape/shaders/text_billboard_vertex_shader.vsh b/drape/shaders/text_billboard_vertex_shader.vsh
index a655997f05..19b03e8eb6 100755
--- a/drape/shaders/text_billboard_vertex_shader.vsh
+++ b/drape/shaders/text_billboard_vertex_shader.vsh
@@ -17,21 +17,22 @@ varying vec2 v_colorTexCoord;
varying vec2 v_maskTexCoord;
-const float Zero = 0.0;
-const float One = 1.0;
-
void main()
{
// Here we intentionally decrease precision of 'pivot' calculation
// to eliminate jittering effect in process of billboard reconstruction.
- lowp vec4 pivot = a_position * modelView;
- vec4 offset = vec4(a_normal, Zero, Zero) * projection;
-
+ lowp vec4 pivot = vec4(a_position.xyz, 1.0) * modelView;
+ vec4 offset = vec4(a_normal, 0.0, 0.0) * projection;
+
+ float pivotZ = a_position.w;
+ float zScale = projection[0][0] * length(vec4(1.0, 0.0, 0.0, 0.0) * modelView);
+
vec4 projectedPivot = pivot * projection;
- vec4 transformedPivot = pivotTransform * vec4(projectedPivot.xy, 0.0, 1.0);
-
- vec4 scale = pivotTransform * vec4(One, -One, Zero, One);
- gl_Position = transformedPivot + vec4(offset.xy * transformedPivot.w / scale.w * scale.x, Zero, Zero);
+ float logicZ = projectedPivot.z / projectedPivot.w;
+ vec4 transformedPivot = pivotTransform * vec4(projectedPivot.xy, pivotZ * zScale, projectedPivot.w);
+
+ vec4 scale = pivotTransform * vec4(1.0, -1.0, 0.0, 1.0);
+ gl_Position = vec4(transformedPivot.xy / transformedPivot.w, logicZ, 1.0) + vec4(offset.xy / scale.w * scale.x, 0.0, 0.0);
#ifdef ENABLE_VTF
v_color = texture2D(u_colorTex, a_colorTexCoord);
diff --git a/drape/shaders/text_outlined_billboard_vertex_shader.vsh b/drape/shaders/text_outlined_billboard_vertex_shader.vsh
index b0de7c5c08..3631bf481e 100755
--- a/drape/shaders/text_outlined_billboard_vertex_shader.vsh
+++ b/drape/shaders/text_outlined_billboard_vertex_shader.vsh
@@ -18,26 +18,28 @@ varying vec2 v_colorTexCoord;
varying vec2 v_maskTexCoord;
-const float Zero = 0.0;
-const float One = 1.0;
const float BaseDepthShift = -10.0;
void main()
{
float isOutline = step(0.5, u_isOutlinePass);
- float notOutline = One - isOutline;
+ float notOutline = 1.0 - isOutline;
float depthShift = BaseDepthShift * isOutline;
-
- // Here we intentionally decrease precision of 'pos' calculation
+
+ // Here we intentionally decrease precision of 'pivot' calculation
// to eliminate jittering effect in process of billboard reconstruction.
- lowp vec4 pivot = a_position * modelView;
- vec4 offset = vec4(a_normal, Zero, Zero) * projection;
+ lowp vec4 pivot = (vec4(a_position.xyz, 1.0) + vec4(0.0, 0.0, depthShift, 0.0)) * modelView;
+ vec4 offset = vec4(a_normal, 0.0, 0.0) * projection;
+
+ float pivotZ = a_position.w;
+ float zScale = projection[0][0] * length(vec4(1.0, 0.0, 0.0, 0.0) * modelView);
vec4 projectedPivot = pivot * projection;
- vec4 transformedPivot = pivotTransform * vec4(projectedPivot.xy, 0.0, 1.0);
+ float logicZ = projectedPivot.z / projectedPivot.w;
+ vec4 transformedPivot = pivotTransform * vec4(projectedPivot.xy, pivotZ * zScale, projectedPivot.w);
- vec4 scale = pivotTransform * vec4(One, -One, Zero, One);
- gl_Position = transformedPivot + vec4(offset.xy * transformedPivot.w / scale.w * scale.x, Zero, Zero);
+ vec4 scale = pivotTransform * vec4(1.0, -1.0, 0.0, 1.0);
+ gl_Position = vec4(transformedPivot.xy / transformedPivot.w, logicZ, 1.0) + vec4(offset.xy / scale.w * scale.x, 0.0, 0.0);
vec2 colorTexCoord = a_colorTexCoord * notOutline + a_outlineColorTexCoord * isOutline;
#ifdef ENABLE_VTF
diff --git a/drape/shaders/text_outlined_gui_vertex_shader.vsh b/drape/shaders/text_outlined_gui_vertex_shader.vsh
index 45206f029b..6a60995631 100755
--- a/drape/shaders/text_outlined_gui_vertex_shader.vsh
+++ b/drape/shaders/text_outlined_gui_vertex_shader.vsh
@@ -29,7 +29,7 @@ void main()
// Here we intentionally decrease precision of 'pos' calculation
// to eliminate jittering effect in process of billboard reconstruction.
- lowp vec4 pos = (a_position + vec4(Zero, Zero, depthShift, Zero)) * modelView;
+ lowp vec4 pos = (vec4(a_position.xyz, 1.0) + vec4(Zero, Zero, depthShift, Zero)) * modelView;
highp vec4 shiftedPos = vec4(a_normal, Zero, Zero) + pos;
gl_Position = shiftedPos * projection;
vec2 colorTexCoord = a_colorTexCoord * notOutline + a_outlineColorTexCoord * isOutline;
diff --git a/drape/shaders/text_outlined_vertex_shader.vsh b/drape/shaders/text_outlined_vertex_shader.vsh
index 36649f64ba..977a3de444 100755
--- a/drape/shaders/text_outlined_vertex_shader.vsh
+++ b/drape/shaders/text_outlined_vertex_shader.vsh
@@ -30,7 +30,7 @@ void main()
// Here we intentionally decrease precision of 'pos' calculation
// to eliminate jittering effect in process of billboard reconstruction.
- lowp vec4 pos = (a_position + vec4(Zero, Zero, depthShift, Zero)) * modelView;
+ lowp vec4 pos = (vec4(a_position.xyz, 1) + vec4(Zero, Zero, depthShift, Zero)) * modelView;
highp vec4 shiftedPos = vec4(a_normal, Zero, Zero) + pos;
shiftedPos = shiftedPos * projection;
float w = shiftedPos.w;
diff --git a/drape/shaders/text_vertex_shader.vsh b/drape/shaders/text_vertex_shader.vsh
index fbc85ef453..e7be2fd7eb 100644
--- a/drape/shaders/text_vertex_shader.vsh
+++ b/drape/shaders/text_vertex_shader.vsh
@@ -24,7 +24,7 @@ void main()
{
// Here we intentionally decrease precision of 'pos' calculation
// to eliminate jittering effect in process of billboard reconstruction.
- lowp vec4 pos = a_position * modelView;
+ lowp vec4 pos = vec4(a_position.xyz, 1) * modelView;
highp vec4 shiftedPos = vec4(a_normal, Zero, Zero) + pos;
shiftedPos = shiftedPos * projection;
float w = shiftedPos.w;
diff --git a/drape/shaders/texturing_billboard_vertex_shader.vsh b/drape/shaders/texturing_billboard_vertex_shader.vsh
index fa901f6ec9..4ddb8941a3 100644
--- a/drape/shaders/texturing_billboard_vertex_shader.vsh
+++ b/drape/shaders/texturing_billboard_vertex_shader.vsh
@@ -1,4 +1,4 @@
-attribute vec3 a_position;
+attribute vec4 a_position;
attribute vec2 a_normal;
attribute vec2 a_colorTexCoords;
@@ -12,14 +12,18 @@ void main(void)
{
// Here we intentionally decrease precision of 'pivot' calculation
// to eliminate jittering effect in process of billboard reconstruction.
- lowp vec4 pivot = vec4(a_position, 1) * modelView;
- vec4 offset = vec4(a_normal, 0, 0) * projection;
-
+ lowp vec4 pivot = vec4(a_position.xyz, 1.0) * modelView;
+ vec4 offset = vec4(a_normal, 0.0, 0.0) * projection;
+
+ float pivotZ = a_position.w;
+ float zScale = projection[0][0] * length(vec4(1.0, 0.0, 0.0, 0.0) * modelView);
+
vec4 projectedPivot = pivot * projection;
- vec4 transformedPivot = pivotTransform * vec4(projectedPivot.xy, 0.0, 1.0);
-
- vec4 scale = pivotTransform * vec4(1.0, -1.0, 0, 1.0);
- gl_Position = transformedPivot + vec4(offset.xy * transformedPivot.w / scale.w * scale.x, 0, 0);
+ float logicZ = projectedPivot.z / projectedPivot.w;
+ vec4 transformedPivot = pivotTransform * vec4(projectedPivot.xy, pivotZ * zScale, projectedPivot.w);
+
+ vec4 scale = pivotTransform * vec4(1.0, -1.0, 0.0, 1.0);
+ gl_Position = vec4(transformedPivot.xy / transformedPivot.w, logicZ, 1.0) + vec4(offset.xy / scale.w * scale.x, 0.0, 0.0);
v_colorTexCoords = a_colorTexCoords;
}
diff --git a/drape/shaders/texturing_vertex_shader.vsh b/drape/shaders/texturing_vertex_shader.vsh
index 884aa07476..d633a12540 100644
--- a/drape/shaders/texturing_vertex_shader.vsh
+++ b/drape/shaders/texturing_vertex_shader.vsh
@@ -1,4 +1,4 @@
-attribute vec3 a_position;
+attribute vec4 a_position;
attribute vec2 a_normal;
attribute vec2 a_colorTexCoords;
@@ -12,7 +12,7 @@ void main(void)
{
// Here we intentionally decrease precision of 'pos' calculation
// to eliminate jittering effect in process of billboard reconstruction.
- lowp vec4 pos = vec4(a_position, 1) * modelView;
+ lowp vec4 pos = vec4(a_position.xyz, 1) * modelView;
highp vec4 shiftedPos = vec4(a_normal, 0, 0) + pos;
shiftedPos = shiftedPos * projection;
float w = shiftedPos.w;
diff --git a/drape/utils/vertex_decl.cpp b/drape/utils/vertex_decl.cpp
index c533790843..f2afc6d793 100644
--- a/drape/utils/vertex_decl.cpp
+++ b/drape/utils/vertex_decl.cpp
@@ -56,12 +56,12 @@ dp::BindingInfo Area3dBindingInit()
dp::BindingInfo SolidTexturingBindingInit()
{
- static_assert(sizeof(SolidTexturingVertex) == (sizeof(SolidTexturingVertex::TPosition) +
+ static_assert(sizeof(SolidTexturingVertex) == (sizeof(SolidTexturingVertex::TPosition3d) +
sizeof(SolidTexturingVertex::TNormal) +
sizeof(SolidTexturingVertex::TTexCoord)), "");
dp::BindingFiller<SolidTexturingVertex> filler(3);
- filler.FillDecl<SolidTexturingVertex::TPosition>("a_position");
+ filler.FillDecl<SolidTexturingVertex::TPosition3d>("a_position");
filler.FillDecl<SolidTexturingVertex::TNormal>("a_normal");
filler.FillDecl<SolidTexturingVertex::TTexCoord>("a_colorTexCoords");
@@ -93,11 +93,11 @@ dp::BindingInfo TextOutlinedStaticBindingInit()
dp::BindingInfo TextDynamicBindingInit()
{
- static_assert(sizeof(TextDynamicVertex) == (sizeof(TextStaticVertex::TPosition) +
+ static_assert(sizeof(TextDynamicVertex) == (sizeof(TextStaticVertex::TPosition3d) +
sizeof(TextDynamicVertex::TNormal)), "");
dp::BindingFiller<TextDynamicVertex> filler(2, TextDynamicVertex::GetDynamicStreamID());
- filler.FillDecl<TextStaticVertex::TPosition>("a_position");
+ filler.FillDecl<TextStaticVertex::TPosition3d>("a_position");
filler.FillDecl<TextDynamicVertex::TNormal>("a_normal");
return filler.m_info;
@@ -212,13 +212,13 @@ dp::BindingInfo const & Area3dVertex::GetBindingInfo()
}
SolidTexturingVertex::SolidTexturingVertex()
- : m_position(0.0, 0.0, 0.0)
+ : m_position(0.0, 0.0, 0.0, 0.0)
, m_normal(0.0, 0.0)
, m_colorTexCoord(0.0, 0.0)
{
}
-SolidTexturingVertex::SolidTexturingVertex(TPosition const & position, TNormal const & normal,
+SolidTexturingVertex::SolidTexturingVertex(const TPosition3d & position, TNormal const & normal,
TTexCoord const & colorTexCoord)
: m_position(position)
, m_normal(normal)
@@ -253,12 +253,12 @@ dp::BindingInfo const & TextOutlinedStaticVertex::GetBindingInfo()
}
TextDynamicVertex::TextDynamicVertex()
- : m_position(0.0, 0.0, 0.0)
+ : m_position(0.0, 0.0, 0.0, 0.0)
, m_normal(0.0, 0.0)
{
}
-TextDynamicVertex::TextDynamicVertex(TPosition const & position, TNormal const & normal)
+TextDynamicVertex::TextDynamicVertex(const TPosition3d & position, TNormal const & normal)
: m_position(position),
m_normal(normal)
{
diff --git a/drape/utils/vertex_decl.hpp b/drape/utils/vertex_decl.hpp
index 296a1d81ab..a491b2a5b5 100644
--- a/drape/utils/vertex_decl.hpp
+++ b/drape/utils/vertex_decl.hpp
@@ -11,6 +11,7 @@ namespace gpu
struct BaseVertex
{
using TPosition = glsl::vec3;
+ using TPosition3d = glsl::vec4;
using TNormal = glsl::vec2;
using TNormal3d = glsl::vec3;
using TTexCoord = glsl::vec2;
@@ -42,9 +43,9 @@ struct Area3dVertex : BaseVertex
struct SolidTexturingVertex : BaseVertex
{
SolidTexturingVertex();
- SolidTexturingVertex(TPosition const & position, TNormal const & normal, TTexCoord const & colorTexCoord);
+ SolidTexturingVertex(TPosition3d const & position, TNormal const & normal, TTexCoord const & colorTexCoord);
- TPosition m_position;
+ TPosition3d m_position;
TNormal m_normal;
TTexCoord m_colorTexCoord;
@@ -85,9 +86,9 @@ typedef buffer_vector<TextOutlinedStaticVertex, 128> TTextOutlinedStaticVertexBu
struct TextDynamicVertex : BaseVertex
{
TextDynamicVertex();
- TextDynamicVertex(TPosition const & position, TNormal const & normal);
+ TextDynamicVertex(TPosition3d const & position, TNormal const & normal);
- TPosition m_position;
+ TPosition3d m_position;
TNormal m_normal;
static dp::BindingInfo const & GetBindingInfo();