Search code examples
c#unity-game-engineterrainprocedural-generationunity3d-terrain

What is the "correct" way of combining Voronoi Diagrams with Perlin Noise for Texture Generation?


I am working on a project revovling around procedural terrain generation. I currenly have 2 seperate parts, one which generates my Voronoi Diagram, while the other deals with the generation of the whole terrain. The terrain is currently generated in chunks, as it is too large to be generated on its own. The polygons, which are generated by my Voronoi Algorithms are close in size to a signle terrain chunk. I want a seperate chunk to be generated for each polygon, as I want the Perlin Noise values to be determined the generated polygons. In the current impementation my Terrain Chunks have a form of a square, hence I can not really stick a polygon in. How would you go about it?

I was initially trying to get my texture into a polygon shape, but it the Textures in unity have width and height, duh, so that did not exactly work out. I also considered seperating each Terrain chunk into a set of polygons with the same properties which would form the square, the this ruins the whole purpose of using Voronoi.

I would be happy to include my code, but I don't think it is partically valuable in this case.

As a note: My Voronoi implementaion returns a list of polygon objects with the respective corner points, edges, centroids, etc.

Thanks in advance :)


Solution

  • Most of the time when I've seen Voronoi algorithms in terrain generation, they're applied to a texture at runtime. Other types of noise can then be added/multiplied/etc to that texture to create a heightmap for your procedural terrain.

    If you have your Voronoi algorithm generating geometry already, one option is to make a shader for your terrain that samples Perlin noise in world space coordinates (this way you wouldn't run into any tiling issues on your polygonal mesh). If the noise was to be used as a heightmap, tesselation can increase your mesh resolution. However, if you haven't used shaders before you might see results faster using the texture approach. And it wouldn't make a lot of sense to do half of the terrain noise in a shader if you're doing the other half in C#.

    Since this topic can get pretty broad, I'd highly recommend Sebastian Lague's videos on terrain generation. https://www.youtube.com/watch?v=wbpMiKiSKm8&list=PLFt_AvWsXl0eBW2EiBtl_sxmDtSgZBxB3