Location shaders: check no rotation, fixes #321

This commit is contained in:
Emux
2017-03-05 12:09:53 +02:00
parent f061e06d94
commit 320ce5b44d
5 changed files with 32 additions and 28 deletions

View File

@@ -5,7 +5,7 @@
- Symbol rotation [#294](https://github.com/mapsforge/vtm/issues/294) - Symbol rotation [#294](https://github.com/mapsforge/vtm/issues/294)
- Marker clustering [#312](https://github.com/mapsforge/vtm/issues/312) - Marker clustering [#312](https://github.com/mapsforge/vtm/issues/312)
- Osmagray theme [#300](https://github.com/mapsforge/vtm/issues/300) - Osmagray theme [#300](https://github.com/mapsforge/vtm/issues/300)
- Location renderer custom shaders [#317](https://github.com/mapsforge/vtm/issues/317) - Location custom shaders [#317](https://github.com/mapsforge/vtm/issues/317)
- OkHttp external cache [#135](https://github.com/mapsforge/vtm/issues/135) - 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) - Texture atlas improvements [#301](https://github.com/mapsforge/vtm/pull/301) [#304](https://github.com/mapsforge/vtm/pull/304)
- Many other minor improvements and bug fixes - Many other minor improvements and bug fixes

View File

@@ -22,7 +22,7 @@ uniform float u_phase;
uniform vec2 u_dir; uniform vec2 u_dir;
void main() { void main() {
float len = 1.0 - length(v_tex); float len = 1.0 - length(v_tex);
if (u_dir.x == 0.0 && u_dir.y == 0.0){ if (u_dir.x == 0.0 && u_dir.y == 0.0) {
gl_FragColor = vec4(0.2, 0.2, 0.8, 1.0) * len; gl_FragColor = vec4(0.2, 0.2, 0.8, 1.0) * len;
} else { } else {
// outer ring // outer ring

View File

@@ -22,7 +22,7 @@ uniform float u_phase;
uniform vec2 u_dir; uniform vec2 u_dir;
void main() { void main() {
float len = 1.0 - length(v_tex); float len = 1.0 - length(v_tex);
if (u_dir.x == 0.0 && u_dir.y == 0.0){ if (u_dir.x == 0.0 && u_dir.y == 0.0) {
gl_FragColor = vec4(0.2, 0.2, 0.8, 1.0) * len; gl_FragColor = vec4(0.2, 0.2, 0.8, 1.0) * len;
} else { } else {
// outer ring // outer ring

View File

@@ -22,19 +22,23 @@ uniform float u_phase;
uniform vec2 u_dir; uniform vec2 u_dir;
void main() { void main() {
float len = 1.0 - length(v_tex); float len = 1.0 - length(v_tex);
// outer ring if (u_dir.x == 0.0 && u_dir.y == 0.0) {
float a = smoothstep(0.0, 2.0 / u_scale, len); gl_FragColor = vec4(0.2, 0.2, 0.8, 1.0) * len;
// inner ring } else {
float b = 0.8 * smoothstep(3.0 / u_scale, 4.0 / u_scale, len); // outer ring
// center point float a = smoothstep(0.0, 2.0 / u_scale, len);
float c = 0.5 * (1.0 - smoothstep(14.0 / u_scale, 16.0 / u_scale, 1.0 - len)); // inner ring
vec2 dir = normalize(v_tex); float b = 0.8 * smoothstep(3.0 / u_scale, 4.0 / u_scale, len);
float d = dot(dir, u_dir); // center point
// 0.5 width of viewshed float c = 0.5 * (1.0 - smoothstep(14.0 / u_scale, 16.0 / u_scale, 1.0 - len));
d = clamp(smoothstep(0.7, 0.7 + 2.0/u_scale, d) * len, 0.0, 1.0); vec2 dir = normalize(v_tex);
// - subtract inner from outer to create the outline float d = dot(dir, u_dir);
// - multiply by viewshed // 0.5 width of viewshed
// - add center point d = clamp(smoothstep(0.7, 0.7 + 2.0/u_scale, d) * len, 0.0, 1.0);
a = max(d, (a - (b + c)) + c); // - subtract inner from outer to create the outline
gl_FragColor = vec4(0.2, 0.2, 0.8, 1.0) * a; // - multiply by viewshed
// - add center point
a = max(d, (a - (b + c)) + c);
gl_FragColor = vec4(0.2, 0.2, 0.8, 1.0) * a;
}
} }

View File

@@ -226,17 +226,17 @@ public class LocationRenderer extends LayerRenderer {
gl.uniform1f(hPhase, 1); gl.uniform1f(hPhase, 1);
} }
if (viewShed && mLocationIsVisible) { if (viewShed && mLocationIsVisible && mCallback != null) {
float rotation = 0; float rotation = mCallback.getRotation();
if (mCallback != null) if (rotation != 0) {
rotation = mCallback.getRotation(); rotation -= 90;
rotation -= 90; gl.uniform2f(hDirection,
gl.uniform2f(hDirection, (float) Math.cos(Math.toRadians(rotation)),
(float) Math.cos(Math.toRadians(rotation)), (float) Math.sin(Math.toRadians(rotation)));
(float) Math.sin(Math.toRadians(rotation))); } else
} else { gl.uniform2f(hDirection, 0, 0);
} else
gl.uniform2f(hDirection, 0, 0); gl.uniform2f(hDirection, 0, 0);
}
gl.drawArrays(GL.TRIANGLE_STRIP, 0, 4); gl.drawArrays(GL.TRIANGLE_STRIP, 0, 4);
} }