OpenGL project that generates a Voronoi diagram with moving seeds
Download the latest release.
Make sure you are in /
mkdir build
cd build
cmake ..
Compile and run the project.
You can pause and unpause the animation by pressing Q
The key is defined in inputmanager.cpp
if (glfwGetKey(window, GLFW_KEY_Q) == GLFW_PRESS) {
m_Q = true;
}
else {
m_Q = false;
}
You can change the way the Voronoi diagram is rendered by manipulating the distances.
float EuclideanDistance(vec2 a, vec2 b);
float ManhattanDistance(vec2 a, vec2 b);
float ChebyshevDistance(vec2 a, vec2 b);
float MinkowskiDistance(vec2 a, vec2 b, float p);
Change the function on this line in defaultfragmentshader.glsl
gl_FragDepth = MinkowskiDistance(seedPos, gl_FragCoord.xy, MINKOWSKI_VALUE) / length(screenRes);
You can also change the number of seeds(voronoi generators) by changing this field in main.cpp
#define SEEDS_COUNT 10
Note The seeds are generated randomly and there is no current implementation of a special noise function. This is the same for the colors.
You can set the initial window size by changing these fields in main.cpp
#define WINDOW_WIDTH 1000;
#define WINDOW_HEIGHT 1000;
Voronoi-OpenGL is released under MIT License.