fix stipple width
This commit is contained in:
parent
54d3fe332b
commit
2843c49ced
@ -24,6 +24,7 @@ import org.oscim.renderer.layer.Layers;
|
|||||||
import org.oscim.renderer.layer.LineLayer;
|
import org.oscim.renderer.layer.LineLayer;
|
||||||
import org.oscim.renderer.layer.LineTexLayer;
|
import org.oscim.renderer.layer.LineTexLayer;
|
||||||
import org.oscim.theme.renderinstruction.Line;
|
import org.oscim.theme.renderinstruction.Line;
|
||||||
|
import org.oscim.utils.FastMath;
|
||||||
import org.oscim.utils.GlUtils;
|
import org.oscim.utils.GlUtils;
|
||||||
|
|
||||||
import android.opengl.GLES20;
|
import android.opengl.GLES20;
|
||||||
@ -178,7 +179,8 @@ public class LineTexRenderer {
|
|||||||
// scale pattern to twice its size, then reset scale to 1.
|
// scale pattern to twice its size, then reset scale to 1.
|
||||||
// (coord scale * pattern size / tex size) / scale
|
// (coord scale * pattern size / tex size) / scale
|
||||||
//GLES20.glUniform1f(hPatternScale, (8 * line.stipple / 64) / Math.max((int) s, 1));
|
//GLES20.glUniform1f(hPatternScale, (8 * line.stipple / 64) / Math.max((int) s, 1));
|
||||||
GLES20.glUniform1f(hPatternScale, (8 * line.stipple) / Math.max((int) s, 1));
|
float ps = FastMath.clamp((int) (s * 1.3f), 1, 4);
|
||||||
|
GLES20.glUniform1f(hPatternScale, (8 * line.stipple) / ps);
|
||||||
|
|
||||||
GLES20.glUniform1f(hPatternWidth, line.stippleWidth);
|
GLES20.glUniform1f(hPatternWidth, line.stippleWidth);
|
||||||
//float f = Math.max((int)(s), 1);
|
//float f = Math.max((int)(s), 1);
|
||||||
@ -301,12 +303,12 @@ public class LineTexRenderer {
|
|||||||
+ " uniform float u_pwidth;"
|
+ " uniform float u_pwidth;"
|
||||||
+ " varying vec2 v_st;"
|
+ " varying vec2 v_st;"
|
||||||
+ " void main() {"
|
+ " void main() {"
|
||||||
// 1.0 minus distance on perpendicular to the line
|
// distance on perpendicular to the line
|
||||||
+ " float dist = 1.0 - abs(v_st.t);"
|
+ " float dist = abs(v_st.t);"
|
||||||
+ " float fuzz = fwidth(v_st.t);"
|
+ " float fuzz = fwidth(v_st.t);"
|
||||||
+ " float fuzz_p = fwidth(v_st.s);"
|
+ " float fuzz_p = fwidth(v_st.s);"
|
||||||
+ " float line_w = smoothstep(0.0, fuzz, dist);"
|
+ " float line_w = smoothstep(0.0, fuzz, 1.0 - dist);"
|
||||||
+ " float stipple_w = smoothstep(0.0, u_pwidth + fuzz, dist);"
|
+ " float stipple_w = smoothstep(0.0, fuzz, u_pwidth - dist);"
|
||||||
+ " float phase = abs(mod(v_st.s, 2.0) - 1.0);"
|
+ " float phase = abs(mod(v_st.s, 2.0) - 1.0);"
|
||||||
+ " float stipple_p = smoothstep(0.5 - fuzz_p, 0.5 + fuzz_p, phase);"
|
+ " float stipple_p = smoothstep(0.5 - fuzz_p, 0.5 + fuzz_p, phase);"
|
||||||
+ " gl_FragColor = line_w * mix(u_bgcolor, u_color, min(stipple_w, stipple_p));"
|
+ " gl_FragColor = line_w * mix(u_bgcolor, u_color, min(stipple_w, stipple_p));"
|
||||||
|
@ -917,7 +917,7 @@
|
|||||||
|
|
||||||
<rule e="way" k="railway" v="rail|turntable" zoom-min="15">
|
<rule e="way" k="railway" v="rail|turntable" zoom-min="15">
|
||||||
<line stroke="#ddaa9988" width="2.0" cap="butt" fixed="true" fade="12"
|
<line stroke="#ddaa9988" width="2.0" cap="butt" fixed="true" fade="12"
|
||||||
stipple="10" stipple-width="0.6" stipple-stroke="#ffffff"/>
|
stipple="10" stipple-width="0.8" stipple-stroke="#ffffff"/>
|
||||||
</rule>
|
</rule>
|
||||||
|
|
||||||
<!-- <rule e="way" k="railway" v="rail" zoom-max="14" zoom-min="13">
|
<!-- <rule e="way" k="railway" v="rail" zoom-max="14" zoom-min="13">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user