This repository has been archived on 2022-05-19. You can view files and clone it, but cannot push or open issues or pull requests.
DemoGL4D/shaders/voronoi.fs

32 lines
605 B
Forth
Raw Normal View History

2022-05-16 13:21:24 +02:00
/* TP6 */
#version 330
uniform int nb_sites;
uniform vec2 coords[500];
uniform vec4 colors[500];
uniform sampler2D tex;
in vec2 vsoTexCoord;
out vec4 fragColor;
2022-05-17 17:10:41 +02:00
void main(void) {
2022-05-16 13:21:24 +02:00
float dmin = distance(vsoTexCoord, coords[0]);
int imin = 0;
2022-05-17 22:02:06 +02:00
for(int i = 0; i < nb_sites; i++) {
2022-05-16 13:21:24 +02:00
float d = distance(vsoTexCoord, coords[i]);
if(d < dmin) {
imin = i;
dmin = d;
}
}
// Affichage d'un point au milieu d'une aire terminée
if(dmin < 0.003) {
fragColor = vec4(0, 0, 0, 1);
} else {
fragColor = colors[imin];
}
}