forked from organicmaps/organicmaps
[drape] shaders clean up
This commit is contained in:
parent
d8415cb119
commit
8649b4e94c
13 changed files with 56 additions and 124 deletions
|
@ -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 \
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -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);
|
||||
}
|
|
@ -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;
|
||||
}
|
20
drape/shaders/text_vertex_shader.vsh
Executable file
20
drape/shaders/text_vertex_shader.vsh
Executable file
|
@ -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;
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue