Skip to content

OpenGL project that generates a Voronoi diagram with moving seeds

License

Notifications You must be signed in to change notification settings

MihaiZegheru/Voronoi-OpenGL

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Voronoi-OpenGL

OpenGL project that generates a Voronoi diagram with moving seeds

Euclidean Distances

Installing

Download the latest release.

Building

Make sure you are in /

mkdir build
cd build
cmake ..

Usage

Compile and run the project.

Controls

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;
}

Distances

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);

Euclidean Distances MinkowskiDistance Manhattan Distances

Seeds

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.

Window Size

You can set the initial window size by changing these fields in main.cpp

#define WINDOW_WIDTH  1000;
#define WINDOW_HEIGHT 1000;

Credits

License

Voronoi-OpenGL is released under MIT License.