planet-wars/frontend/www/static/shaders/frag/vor.glsl

31 lines
584 B
Text
Raw Permalink Normal View History

2019-09-24 14:29:13 +02:00
#ifdef GL_ES
precision mediump float;
#endif
uniform vec3 u_planets[$PLANETS];
uniform vec3 u_planet_colours[$PLANETS * 2];
uniform float u_step_interval;
uniform float u_time;
2020-03-29 07:15:50 +02:00
uniform bool u_vor;
2019-09-24 14:29:13 +02:00
varying vec2 v_pos;
void main() {
vec3 color = vec3(0.2);
2020-03-29 07:15:50 +02:00
if (u_vor) {
float dis = 1000000.0;
for(int i = 0; i < $PLANETS; i++) {
float d = distance(v_pos, u_planets[i].xy);
if (d < dis) {
dis = d;
color = u_planet_colours[2 * i];
}
2019-09-24 14:29:13 +02:00
}
}
gl_FragColor = vec4(color, 0.2);
}