Noise City Gen is an innovative procedural city generation system built in Unity, designed to create diverse urban environments dynamically. By blending Perlin Noise and Random Walk algorithms, this system generates realistic city layouts with varied structures, roads, and landscapes.
The main goal of this project is developing a procedural city generation system in Unity where production output with different parameters such as noise values, initial sizes or some constraints on world props. Procedural generation system is dynamic enough to provide different results with different parameters while using a smooth scaling.
Application creates a very good mix of both Random Walk and Perlin Noise algorithms, enhancing its capabilities for generating procedural cities. In this application, generation logic is later visualised with spawning objects in the determined positions and rotations.
Perlin noise is a very efficient and powerful algorithm firstly developed by Ken Perlin. The algorithm itself uses a static hash table for generating seed random values, instead of generating random values every time.
Hash table stores pre-computed gradient vectors for calculation of (x, y) output values. This hash table, as stated before, is a static table which reduces the memory usage and efficiency of the algorithm. Each time a value for any (x, y) point is generated, a hash table is used for getting four different gradient vectors from nearest seed randoms available on the grid. It is important to note that the gradient vectors are assigned with a length of 1 and a random direction.
After four random vectors are generated, four more vectors are created from nearest seed randoms to (x, y) point. A dot product between random vectors and newly generated vectors is calculated the output, which is a scalar product, saved as values for nearest seed random points. This approach creates a smooth transition while (x, y) is changed between seed random points which eventually creates a smoothness that triggers natural looking noise. It is also very important to note that, if any point is closer to (x, y) point, the contribution made by that point is smaller.
dot product = gradient vector * vector to corner
Last step of perlin noise generation is getting the weighted sum of the four different scalar values located on bottom left, bottom right, upper left and upper right. Calculation of weighted sum is being done by a weighted averaging function called ease curve.
Random walk algorithm is generally used for road and dungeon generation in the computer games industry. This algorithm creates natural road networks connected to each other. In this project, the Random Walk algorithm is connected to the Perlin Noise where some parameters of the Random Walk Algorithm are decided by Perlin Noise.
Random walk algorithm starts generating a road network from the centre of the given area. Starting from the centre, roads are placed in different directions and their edges are saved to a list. This process is done in steps given in the parameters. As the steps increase, based on the density value, the roads start diluting on the game world. Each time an edge is being processed, Perlin Noise is used for determining the count of new branches. As the final step, each branch’s direction is calculated via Unity’s random integer generator.
Perlin noise is a very efficient solution to do smooth and natural randomization. Increasing density in the center is creating a very natural look for the city. Random walk algorithm is a great way to procedurally generate road maps and similar structures.
Custom Perlin Noise implemented in this project requires a noise scale for generating values, and the noise parameter given highly affects the road network’s structure. Random walk algorithm on the other hand, uses a set of parameters to generate a road network in a procedural way.