Location renderer improvements #321
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
- Marker clustering [#312](https://github.com/mapsforge/vtm/issues/312)
|
||||
- Osmagray theme [#300](https://github.com/mapsforge/vtm/issues/300)
|
||||
- Symbol rotation [#294](https://github.com/mapsforge/vtm/issues/294)
|
||||
- Location custom shaders [#317](https://github.com/mapsforge/vtm/issues/317)
|
||||
- Location custom shaders & improvements [#317](https://github.com/mapsforge/vtm/issues/317) [#321](https://github.com/mapsforge/vtm/issues/321)
|
||||
- OkHttp external cache [#135](https://github.com/mapsforge/vtm/issues/135)
|
||||
- Texture atlas improvements [#301](https://github.com/mapsforge/vtm/pull/301) [#304](https://github.com/mapsforge/vtm/pull/304)
|
||||
- vtm-ios-example module [#326](https://github.com/mapsforge/vtm/issues/326)
|
||||
|
||||
@@ -20,9 +20,10 @@ varying vec2 v_tex;
|
||||
uniform float u_scale;
|
||||
uniform float u_phase;
|
||||
uniform vec2 u_dir;
|
||||
uniform int u_mode;
|
||||
void main() {
|
||||
float len = 1.0 - length(v_tex);
|
||||
if (u_dir.x == 0.0 && u_dir.y == 0.0) {
|
||||
if (u_mode == 1) {
|
||||
gl_FragColor = vec4(0.2, 0.2, 0.8, 1.0) * len;
|
||||
} else {
|
||||
// outer ring
|
||||
|
||||
@@ -20,9 +20,10 @@ varying vec2 v_tex;
|
||||
uniform float u_scale;
|
||||
uniform float u_phase;
|
||||
uniform vec2 u_dir;
|
||||
uniform int u_mode;
|
||||
void main() {
|
||||
float len = 1.0 - length(v_tex);
|
||||
if (u_dir.x == 0.0 && u_dir.y == 0.0) {
|
||||
if (u_mode == 1) {
|
||||
gl_FragColor = vec4(0.2, 0.2, 0.8, 1.0) * len;
|
||||
} else {
|
||||
// outer ring
|
||||
|
||||
@@ -20,9 +20,10 @@ varying vec2 v_tex;
|
||||
uniform float u_scale;
|
||||
uniform float u_phase;
|
||||
uniform vec2 u_dir;
|
||||
uniform int u_mode;
|
||||
void main() {
|
||||
float len = 1.0 - length(v_tex);
|
||||
if (u_dir.x == 0.0 && u_dir.y == 0.0) {
|
||||
if (u_mode == 1) {
|
||||
gl_FragColor = vec4(0.2, 0.2, 0.8, 1.0) * len;
|
||||
} else {
|
||||
// outer ring
|
||||
@@ -34,11 +35,11 @@ void main() {
|
||||
vec2 dir = normalize(v_tex);
|
||||
float d = dot(dir, u_dir);
|
||||
// 0.5 width of viewshed
|
||||
d = clamp(smoothstep(0.7, 0.7 + 2.0/u_scale, d) * len, 0.0, 1.0);
|
||||
d = clamp(smoothstep(0.7, 0.7 + 2.0 / u_scale, d) * len, 0.0, 1.0);
|
||||
// - subtract inner from outer to create the outline
|
||||
// - multiply by viewshed
|
||||
// - add center point
|
||||
a = max(d, (a - (b + c)) + c);
|
||||
a = max(d, (a - (b + c)) + c) + (u_mode == 2 ? c : 0);
|
||||
gl_FragColor = vec4(0.2, 0.2, 0.8, 1.0) * a;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,6 +47,7 @@ public class LocationRenderer extends LayerRenderer {
|
||||
private int hScale;
|
||||
private int hPhase;
|
||||
private int hDirection;
|
||||
private int uMode;
|
||||
|
||||
private final Point mIndicatorPosition = new Point();
|
||||
|
||||
@@ -226,14 +227,18 @@ public class LocationRenderer extends LayerRenderer {
|
||||
gl.uniform1f(hPhase, 1);
|
||||
}
|
||||
|
||||
if (viewShed && mLocationIsVisible && mCallback != null && mCallback.hasRotation()) {
|
||||
float rotation = mCallback.getRotation();
|
||||
rotation -= 90;
|
||||
gl.uniform2f(hDirection,
|
||||
(float) Math.cos(Math.toRadians(rotation)),
|
||||
(float) Math.sin(Math.toRadians(rotation)));
|
||||
if (viewShed && mLocationIsVisible) {
|
||||
if (mCallback != null && mCallback.hasRotation()) {
|
||||
float rotation = mCallback.getRotation();
|
||||
rotation -= 90;
|
||||
gl.uniform2f(hDirection,
|
||||
(float) Math.cos(Math.toRadians(rotation)),
|
||||
(float) Math.sin(Math.toRadians(rotation)));
|
||||
gl.uniform1i(uMode, 3); // With bearing
|
||||
} else
|
||||
gl.uniform1i(uMode, 2); // Without bearing
|
||||
} else
|
||||
gl.uniform2f(hDirection, 0, 0);
|
||||
gl.uniform1i(uMode, 1); // Outside screen
|
||||
|
||||
gl.drawArrays(GL.TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
@@ -249,6 +254,7 @@ public class LocationRenderer extends LayerRenderer {
|
||||
hPhase = gl.getUniformLocation(program, "u_phase");
|
||||
hScale = gl.getUniformLocation(program, "u_scale");
|
||||
hDirection = gl.getUniformLocation(program, "u_dir");
|
||||
uMode = gl.getUniformLocation(program, "u_mode");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user