forked from organicmaps/organicmaps
Fixed arrow rendering shader for Samsung Galaxy S3
This commit is contained in:
parent
a8b45fc4d9
commit
cc9aa209a0
1 changed files with 18 additions and 17 deletions
|
@ -5,26 +5,27 @@ uniform vec4 u_textureRect;
|
|||
|
||||
uniform mat4 u_arrowBorders;
|
||||
|
||||
vec2 calculateUv(vec2 len, vec4 arrowBorder)
|
||||
{
|
||||
vec2 uv = vec2(0, 0);
|
||||
if (len.x >= arrowBorder.x && len.x <= arrowBorder.z)
|
||||
{
|
||||
float coef = clamp((len.x - arrowBorder.x) / (arrowBorder.z - arrowBorder.x), 0.0, 1.0);
|
||||
float u = mix(arrowBorder.y, arrowBorder.w, coef);
|
||||
float v = 0.5 * len.y + 0.5;
|
||||
uv = vec2(mix(u_textureRect.x, u_textureRect.z, u), mix(u_textureRect.y, u_textureRect.w, v));
|
||||
}
|
||||
return uv;
|
||||
}
|
||||
|
||||
void main(void)
|
||||
{
|
||||
bool needDiscard = true;
|
||||
vec2 uv = vec2(0, 0);
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
vec4 arrowBorder = u_arrowBorders[i];
|
||||
if (v_length.x >= arrowBorder.x && v_length.x <= arrowBorder.z)
|
||||
{
|
||||
needDiscard = false;
|
||||
float coef = clamp((v_length.x - arrowBorder.x) / (arrowBorder.z - arrowBorder.x), 0.0, 1.0);
|
||||
float u = mix(arrowBorder.y, arrowBorder.w, coef);
|
||||
float v = 0.5 * v_length.y + 0.5;
|
||||
uv = vec2(mix(u_textureRect.x, u_textureRect.z, u), mix(u_textureRect.y, u_textureRect.w, v));
|
||||
}
|
||||
}
|
||||
vec4 arrowBorder = u_arrowBorders[0];
|
||||
vec2 uv = calculateUv(v_length, u_arrowBorders[0]) +
|
||||
calculateUv(v_length, u_arrowBorders[1]) +
|
||||
calculateUv(v_length, u_arrowBorders[2]) +
|
||||
calculateUv(v_length, u_arrowBorders[3]);
|
||||
|
||||
vec4 color = texture2D(u_colorTex, uv);
|
||||
if (needDiscard)
|
||||
color.a = 0.0;
|
||||
|
||||
gl_FragColor = color;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue