diff --git a/drape/shaders/shader_index.txt b/drape/shaders/shader_index.txt index 69abd529f0..0cb04433ee 100644 --- a/drape/shaders/shader_index.txt +++ b/drape/shaders/shader_index.txt @@ -1,5 +1,6 @@ TEXT_OUTLINED_PROGRAM text_outlined_vertex_shader.vsh text_fragment_shader.fsh TEXT_PROGRAM text_vertex_shader.vsh text_fragment_shader.fsh +TEXT_OUTLINED_GUI_PROGRAM text_outlined_gui_vertex_shader.vsh text_fragment_shader.fsh AREA_PROGRAM area_vertex_shader.vsh solid_color_fragment_shader.fsh TEXTURING_PROGRAM texturing_vertex_shader.vsh texturing_fragment_shader.fsh LINE_PROGRAM line_vertex_shader.vsh line_fragment_shader.fsh diff --git a/drape/shaders/text_outlined_gui_vertex_shader.vsh b/drape/shaders/text_outlined_gui_vertex_shader.vsh new file mode 100755 index 0000000000..45206f029b --- /dev/null +++ b/drape/shaders/text_outlined_gui_vertex_shader.vsh @@ -0,0 +1,42 @@ +attribute vec4 a_position; +attribute vec2 a_normal; +attribute vec2 a_colorTexCoord; +attribute vec2 a_outlineColorTexCoord; +attribute vec2 a_maskTexCoord; + +uniform mat4 modelView; +uniform mat4 projection; +uniform float u_isOutlinePass; + +#ifdef ENABLE_VTF +uniform sampler2D u_colorTex; +varying lowp vec4 v_color; +#else +varying vec2 v_colorTexCoord; +#endif + +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 depthShift = BaseDepthShift * isOutline; + + // 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; + highp vec4 shiftedPos = vec4(a_normal, Zero, Zero) + pos; + gl_Position = shiftedPos * projection; + vec2 colorTexCoord = a_colorTexCoord * notOutline + a_outlineColorTexCoord * isOutline; +#ifdef ENABLE_VTF + v_color = texture2D(u_colorTex, colorTexCoord); +#else + v_colorTexCoord = colorTexCoord; +#endif + v_maskTexCoord = a_maskTexCoord; +} diff --git a/drape_frontend/gui/gui_text.cpp b/drape_frontend/gui/gui_text.cpp index ce902bd3d6..b6eebf9781 100644 --- a/drape_frontend/gui/gui_text.cpp +++ b/drape_frontend/gui/gui_text.cpp @@ -105,7 +105,7 @@ dp::BindingInfo const & StaticLabel::Vertex::GetBindingInfo() return *info.get(); } -StaticLabel::LabelResult::LabelResult() : m_state(gpu::TEXT_OUTLINED_PROGRAM, dp::GLState::Gui) {} +StaticLabel::LabelResult::LabelResult() : m_state(gpu::TEXT_OUTLINED_GUI_PROGRAM, dp::GLState::Gui) {} char const * StaticLabel::DefaultDelim = "\n"; @@ -281,7 +281,7 @@ dp::BindingInfo const & MutableLabel::DynamicVertex::GetBindingInfo() return *info.get(); } -MutableLabel::PrecacheResult::PrecacheResult() : m_state(gpu::TEXT_OUTLINED_PROGRAM, dp::GLState::Gui) {} +MutableLabel::PrecacheResult::PrecacheResult() : m_state(gpu::TEXT_OUTLINED_GUI_PROGRAM, dp::GLState::Gui) {} MutableLabel::MutableLabel(dp::Anchor anchor) : m_anchor(anchor)