So, instead of using the built-in random number generator I Way to specify the seed value, and therefore no way to generate reproducible outputs. Although JavaScript provides a way to generate random numbers using the Math.random() function, there is no Many of the algorithms used for this project require a random number generator. The standard approach for achieving this is to use the Marching Squares algorithm: In order to draw contour lines we need to draw lines between adjacent points that have the same elevation. The landscape generator can add contour lines to the image. Five such sets of points are calculated, and then lines are drawn between them in progressively darker colours to simulate the sea bed dropping away as we travel further off shore: ![]() The waves are rendered by calculating sets of points in the sea that are all equidistantįrom the nearest point on land. Map locations are coloured according to how much water passes through them, the end result is a fairly convincing set of rivers and lakes, like this:įor aesthetic purposes, and to provide greater contrast between land and sea, I added waves around the coastline. Once all possible droplet paths have been covered we check how many times each point on the map was visited by a droplet, the more visits a location receives, the wetter the ground in that place will become. ![]() The process of calculating the path taken by water droplets, described above, can also be used to determine where streams and rivers would form on the landscape.Įach point on the map is considered in turn, and if the elevation of that point is above sea-level then a water droplet is placed there and its path calculated. Notice how the shape of the lake changes as valleys form: This video shows the erosion process taking place with 200,000 simulated water droplets. Paths that are followed by droplets from many different locations become heavily eroded, forming channels and valleys. In this way material is slowly redistributed by the water in a manner similar to natural hydraulic erosion. Once a droplet cannot absorb any more material, or when its momentum carries it up a slope, it deposits some of its material onto the ground. As the droplets move they pick up material from the ground, a process which continues until they reach their carrying capacity. Until it reaches the sea, or it comes to rest in a pit or indentation in the ground. The algorithm calculates the path that would be taken by a water droplet if it were placed at a certain location on the landscape, and allowed to flow freely downhill under gravity. I have simulated water erosion using an algorithm outlined in this paper by Hans Theobald Beyer. Smoothing out rough ground and creating distinctive features such as river valleys and coastal inlets. These processes affect the shape of the land, Natural landscapes are subject to erosion due to wind and rainfall. Surfaces shown above gives the following result: The higher-resolution surfaces add realistic texture at various scales, without really affecting the overall geography. ![]() Some weighting is used when combining the surfaces - the lower resolution surfaces have the greatest influence on the final result, defining ![]() None of these surfaces look particularly natural on their own, however when they are combined together the result gives a reasonable approximation of real terrain. For each landscape image I generate 6 sets of Perlin Noise at different scales: The basic shape of the terrain is generated using Perlin Noise, an algorithm commonly used inĬomputer graphics to create natural looking surface shapes and textures. I've been working on a browser-based landscape generator written in JavaScript, you can try it out here. Codebox Software Landscape Generation with JavaScript open source javascript
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |