I want to convert a Voronoi Graph made with this awesome library by jceipek on GitHub into something I can work on.

So far so good, this user provides with a demo to start with and shows how to generate the VG.


How do I convert the VG (made by edges and that dot in the middle) into something that I can work with?

Such as, after you generate some noise and apply to it (height), you colour the polygons based on it.


Something comes to my mind about instantiating meshes and tiles based on the edges and the position of the dot as a start, but it won't work if I can't "detect" the polygon.

Expected result:

Image from this blog about Voronoi Mapping link

enter image description here

What I have:

enter image description here

It is drawn with Gizmos (for visual debugging in Unity)

I want to know how to color my polygons as in the expected image above. So I thought about doing a mesh or individual tile (and color it based on height afterwards but that is sauce for another question if needed)

Edit of my progress:

To further explain this question I provide the next image.

It shows a cube inside one of the many edges inside the VG

The image shows that I could use that position data somehow and turn that random polygon shape into a "tile" that will have a colour (mesh?) and possible data in it (script).

I hope this helps otherwise let me know in the comments.

  • 2
    \$\begingroup\$ To be clear, you're asking about "rendering" a Voronoi graph, correct? Not about graph colouring (the algorithmic problem of choosing "colour" labels so that no two adjacent nodes use the same label)? If so, I recommend editing your title to avoid confusion, and including an example image or mock-up of what your input and desired output look like. \$\endgroup\$
    – DMGregory
    Aug 20, 2018 at 10:31
  • \$\begingroup\$ Edit done with my expected results about it. \$\endgroup\$
    – WhiteGlove
    Aug 20, 2018 at 10:58
  • 2
    \$\begingroup\$ Can you be more clear about "into something i can work on" - what do you exactly need and expect? A model, a bitmap, a vector image, a something else? \$\endgroup\$
    – Kromster
    Aug 20, 2018 at 10:59
  • 2
    \$\begingroup\$ Hm... it's not clear to me how this image relates to "after you generate some noise and apply to it (height) you colour the polygon based on it." Can you explain step-by-step? And define what "it" is in each case (the graph? The noise value? The resulting height?) \$\endgroup\$
    – DMGregory
    Aug 20, 2018 at 11:00
  • 1
    \$\begingroup\$ Might the last comment in this thread (by Yandalf) be what you are looking for? forum.unity.com/threads/… \$\endgroup\$
    – loonquawl
    Aug 20, 2018 at 11:17

2 Answers 2


While you could detect the polygon, it would be simpler to directly use the data that was used to generate them.

If you check Voronoi.cs there is a method called Regions () which returns a List<List<Vector2>>. Each sub list is list of points for a given region. From there you can turn the points into a mesh.

  • \$\begingroup\$ If I understand correctly, I think they're looking for help with that last step: turning the region data provided by the Voronoi library into a mesh. \$\endgroup\$
    – DMGregory
    Aug 22, 2018 at 23:00
  • \$\begingroup\$ In addition to where it is suggested to use Regions(), OP will also want to construct a sub-mesh for each tile, set its vertex colours according to the colour you want, and then use a vertex colouring shader / material on it. Alternatively pick a material on which the colour can be set as a whole. \$\endgroup\$
    – Engineer
    Nov 23, 2018 at 5:39

So you can do this by placing a cone mesh (tip facing the camera) at each point.

Assuming each cone has a unique color (and sufficient radius), the depth buffer should automatically "segment" your colors (assuming an ortho camera).


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .