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:
authorExMix <rahuba.youri@mapswithme.com>2014-12-30 15:47:27 +0300
committerAlex Zolotarev <alex@maps.me>2015-09-23 02:35:47 +0300
commit8649b4e94cd701f124cb23b72dde6c8802fb7bb2 (patch)
tree5c9cc8c7315ec0eacbaa7b86ab84600bcc10883d /drape
parentd8415cb119e00105fbeaacf8807f34518fac473b (diff)
[drape] shaders clean up
Diffstat (limited to 'drape')
-rw-r--r--drape/drape.pro11
-rwxr-xr-xdrape/shaders/font_vertex_shader.vsh20
-rw-r--r--drape/shaders/line_fragment_shader.fsh11
-rw-r--r--drape/shaders/line_vertex_shader.vsh8
-rw-r--r--drape/shaders/normalize_vertex_shader.vsh14
-rwxr-xr-xdrape/shaders/path_font_vertex_shader.vsh20
-rw-r--r--drape/shaders/shader_index.txt8
-rw-r--r--drape/shaders/simple_vertex_shader.vsh13
-rw-r--r--drape/shaders/solid_color_fragment_shader.fsh8
-rwxr-xr-xdrape/shaders/text_fragment_shader.fsh (renamed from drape/shaders/font_fragment_shader.fsh)28
-rwxr-xr-xdrape/shaders/text_vertex_shader.vsh20
-rw-r--r--drape/shaders/texturing_fragment_shader.fsh7
-rw-r--r--drape/shaders/texturing_vertex_shader.vsh12
13 files changed, 56 insertions, 124 deletions
diff --git a/drape/drape.pro b/drape/drape.pro
index 90b932aab0..59cd04d5cc 100644
--- a/drape/drape.pro
+++ b/drape/drape.pro
@@ -20,15 +20,10 @@ include($$DRAPE_DIR/drape_common.pri)
SOURCES += glfunctions.cpp
OTHER_FILES += \
- shaders/simple_vertex_shader.vsh \
- shaders/solid_area_fragment_shader.fsh \
shaders/texturing_vertex_shader.vsh \
- shaders/shader_index.txt \
shaders/texturing_fragment_shader.fsh \
+ shaders/shader_index.txt \
shaders/line_vertex_shader.vsh \
shaders/line_fragment_shader.fsh \
- shaders/solid_color_fragment_shader.fsh \
- shaders/normalize_vertex_shader.vsh \
- shaders/font_fragment_shader.fsh \
- shaders/font_vertex_shader.vsh \
- shaders/path_font_vertex_shader.vsh \
+ shaders/text_fragment_shader.fsh \
+ shaders/text_vertex_shader.vsh \
diff --git a/drape/shaders/font_vertex_shader.vsh b/drape/shaders/font_vertex_shader.vsh
deleted file mode 100755
index 6cde38ca67..0000000000
--- a/drape/shaders/font_vertex_shader.vsh
+++ /dev/null
@@ -1,20 +0,0 @@
-attribute vec4 a_position;
-attribute vec4 a_texcoord;
-attribute vec4 a_color;
-attribute float a_index;
-
-uniform mat4 modelView;
-uniform mat4 projection;
-
-varying vec3 v_texcoord;
-varying vec4 v_colors;
-varying float v_index;
-
-void main()
-{
- gl_Position = (vec4(a_position.zw, 0, 0) + (vec4(a_position.xy, a_texcoord.w, 1) * modelView)) * projection;
-
- v_texcoord = a_texcoord.xyz;
- v_colors = a_color;
- v_index = a_index;
-}
diff --git a/drape/shaders/line_fragment_shader.fsh b/drape/shaders/line_fragment_shader.fsh
index 9ca5e16712..326874bc3f 100644
--- a/drape/shaders/line_fragment_shader.fsh
+++ b/drape/shaders/line_fragment_shader.fsh
@@ -2,10 +2,11 @@ varying float v_dx;
varying vec4 v_radius;
varying vec2 v_type;
-varying vec3 v_color;
-varying vec3 v_mask;
+varying vec2 v_color;
+varying vec2 v_mask;
-~getTexel~
+uniform sampler2D u_colorTex;
+uniform sampler2D u_maskTex;
void main(void)
{
@@ -27,7 +28,7 @@ void main(void)
else if (v_type.y > 0.1 && abs(v_dx) >= 1.0 && (squareDist + capY > squareRadius))
discard;
- vec4 color = getTexel(int(v_color.z), v_color.xy);
- color.a = getTexel(int(v_mask.z), v_mask.xy).a;
+ vec4 color = texture2D(u_colorTex, v_color);
+ color.a = texture2D(u_maskTex, v_mask).a;
gl_FragColor = color;
}
diff --git a/drape/shaders/line_vertex_shader.vsh b/drape/shaders/line_vertex_shader.vsh
index 777affb7a7..537f4a4a87 100644
--- a/drape/shaders/line_vertex_shader.vsh
+++ b/drape/shaders/line_vertex_shader.vsh
@@ -2,15 +2,15 @@ attribute vec4 a_position;
attribute vec4 a_deltas;
attribute vec4 a_width_type;
attribute vec4 a_centres;
-attribute vec3 a_color;
-attribute vec3 a_mask;
+attribute vec2 a_color;
+attribute vec2 a_mask;
varying float v_dx;
varying vec4 v_radius;
varying vec2 v_type;
-varying vec3 v_color;
-varying vec3 v_mask;
+varying vec2 v_color;
+varying vec2 v_mask;
uniform mat4 modelView;
uniform mat4 projection;
diff --git a/drape/shaders/normalize_vertex_shader.vsh b/drape/shaders/normalize_vertex_shader.vsh
deleted file mode 100644
index ef5196d1df..0000000000
--- a/drape/shaders/normalize_vertex_shader.vsh
+++ /dev/null
@@ -1,14 +0,0 @@
-attribute vec4 a_position;
-attribute vec4 a_normal;
-attribute vec3 a_color_index;
-
-uniform mat4 modelView;
-uniform mat4 projection;
-
-varying vec3 v_color_index;
-
-void main(void)
-{
- gl_Position = ((a_position * modelView) + a_normal) * projection;
- v_color_index = a_color_index;
-}
diff --git a/drape/shaders/path_font_vertex_shader.vsh b/drape/shaders/path_font_vertex_shader.vsh
deleted file mode 100755
index 59a689cad0..0000000000
--- a/drape/shaders/path_font_vertex_shader.vsh
+++ /dev/null
@@ -1,20 +0,0 @@
-attribute vec2 a_position;
-attribute vec4 a_texcoord;
-attribute vec4 a_color;
-attribute float a_index;
-
-uniform mat4 modelView;
-uniform mat4 projection;
-
-varying vec3 v_texcoord;
-varying vec4 v_colors;
-varying float v_index;
-
-void main()
-{
- gl_Position = vec4(a_position, a_texcoord.w, 1) * modelView * projection;
-
- v_texcoord = a_texcoord.xyz;
- v_colors = a_color;
- v_index = a_index;
-}
diff --git a/drape/shaders/shader_index.txt b/drape/shaders/shader_index.txt
index 9bdd7887f4..eece273841 100644
--- a/drape/shaders/shader_index.txt
+++ b/drape/shaders/shader_index.txt
@@ -1,7 +1,3 @@
-SOLID_AREA_PROGRAM simple_vertex_shader.vsh solid_color_fragment_shader.fsh
-SOLID_SHAPE_PROGRAM normalize_vertex_shader.vsh solid_color_fragment_shader.fsh
TEXTURING_PROGRAM texturing_vertex_shader.vsh texturing_fragment_shader.fsh
-SOLID_LINE_PROGRAM line_vertex_shader.vsh line_fragment_shader.fsh
-TEST_DYN_ATTR_PROGRAM normalize_vertex_shader.vsh solid_color_fragment_shader.fsh
-FONT_PROGRAM font_vertex_shader.vsh font_fragment_shader.fsh
-PATH_FONT_PROGRAM path_font_vertex_shader.vsh font_fragment_shader.fsh
+LINE_PROGRAM line_vertex_shader.vsh line_fragment_shader.fsh
+TEXT_PROGRAM text_vertex_shader.vsh text_fragment_shader.fsh
diff --git a/drape/shaders/simple_vertex_shader.vsh b/drape/shaders/simple_vertex_shader.vsh
deleted file mode 100644
index 2ddd28d68d..0000000000
--- a/drape/shaders/simple_vertex_shader.vsh
+++ /dev/null
@@ -1,13 +0,0 @@
-attribute vec4 a_position;
-attribute vec3 a_color_index;
-
-uniform mat4 modelView;
-uniform mat4 projection;
-
-varying vec3 v_color_index;
-
-void main(void)
-{
- gl_Position = a_position * modelView * projection;
- v_color_index = a_color_index;
-}
diff --git a/drape/shaders/solid_color_fragment_shader.fsh b/drape/shaders/solid_color_fragment_shader.fsh
deleted file mode 100644
index 1f57f35738..0000000000
--- a/drape/shaders/solid_color_fragment_shader.fsh
+++ /dev/null
@@ -1,8 +0,0 @@
-varying vec3 v_color_index;
-
-~getTexel~
-
-void main(void)
-{
- gl_FragColor = getTexel(int(v_color_index.z), v_color_index.xy);
-}
diff --git a/drape/shaders/font_fragment_shader.fsh b/drape/shaders/text_fragment_shader.fsh
index c758e4c367..48e021f400 100755
--- a/drape/shaders/font_fragment_shader.fsh
+++ b/drape/shaders/text_fragment_shader.fsh
@@ -1,8 +1,9 @@
-varying vec3 v_texcoord;
-varying vec4 v_colors;
-varying float v_index;
+varying vec2 v_colorTexCoord;
+varying vec2 v_outlineColorTexCoord;
+varying vec2 v_maskTexCoord;
-~getTexel~
+uniform sampler2D u_colorTex;
+uniform sampler2D u_maskTex;
const lowp float OUTLINE_MIN_VALUE0 = 0.41;
const lowp float OUTLINE_MIN_VALUE1 = 0.565;
@@ -17,7 +18,7 @@ vec4 colorize(vec4 base, vec4 outline, float alpha)
return vec4(outline.rgb, 0);
if (alpha > OUTLINE_MAX_VALUE0)
{
- float oFactor = smoothstep(OUTLINE_MAX_VALUE1, OUTLINE_MAX_VALUE0, alpha );
+ float oFactor = smoothstep(OUTLINE_MAX_VALUE1, OUTLINE_MAX_VALUE0, alpha);
return mix(vec4(outline.rgb,0), outline, oFactor);
}
if (alpha > OUTLINE_MIN_VALUE1)
@@ -26,7 +27,7 @@ vec4 colorize(vec4 base, vec4 outline, float alpha)
}
if (alpha > OUTLINE_MIN_VALUE0)
{
- float oFactor = smoothstep(OUTLINE_MIN_VALUE0, OUTLINE_MIN_VALUE1, alpha );
+ float oFactor = smoothstep(OUTLINE_MIN_VALUE0, OUTLINE_MIN_VALUE1, alpha);
return mix(base, outline, oFactor);
}
return base;
@@ -44,18 +45,15 @@ vec4 without_outline(vec4 base, float alpha)
void main (void)
{
- int shapeIndex = int(v_texcoord.z / 2.0);
- int colorIndex = int(v_index);
- vec4 base = getTexel(colorIndex, v_colors.xy);;
- vec4 outline = getTexel(colorIndex, v_colors.zw);
- float alpha = getTexel(shapeIndex, v_texcoord.xy).a;
+ vec4 base = texture2D(u_colorTex, v_colorTexCoord);
+ vec4 outline = texture2D(u_colorTex, v_outlineColorTexCoord);
+ float alpha = texture2D(u_maskTex, v_maskTexCoord).a;
- float needOutline = (fract(v_texcoord.z / 2.0)) * 2.0;
vec4 finalColor;
- if (needOutline > 0.5)
- finalColor = colorize(base, outline, 1.0 - base.a*alpha);
+ if (outline.a > 0.1)
+ finalColor = colorize(base, outline, 1.0 - base.a * alpha);
else
- finalColor = without_outline(base, 1.0 - base.a*alpha);
+ finalColor = without_outline(base, 1.0 - base.a * alpha);
gl_FragColor = finalColor;
}
diff --git a/drape/shaders/text_vertex_shader.vsh b/drape/shaders/text_vertex_shader.vsh
new file mode 100755
index 0000000000..344a8c049c
--- /dev/null
+++ b/drape/shaders/text_vertex_shader.vsh
@@ -0,0 +1,20 @@
+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;
+
+varying vec2 v_colorTexCoord;
+varying vec2 v_maskTexCoord;
+varying vec2 v_outlineColorTexCoord;
+
+void main()
+{
+ gl_Position = (vec4(a_normal, 0, 0) + a_position * modelView) * projection;
+ v_colorTexCoord = a_colorTexCoord;
+ v_maskTexCoord = a_maskTexCoord;
+ v_outlineColorTexCoord = a_outlineColorTexCoord;
+}
diff --git a/drape/shaders/texturing_fragment_shader.fsh b/drape/shaders/texturing_fragment_shader.fsh
index 9afde9f7f9..9874628e86 100644
--- a/drape/shaders/texturing_fragment_shader.fsh
+++ b/drape/shaders/texturing_fragment_shader.fsh
@@ -1,9 +1,8 @@
-varying vec2 v_texCoords;
-varying float v_textureIndex;
+uniform sampler2D u_colorTex;
-~getTexel~
+varying vec2 v_colorTexCoords;
void main(void)
{
- gl_FragColor = getTexel(int(v_textureIndex), v_texCoords);
+ gl_FragColor = texture2D(u_colorTex, v_colorTexCoords);
}
diff --git a/drape/shaders/texturing_vertex_shader.vsh b/drape/shaders/texturing_vertex_shader.vsh
index 167852012e..f4fe0318be 100644
--- a/drape/shaders/texturing_vertex_shader.vsh
+++ b/drape/shaders/texturing_vertex_shader.vsh
@@ -1,16 +1,14 @@
-attribute vec4 a_position;
+attribute vec3 a_position;
attribute vec2 a_normal;
-attribute vec3 a_texCoords;
+attribute vec2 a_colorTexCoords;
uniform mat4 modelView;
uniform mat4 projection;
-varying vec2 v_texCoords;
-varying float v_textureIndex;
+varying vec2 v_colorTexCoords;
void main(void)
{
- gl_Position = (vec4(a_normal.xy, 0, 0) + a_position * modelView) * projection;
- v_texCoords = a_texCoords.st;
- v_textureIndex = a_texCoords.z;
+ gl_Position = (vec4(a_normal, 0, 0) + vec4(a_position, 1) * modelView) * projection;
+ v_colorTexCoords = a_colorTexCoords;
}