do premultiplication of alpha in blend function
This commit is contained in:
@@ -43,9 +43,9 @@ class LineLayer extends Layer {
|
|||||||
|
|
||||||
float a = (color >> 24 & 0xff) / 255.0f;
|
float a = (color >> 24 & 0xff) / 255.0f;
|
||||||
|
|
||||||
colors[0] = (color >> 16 & 0xff) / 255.0f * a;
|
colors[0] = (color >> 16 & 0xff) / 255.0f;
|
||||||
colors[1] = (color >> 8 & 0xff) / 255.0f * a;
|
colors[1] = (color >> 8 & 0xff) / 255.0f;
|
||||||
colors[2] = (color >> 0 & 0xff) / 255.0f * a;
|
colors[2] = (color >> 0 & 0xff) / 255.0f;
|
||||||
colors[3] = a;
|
colors[3] = a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -463,9 +463,9 @@ public class MapRenderer implements org.mapsforge.android.MapRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
GLES20.glUniform4f(gPolygonColorHandle,
|
GLES20.glUniform4f(gPolygonColorHandle,
|
||||||
(color >> 16 & 0xff) / 255f * alpha,
|
(color >> 16 & 0xff) / 255f,
|
||||||
(color >> 8 & 0xff) / 255f * alpha,
|
(color >> 8 & 0xff) / 255f,
|
||||||
(color & 0xff) / 255f * alpha, alpha);
|
(color & 0xff) / 255f, alpha);
|
||||||
|
|
||||||
// set stencil buffer mask used to draw this layer
|
// set stencil buffer mask used to draw this layer
|
||||||
GLES20.glStencilFunc(GLES20.GL_EQUAL, 0xff, 1 << c);
|
GLES20.glStencilFunc(GLES20.GL_EQUAL, 0xff, 1 << c);
|
||||||
@@ -540,11 +540,11 @@ public class MapRenderer implements org.mapsforge.android.MapRenderer {
|
|||||||
else {
|
else {
|
||||||
// clear stencilbuffer
|
// clear stencilbuffer
|
||||||
GLES20.glStencilMask(0xFF);
|
GLES20.glStencilMask(0xFF);
|
||||||
GLES20.glClear(GLES20.GL_STENCIL_BUFFER_BIT);
|
// GLES20.glClear(GLES20.GL_STENCIL_BUFFER_BIT);
|
||||||
|
|
||||||
// clear stencilbuffer (tile region)
|
// clear stencilbuffer (tile region)
|
||||||
// GLES20.glStencilOp(GLES20.GL_ZERO, GLES20.GL_ZERO, GLES20.GL_ZERO);
|
GLES20.glStencilOp(GLES20.GL_ZERO, GLES20.GL_ZERO, GLES20.GL_ZERO);
|
||||||
// GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
|
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, 0, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
// stencil op for stencil method polygon drawing
|
// stencil op for stencil method polygon drawing
|
||||||
@@ -562,7 +562,7 @@ public class MapRenderer implements org.mapsforge.android.MapRenderer {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
// modify alpha channel
|
// modify alpha channel
|
||||||
float s = ((mDrawScale / z) < 1.3f ? 1.3f : (mDrawScale / z));
|
float s = (mDrawScale > 1.3f ? mDrawScale : 1.3f);
|
||||||
colors[cnt] = (colors[cnt] & 0xffffff)
|
colors[cnt] = (colors[cnt] & 0xffffff)
|
||||||
| (byte) ((s - 1) * 0xff) << 24;
|
| (byte) ((s - 1) * 0xff) << 24;
|
||||||
}
|
}
|
||||||
@@ -1094,10 +1094,10 @@ public class MapRenderer implements org.mapsforge.android.MapRenderer {
|
|||||||
GLES20.glEnableVertexAttribArray(gLineVertexPositionHandle);
|
GLES20.glEnableVertexAttribArray(gLineVertexPositionHandle);
|
||||||
GLES20.glEnableVertexAttribArray(gLineTexturePositionHandle);
|
GLES20.glEnableVertexAttribArray(gLineTexturePositionHandle);
|
||||||
|
|
||||||
GLES20.glBlendFunc(GLES20.GL_ONE, GLES20.GL_ONE_MINUS_SRC_ALPHA);
|
GLES20.glBlendFunc(GLES20.GL_SRC_ALPHA, GLES20.GL_ONE_MINUS_SRC_ALPHA);
|
||||||
GLES20.glDisable(GLES20.GL_DEPTH_TEST);
|
GLES20.glDisable(GLES20.GL_DEPTH_TEST);
|
||||||
GLES20.glDisable(GLES20.GL_DITHER);
|
GLES20.glDisable(GLES20.GL_DITHER);
|
||||||
GLES20.glClearColor(0.96f, 0.96f, 0.95f, 1.0f);
|
GLES20.glClearColor(0.98f, 0.98f, 0.975f, 1.0f);
|
||||||
GLES20.glClearStencil(0);
|
GLES20.glClearStencil(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ class Shaders {
|
|||||||
final static String gLineVertexShader = ""
|
final static String gLineVertexShader = ""
|
||||||
+ "precision mediump float; \n"
|
+ "precision mediump float; \n"
|
||||||
+ "uniform mat4 u_center;"
|
+ "uniform mat4 u_center;"
|
||||||
// + "uniform float u_width;"
|
|
||||||
+ "attribute vec4 a_position;"
|
+ "attribute vec4 a_position;"
|
||||||
+ "attribute vec2 a_st;"
|
+ "attribute vec2 a_st;"
|
||||||
+ "varying vec2 v_st;"
|
+ "varying vec2 v_st;"
|
||||||
@@ -30,31 +29,65 @@ class Shaders {
|
|||||||
|
|
||||||
final static String gLineFragmentShader = ""
|
final static String gLineFragmentShader = ""
|
||||||
+ "#extension GL_OES_standard_derivatives : enable\n"
|
+ "#extension GL_OES_standard_derivatives : enable\n"
|
||||||
+ "#pragma profilepragma blendoperation(gl_FragColor, GL_FUNC_ADD, GL_ONE, GL_ONE_MINUS_SRC_ALPHA)\n"
|
|
||||||
+ "precision mediump float;"
|
+ "precision mediump float;"
|
||||||
+ "uniform vec2 u_mode;"
|
+ "uniform vec2 u_mode;"
|
||||||
+ "uniform vec4 u_color;"
|
+ "uniform vec4 u_color;"
|
||||||
+ "const float zero = 0.0;"
|
+ "const float zero = 0.0;"
|
||||||
+ "const vec4 blank = vec4(0.0,0.0,0.0,0.0);"
|
+ "const float fuzzf = 1.5;"
|
||||||
|
// + "const vec4 blank = vec4(0.0,0.0,0.0,0.0);"
|
||||||
+ "varying vec2 v_st;"
|
+ "varying vec2 v_st;"
|
||||||
+ "void main() {"
|
+ "void main() {"
|
||||||
+ "float width = u_mode[1];"
|
+ " lowp vec4 color = u_color;"
|
||||||
+ " if (v_st.t == zero){ "
|
+ " lowp float len;"
|
||||||
+ " float fuzz = fwidth(v_st.s) * 1.5;"
|
+ " lowp float fuzz;"
|
||||||
+ " float min_fuzz = -fuzz * u_mode[0];"
|
+ " lowp float width = u_mode[1];"
|
||||||
+ " float len = width - abs(v_st.s);"
|
+ " if (v_st.t == zero){ "
|
||||||
// + " if (len > fuzz)"
|
+ " fuzz = fwidth(v_st.s) * fuzzf;"
|
||||||
// + " gl_FragColor = u_color;"
|
+ " len = width - abs(v_st.s);"
|
||||||
// + " else if (len < min_fuzz)"
|
+ " } else {"
|
||||||
// + " gl_FragColor = blank;"
|
+ " fuzz = max(fwidth(v_st.s), fwidth(v_st.t)) * fuzzf;"
|
||||||
// + " else"
|
+ " len = width - length(v_st);"
|
||||||
+ " gl_FragColor = u_color * smoothstep(min_fuzz, fuzz, len);"
|
+ " } "
|
||||||
+ " } else {"
|
+ " lowp float min_fuzz = -fuzz * u_mode[0];"
|
||||||
+ " float fuzz = max(fwidth(v_st.s), fwidth(v_st.t)) * 1.5;"
|
+ " if (len < min_fuzz)"
|
||||||
+ " gl_FragColor = u_color * smoothstep(-fuzz * u_mode[0], fuzz, width - length(v_st));"
|
+ " discard;"
|
||||||
+ " } "
|
// + " color = blank;"
|
||||||
|
+ " else {"
|
||||||
|
+ " if (len < fuzz)"
|
||||||
|
+ " color.a *= smoothstep(min_fuzz, fuzz, len);"
|
||||||
|
+ " gl_FragColor = color;"
|
||||||
|
+ " }"
|
||||||
+ "}";
|
+ "}";
|
||||||
|
|
||||||
|
// final static String gLineFragmentShader = ""
|
||||||
|
// + "#extension GL_OES_standard_derivatives : enable\n"
|
||||||
|
// + "#pragma profilepragma blendoperation(gl_FragColor, GL_FUNC_ADD, GL_ONE, GL_ONE_MINUS_SRC_ALPHA)\n"
|
||||||
|
// + "precision mediump float;"
|
||||||
|
// + "uniform vec2 u_mode;"
|
||||||
|
// + "uniform vec4 u_color;"
|
||||||
|
// + "const float zero = 0.0;"
|
||||||
|
// + "const vec4 blank = vec4(0.0,0.0,0.0,0.0);"
|
||||||
|
// + "varying vec2 v_st;"
|
||||||
|
// + "void main() {"
|
||||||
|
// + "lowp color = u_color;"
|
||||||
|
// + "lowp alpha = 1.0;"
|
||||||
|
// + "float width = u_mode[1];"
|
||||||
|
// + " if (v_st.t == zero){ "
|
||||||
|
// + " float fuzz = fwidth(v_st.s) * 1.5;"
|
||||||
|
// + " float min_fuzz = -fuzz * u_mode[0];"
|
||||||
|
// + " float len = width - abs(v_st.s);"
|
||||||
|
// // + " if (len > fuzz)"
|
||||||
|
// // + " gl_FragColor = u_color;"
|
||||||
|
// // + " else if (len < min_fuzz)"
|
||||||
|
// // + " gl_FragColor = blank;"
|
||||||
|
// // + " else"
|
||||||
|
// + " gl_FragColor = u_color * smoothstep(min_fuzz, fuzz, len);"
|
||||||
|
// + " } else {"
|
||||||
|
// + " float fuzz = max(fwidth(v_st.s), fwidth(v_st.t)) * 1.5;"
|
||||||
|
// + " gl_FragColor = u_color * smoothstep(-fuzz * u_mode[0], fuzz, width - length(v_st));"
|
||||||
|
// + " } "
|
||||||
|
// + "glFragColor = color"
|
||||||
|
// + "}";
|
||||||
// final static String gLineFragmentShader = ""
|
// final static String gLineFragmentShader = ""
|
||||||
// + "#extension GL_OES_standard_derivatives : enable\n"
|
// + "#extension GL_OES_standard_derivatives : enable\n"
|
||||||
// + "precision mediump float;"
|
// + "precision mediump float;"
|
||||||
@@ -135,7 +168,6 @@ class Shaders {
|
|||||||
+ "}";
|
+ "}";
|
||||||
|
|
||||||
final static String gPolygonFragmentShader = ""
|
final static String gPolygonFragmentShader = ""
|
||||||
+ "#pragma profilepragma blendoperation(gl_FragColor, GL_FUNC_ADD, GL_ONE, GL_ONE_MINUS_SRC_ALPHA)\n"
|
|
||||||
+ "precision mediump float;"
|
+ "precision mediump float;"
|
||||||
+ "uniform vec4 u_color;"
|
+ "uniform vec4 u_color;"
|
||||||
+ "void main() {"
|
+ "void main() {"
|
||||||
|
|||||||
@@ -56,12 +56,12 @@
|
|||||||
stroke-linecap="butt" />
|
stroke-linecap="butt" />
|
||||||
</rule>
|
</rule>
|
||||||
<rule e="way" k="*"
|
<rule e="way" k="*"
|
||||||
v="pedestrian|unclassified|residential|living_street|byway">
|
v="pedestrian|unclassified|residential|living_street|byway|tertiary">
|
||||||
<line stroke="#ffffff" stroke-width="1.3" outline="0"
|
<line stroke="#ffffff" stroke-width="1.3" outline="0"
|
||||||
stroke-linecap="butt" />
|
stroke-linecap="butt" />
|
||||||
</rule>
|
</rule>
|
||||||
<rule e="way" k="*"
|
<rule e="way" k="*"
|
||||||
v="tertiary|secondary_link|primary_link|trunk_link|motorway_link|secondary|primary">
|
v="secondary_link|primary_link|trunk_link|motorway_link|secondary|primary">
|
||||||
<line stroke="#bbffff9a" stroke-width="1.5" outline="0"
|
<line stroke="#bbffff9a" stroke-width="1.5" outline="0"
|
||||||
stroke-linecap="butt" />
|
stroke-linecap="butt" />
|
||||||
</rule>
|
</rule>
|
||||||
@@ -106,16 +106,22 @@
|
|||||||
<rule e="way" k="*" v="farmland|farm">
|
<rule e="way" k="*" v="farmland|farm">
|
||||||
<area fill="#fff8bf" fade="12" />
|
<area fill="#fff8bf" fade="12" />
|
||||||
</rule>
|
</rule>
|
||||||
<rule e="way" k="*" v="allotments|village_green|recreation_ground">
|
<!-- <rule e="way" k="*" v="village_green|recreation_ground">
|
||||||
<area fill="#c9d8a2" fade="12" />
|
<area fill="#daebaf" fade="12" />
|
||||||
</rule>
|
</rule> -->
|
||||||
|
<!-- <rule e="way" k="*" v="allotments|village_green|recreation_ground">
|
||||||
|
<area fill="#e7f7c1" fade="12" />
|
||||||
|
</rule> -->
|
||||||
<rule e="way" k="*" v="reservoir|basin">
|
<rule e="way" k="*" v="reservoir|basin">
|
||||||
<area fill="#b4cbdc" />
|
<area fill="#b4cbdc" />
|
||||||
</rule>
|
</rule>
|
||||||
</rule>
|
</rule>
|
||||||
|
|
||||||
|
|
||||||
|
<rule e="way" k="leisure|landuse" v="allotments|village_green|recreation_ground|garden|golf_course|dog_park" zoom-min="12">
|
||||||
|
<area fill="#e7f7c1" fade="12" />
|
||||||
|
</rule>
|
||||||
|
|
||||||
|
|
||||||
<rule e="way" k="leisure" v="*" zoom-min="12">
|
<rule e="way" k="leisure" v="*" zoom-min="12">
|
||||||
<rule e="way" k="*" v="park|common|green">
|
<rule e="way" k="*" v="park|common|green">
|
||||||
@@ -160,7 +166,7 @@
|
|||||||
<area fill="#f8f8f8" />
|
<area fill="#f8f8f8" />
|
||||||
</rule>
|
</rule>
|
||||||
<rule e="way" k="*" v="beach">
|
<rule e="way" k="*" v="beach">
|
||||||
<area fill="#eecc55" />
|
<area fill="#fcfeab" />
|
||||||
</rule>
|
</rule>
|
||||||
<!-- Heideland -->
|
<!-- Heideland -->
|
||||||
<rule e="way" k="*" v="heath">
|
<rule e="way" k="*" v="heath">
|
||||||
@@ -173,23 +179,23 @@
|
|||||||
|
|
||||||
|
|
||||||
<!-- leisure -->
|
<!-- leisure -->
|
||||||
<rule e="way" k="leisure" v="*" zoom-min="12">
|
<rule e="way" k="leisure" v="*" zoom-min="13">
|
||||||
|
|
||||||
<rule e="way" k="*" v="garden|golf_course">
|
<!-- playground| -->
|
||||||
<area fill="#d7e6b0" fade="12" />
|
|
||||||
|
<!-- sollte unter playing field sein -->
|
||||||
|
<rule e="way" k="*" zoom_min="14" v="sports_centre|water_park">
|
||||||
|
<area fill="#daefdb" fade="12" />
|
||||||
</rule>
|
</rule>
|
||||||
|
|
||||||
<rule e="way" k="*" v="*" zoom-min="15">
|
<rule e="way" k="*" v="*" zoom-min="15">
|
||||||
<rule e="way" k="*" v="playground|playing_fields|pitch|dog_park">
|
<rule e="way" k="*" v="playing_fields|pitch">
|
||||||
<area fill="#d7e6b0" stroke="#b7c690" stroke-width="0.2" />
|
<area fill="#f4f4de" />
|
||||||
|
<line stroke="#dbdbc8" stroke-width="0.6" fixed="true"
|
||||||
|
stroke-linecap="butt" />
|
||||||
</rule>
|
</rule>
|
||||||
</rule>
|
</rule>
|
||||||
|
|
||||||
|
|
||||||
<rule e="way" k="*" v="sports_centre|water_park">
|
|
||||||
<area fill="#c9d8a2" fade="12" />
|
|
||||||
</rule>
|
|
||||||
|
|
||||||
<!-- <rule e="way" k="*" v="track"> <rule e="way" k="area" v="yes|true">
|
<!-- <rule e="way" k="*" v="track"> <rule e="way" k="area" v="yes|true">
|
||||||
<area fill="#c9d8a2" stroke="#b7c690" stroke-width="0.025" /> </rule> <rule
|
<area fill="#c9d8a2" stroke="#b7c690" stroke-width="0.025" /> </rule> <rule
|
||||||
e="way" k="area" v="~|no|false"> <line stroke="#b7c690" stroke-width="0.75"
|
e="way" k="area" v="~|no|false"> <line stroke="#b7c690" stroke-width="0.75"
|
||||||
@@ -332,7 +338,7 @@
|
|||||||
|
|
||||||
<rule e="way" k="outline" v="*">
|
<rule e="way" k="outline" v="*">
|
||||||
<rule e="way" k="*" v="1">
|
<rule e="way" k="*" v="1">
|
||||||
<outline stroke="#bb909090" />
|
<outline stroke="#909090" />
|
||||||
</rule>
|
</rule>
|
||||||
<rule e="way" k="*" v="2">
|
<rule e="way" k="*" v="2">
|
||||||
<outline stroke="#c0c0c0" />
|
<outline stroke="#c0c0c0" />
|
||||||
|
|||||||
Reference in New Issue
Block a user