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

33 lines
728 B
Text
Raw Normal View History

2019-09-17 20:19:04 +02:00
#ifdef GL_ES
precision mediump float;
#endif
uniform int u_circle_count;
uniform float u_time;
uniform vec2 u_mouse;
uniform vec4 u_viewbox; // [x, y, width, height]
uniform vec2 u_resolution;
uniform vec3 u_circles[$MAX_CIRCLES];
2019-09-18 12:29:56 +02:00
uniform vec3 u_colors[$MAX_CIRCLES];
2019-09-17 20:19:04 +02:00
varying vec2 v_pos;
void main() {
vec2 uv = v_pos;
float alpha = 0.0;
2019-09-18 12:29:56 +02:00
vec3 color;
2019-09-17 20:19:04 +02:00
for (int i = 0; i < $MAX_CIRCLES; i++ ){
if (i >= u_circle_count) { break; }
float d = distance(uv.xy, u_circles[i].xy);
2019-09-18 12:29:56 +02:00
float a = 1.0 - d/u_circles[i].z;
if (a > alpha) {
alpha = a;
color = u_colors[i];
}
2019-09-17 20:19:04 +02:00
}
2019-09-18 12:29:56 +02:00
gl_FragColor = vec4(color, alpha);
// gl_FragColor.w *= alpha;
2019-09-17 20:19:04 +02:00
}