Fixed gui text rendering in 3d.

This commit is contained in:
Daria Volvenkova 2015-11-25 13:59:05 +03:00
parent c98f0daa21
commit c2db00a999
3 changed files with 45 additions and 2 deletions

View file

@ -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

View file

@ -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;
}

View file

@ -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)