diff options
author | r.kuznetsov <r.kuznetsov@corp.mail.ru> | 2016-05-17 10:10:18 +0300 |
---|---|---|
committer | r.kuznetsov <r.kuznetsov@corp.mail.ru> | 2016-05-18 14:55:28 +0300 |
commit | c3680e03adb8b2dc353f77417436f63bc5f7cbc5 (patch) | |
tree | 4dea64186d9d88994b6327127d79016c30fecbb3 /drape | |
parent | fc902756303a29c507403ecff570f5ecf027cc27 (diff) |
Added special visualization for deleted POI
Diffstat (limited to 'drape')
-rw-r--r-- | drape/drape.pro | 3 | ||||
-rw-r--r-- | drape/shaders/masked_texturing_billboard_vertex_shader.vsh | 32 | ||||
-rw-r--r-- | drape/shaders/masked_texturing_fragment_shader.fsh | 13 | ||||
-rw-r--r-- | drape/shaders/masked_texturing_vertex_shader.vsh | 26 | ||||
-rw-r--r-- | drape/shaders/shader_index.txt | 2 | ||||
-rw-r--r-- | drape/utils/vertex_decl.cpp | 42 | ||||
-rw-r--r-- | drape/utils/vertex_decl.hpp | 21 |
7 files changed, 134 insertions, 5 deletions
diff --git a/drape/drape.pro b/drape/drape.pro index 618140467e..53603cfc78 100644 --- a/drape/drape.pro +++ b/drape/drape.pro @@ -25,6 +25,9 @@ OTHER_FILES += \ shaders/debug_rect_vertex_shader.vsh \ shaders/line_fragment_shader.fsh \ shaders/line_vertex_shader.vsh \ + shaders/masked_texturing_billboard_vertex_shader.vsh \ + shaders/masked_texturing_fragment_shader.fsh \ + shaders/masked_texturing_vertex_shader.vsh \ shaders/my_position_shader.vsh \ shaders/path_symbol_vertex_shader.vsh \ shaders/position_accuracy3d_shader.vsh \ diff --git a/drape/shaders/masked_texturing_billboard_vertex_shader.vsh b/drape/shaders/masked_texturing_billboard_vertex_shader.vsh new file mode 100644 index 0000000000..9641adacc0 --- /dev/null +++ b/drape/shaders/masked_texturing_billboard_vertex_shader.vsh @@ -0,0 +1,32 @@ +attribute vec4 a_position; +attribute vec2 a_normal; +attribute vec2 a_colorTexCoords; +attribute vec2 a_maskTexCoords; + +uniform mat4 modelView; +uniform mat4 projection; +uniform mat4 pivotTransform; +uniform float zScale; + +varying vec2 v_colorTexCoords; +varying vec2 v_maskTexCoords; + +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.xyz, 1.0) * modelView; + vec4 offset = vec4(a_normal, 0.0, 0.0) * projection; + + float pivotZ = a_position.w; + + vec4 projectedPivot = pivot * projection; + 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; + v_maskTexCoords = a_maskTexCoords; +} diff --git a/drape/shaders/masked_texturing_fragment_shader.fsh b/drape/shaders/masked_texturing_fragment_shader.fsh new file mode 100644 index 0000000000..dff5c84cbc --- /dev/null +++ b/drape/shaders/masked_texturing_fragment_shader.fsh @@ -0,0 +1,13 @@ +uniform sampler2D u_colorTex; +uniform sampler2D u_maskTex; +uniform float u_opacity; + +varying vec2 v_colorTexCoords; +varying vec2 v_maskTexCoords; + +void main(void) +{ + vec4 finalColor = texture2D(u_colorTex, v_colorTexCoords) * texture2D(u_maskTex, v_maskTexCoords); + finalColor.a *= u_opacity; + gl_FragColor = finalColor; +} diff --git a/drape/shaders/masked_texturing_vertex_shader.vsh b/drape/shaders/masked_texturing_vertex_shader.vsh new file mode 100644 index 0000000000..66f03e7077 --- /dev/null +++ b/drape/shaders/masked_texturing_vertex_shader.vsh @@ -0,0 +1,26 @@ +attribute vec4 a_position; +attribute vec2 a_normal; +attribute vec2 a_colorTexCoords; +attribute vec2 a_maskTexCoords; + +uniform mat4 modelView; +uniform mat4 projection; +uniform mat4 pivotTransform; + +varying vec2 v_colorTexCoords; +varying vec2 v_maskTexCoords; + +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.xyz, 1) * modelView; + highp vec4 shiftedPos = vec4(a_normal, 0, 0) + pos; + shiftedPos = shiftedPos * projection; + float w = shiftedPos.w; + shiftedPos.xyw = (pivotTransform * vec4(shiftedPos.xy, 0.0, w)).xyw; + shiftedPos.z *= shiftedPos.w / w; + gl_Position = shiftedPos; + v_colorTexCoords = a_colorTexCoords; + v_maskTexCoords = a_maskTexCoords; +} diff --git a/drape/shaders/shader_index.txt b/drape/shaders/shader_index.txt index e517687ab6..54b94162c4 100644 --- a/drape/shaders/shader_index.txt +++ b/drape/shaders/shader_index.txt @@ -4,6 +4,7 @@ TEXT_OUTLINED_GUI_PROGRAM text_outlined_gui_vertex_shader.vsh text_fragment_shad AREA_PROGRAM area_vertex_shader.vsh solid_color_fragment_shader.fsh AREA_3D_PROGRAM area3d_vertex_shader.vsh texturing3d_fragment_shader.fsh TEXTURING_PROGRAM texturing_vertex_shader.vsh texturing_fragment_shader.fsh +MASKED_TEXTURING_PROGRAM masked_texturing_vertex_shader.vsh masked_texturing_fragment_shader.fsh LINE_PROGRAM line_vertex_shader.vsh line_fragment_shader.fsh CAP_JOIN_PROGRAM circle_shader.vsh circle_shader.fsh DASHED_LINE_PROGRAM dashed_vertex_shader.vsh dashed_fragment_shader.fsh @@ -20,6 +21,7 @@ DEBUG_RECT_PROGRAM debug_rect_vertex_shader.vsh debug_rect_fragment_shader.fsh TRANSPARENT_LAYER_PROGRAM transparent_layer_vertex_shader.vsh transparent_layer_fragment_shader.fsh ARROW_3D_PROGRAM arrow3d_vertex_shader.vsh arrow3d_fragment_shader.fsh TEXTURING_BILLBOARD_PROGRAM texturing_billboard_vertex_shader.vsh texturing_fragment_shader.fsh +MASKED_TEXTURING_BILLBOARD_PROGRAM masked_texturing_billboard_vertex_shader.vsh masked_texturing_fragment_shader.fsh TEXT_OUTLINED_BILLBOARD_PROGRAM text_outlined_billboard_vertex_shader.vsh text_fragment_shader.fsh TEXT_BILLBOARD_PROGRAM text_billboard_vertex_shader.vsh text_fragment_shader.fsh BOOKMARK_BILLBOARD_PROGRAM user_mark_billboard.vsh texturing_fragment_shader.fsh diff --git a/drape/utils/vertex_decl.cpp b/drape/utils/vertex_decl.cpp index f2afc6d793..462888f83f 100644 --- a/drape/utils/vertex_decl.cpp +++ b/drape/utils/vertex_decl.cpp @@ -11,6 +11,7 @@ enum VertexType Area, Area3d, SolidTexturing, + MaskedTexturing, TextStatic, TextOutlinedStatic, TextDynamic, @@ -68,6 +69,22 @@ dp::BindingInfo SolidTexturingBindingInit() return filler.m_info; } +dp::BindingInfo MaskedTexturingBindingInit() +{ + static_assert(sizeof(MaskedTexturingVertex) == (sizeof(MaskedTexturingVertex::TPosition3d) + + sizeof(MaskedTexturingVertex::TNormal) + + sizeof(MaskedTexturingVertex::TTexCoord) + + sizeof(MaskedTexturingVertex::TTexCoord)), ""); + + dp::BindingFiller<MaskedTexturingVertex> filler(4); + filler.FillDecl<SolidTexturingVertex::TPosition3d>("a_position"); + filler.FillDecl<SolidTexturingVertex::TNormal>("a_normal"); + filler.FillDecl<SolidTexturingVertex::TTexCoord>("a_colorTexCoords"); + filler.FillDecl<SolidTexturingVertex::TTexCoord>("a_maskTexCoords"); + + return filler.m_info; +} + dp::BindingInfo TextStaticBindingInit() { static_assert(sizeof(TextStaticVertex) == (2 * sizeof(TextStaticVertex::TTexCoord)), ""); @@ -152,6 +169,7 @@ TInitFunction g_initFunctions[TypeCount] = &AreaBindingInit, &Area3dBindingInit, &SolidTexturingBindingInit, + &MaskedTexturingBindingInit, &TextStaticBindingInit, &TextOutlinedStaticBindingInit, &TextDynamicBindingInit, @@ -218,7 +236,7 @@ SolidTexturingVertex::SolidTexturingVertex() { } -SolidTexturingVertex::SolidTexturingVertex(const TPosition3d & position, TNormal const & normal, +SolidTexturingVertex::SolidTexturingVertex(TPosition3d const & position, TNormal const & normal, TTexCoord const & colorTexCoord) : m_position(position) , m_normal(normal) @@ -231,6 +249,28 @@ dp::BindingInfo const & SolidTexturingVertex::GetBindingInfo() return GetBinding(SolidTexturing); } +MaskedTexturingVertex::MaskedTexturingVertex() + : m_position(0.0, 0.0, 0.0, 0.0) + , m_normal(0.0, 0.0) + , m_colorTexCoord(0.0, 0.0) + , m_maskTexCoord(0.0, 0.0) +{ +} + +MaskedTexturingVertex::MaskedTexturingVertex(TPosition3d const & position, TNormal const & normal, + TTexCoord const & colorTexCoord, TTexCoord const & maskTexCoord) + : m_position(position) + , m_normal(normal) + , m_colorTexCoord(colorTexCoord) + , m_maskTexCoord(maskTexCoord) +{ +} + +dp::BindingInfo const & MaskedTexturingVertex::GetBindingInfo() +{ + return GetBinding(MaskedTexturing); +} + TextOutlinedStaticVertex::TextOutlinedStaticVertex() : m_colorTexCoord(0.0, 0.0) , m_outlineTexCoord(0.0, 0.0) diff --git a/drape/utils/vertex_decl.hpp b/drape/utils/vertex_decl.hpp index a491b2a5b5..3d47c1303a 100644 --- a/drape/utils/vertex_decl.hpp +++ b/drape/utils/vertex_decl.hpp @@ -52,7 +52,20 @@ struct SolidTexturingVertex : BaseVertex static dp::BindingInfo const & GetBindingInfo(); }; -typedef buffer_vector<SolidTexturingVertex, 128> TSolidTexVertexBuffer; +using TSolidTexVertexBuffer = buffer_vector<SolidTexturingVertex, 128>; + +struct MaskedTexturingVertex : BaseVertex +{ + MaskedTexturingVertex(); + MaskedTexturingVertex(TPosition3d const & position, TNormal const & normal, + TTexCoord const & colorTexCoord, TTexCoord const & maskTexCoord); + TPosition3d m_position; + TNormal m_normal; + TTexCoord m_colorTexCoord; + TTexCoord m_maskTexCoord; + + static dp::BindingInfo const & GetBindingInfo(); +}; struct TextStaticVertex : BaseVertex { @@ -65,7 +78,7 @@ struct TextStaticVertex : BaseVertex static dp::BindingInfo const & GetBindingInfo(); }; -typedef buffer_vector<TextStaticVertex, 128> TTextStaticVertexBuffer; +using TTextStaticVertexBuffer = buffer_vector<TextStaticVertex, 128>; struct TextOutlinedStaticVertex : BaseVertex { @@ -81,7 +94,7 @@ public: static dp::BindingInfo const & GetBindingInfo(); }; -typedef buffer_vector<TextOutlinedStaticVertex, 128> TTextOutlinedStaticVertexBuffer; +using TTextOutlinedStaticVertexBuffer = buffer_vector<TextOutlinedStaticVertex, 128>; struct TextDynamicVertex : BaseVertex { @@ -95,7 +108,7 @@ struct TextDynamicVertex : BaseVertex static uint32_t GetDynamicStreamID(); }; -typedef buffer_vector<TextDynamicVertex, 128> TTextDynamicVertexBuffer; +using TTextDynamicVertexBuffer = buffer_vector<TextDynamicVertex, 128>; struct LineVertex : BaseVertex { |