Location renderer: allow external shaders, move existing to glsl files, closes #317
This commit is contained in:
44
vtm/resources/assets/shaders/location_1.glsl
Normal file
44
vtm/resources/assets/shaders/location_1.glsl
Normal file
@@ -0,0 +1,44 @@
|
||||
#ifdef GLES
|
||||
precision mediump float;
|
||||
#endif
|
||||
uniform mat4 u_mvp;
|
||||
uniform float u_phase;
|
||||
uniform float u_scale;
|
||||
attribute vec2 a_pos;
|
||||
varying vec2 v_tex;
|
||||
void main() {
|
||||
gl_Position = u_mvp * vec4(a_pos * u_scale * u_phase, 0.0, 1.0);
|
||||
v_tex = a_pos;
|
||||
}
|
||||
|
||||
$$
|
||||
|
||||
#ifdef GLES
|
||||
precision mediump float;
|
||||
#endif
|
||||
varying vec2 v_tex;
|
||||
uniform float u_scale;
|
||||
uniform float u_phase;
|
||||
uniform vec2 u_dir;
|
||||
void main() {
|
||||
float len = 1.0 - length(v_tex);
|
||||
if (u_dir.x == 0.0 && u_dir.y == 0.0){
|
||||
gl_FragColor = vec4(0.2, 0.2, 0.8, 1.0) * len;
|
||||
} else {
|
||||
// outer ring
|
||||
float a = smoothstep(0.0, 2.0 / u_scale, len);
|
||||
// inner ring
|
||||
float b = 0.5 * smoothstep(4.0 / u_scale, 5.0 / u_scale, len);
|
||||
// center point
|
||||
float c = 0.5 * (1.0 - smoothstep(14.0 / u_scale, 16.0 / u_scale, 1.0 - len));
|
||||
vec2 dir = normalize(v_tex);
|
||||
float d = 1.0 - dot(dir, u_dir);
|
||||
// 0.5 width of viewshed
|
||||
d = clamp(step(0.5, d), 0.4, 0.7);
|
||||
// - subtract inner from outer to create the outline
|
||||
// - multiply by viewshed
|
||||
// - add center point
|
||||
a = d * (a - (b + c)) + c;
|
||||
gl_FragColor = vec4(0.2, 0.2, 0.8, 1.0) * a;
|
||||
}
|
||||
}
|
||||
44
vtm/resources/assets/shaders/location_1_reverse.glsl
Normal file
44
vtm/resources/assets/shaders/location_1_reverse.glsl
Normal file
@@ -0,0 +1,44 @@
|
||||
#ifdef GLES
|
||||
precision mediump float;
|
||||
#endif
|
||||
uniform mat4 u_mvp;
|
||||
uniform float u_phase;
|
||||
uniform float u_scale;
|
||||
attribute vec2 a_pos;
|
||||
varying vec2 v_tex;
|
||||
void main() {
|
||||
gl_Position = u_mvp * vec4(a_pos * u_scale * u_phase, 0.0, 1.0);
|
||||
v_tex = a_pos;
|
||||
}
|
||||
|
||||
$$
|
||||
|
||||
#ifdef GLES
|
||||
precision mediump float;
|
||||
#endif
|
||||
varying vec2 v_tex;
|
||||
uniform float u_scale;
|
||||
uniform float u_phase;
|
||||
uniform vec2 u_dir;
|
||||
void main() {
|
||||
float len = 1.0 - length(v_tex);
|
||||
if (u_dir.x == 0.0 && u_dir.y == 0.0){
|
||||
gl_FragColor = vec4(0.2, 0.2, 0.8, 1.0) * len;
|
||||
} else {
|
||||
// outer ring
|
||||
float a = smoothstep(0.0, 2.0 / u_scale, len);
|
||||
// inner ring
|
||||
float b = 0.5 * smoothstep(4.0 / u_scale, 5.0 / u_scale, len);
|
||||
// center point
|
||||
float c = 0.5 * (1.0 - smoothstep(14.0 / u_scale, 16.0 / u_scale, 1.0 - len));
|
||||
vec2 dir = normalize(v_tex);
|
||||
float d = dot(dir, u_dir);
|
||||
// 0.5 width of viewshed
|
||||
d = clamp(step(0.5, d), 0.4, 0.7);
|
||||
// - subtract inner from outer to create the outline
|
||||
// - multiply by viewshed
|
||||
// - add center point
|
||||
a = d * (a - (b + c)) + c;
|
||||
gl_FragColor = vec4(0.2, 0.2, 0.8, 1.0) * a;
|
||||
}
|
||||
}
|
||||
40
vtm/resources/assets/shaders/location_2.glsl
Normal file
40
vtm/resources/assets/shaders/location_2.glsl
Normal file
@@ -0,0 +1,40 @@
|
||||
#ifdef GLES
|
||||
precision mediump float;
|
||||
#endif
|
||||
uniform mat4 u_mvp;
|
||||
uniform float u_phase;
|
||||
uniform float u_scale;
|
||||
attribute vec2 a_pos;
|
||||
varying vec2 v_tex;
|
||||
void main() {
|
||||
gl_Position = u_mvp * vec4(a_pos * u_scale * u_phase, 0.0, 1.0);
|
||||
v_tex = a_pos;
|
||||
}
|
||||
|
||||
$$
|
||||
|
||||
#ifdef GLES
|
||||
precision mediump float;
|
||||
#endif
|
||||
varying vec2 v_tex;
|
||||
uniform float u_scale;
|
||||
uniform float u_phase;
|
||||
uniform vec2 u_dir;
|
||||
void main() {
|
||||
float len = 1.0 - length(v_tex);
|
||||
// outer ring
|
||||
float a = smoothstep(0.0, 2.0 / u_scale, len);
|
||||
// inner ring
|
||||
float b = 0.8 * smoothstep(3.0 / u_scale, 4.0 / u_scale, len);
|
||||
// center point
|
||||
float c = 0.5 * (1.0 - smoothstep(14.0 / u_scale, 16.0 / u_scale, 1.0 - len));
|
||||
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);
|
||||
// - subtract inner from outer to create the outline
|
||||
// - 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;
|
||||
}
|
||||
Reference in New Issue
Block a user