Heightmap Landscape Generation
Martin Munck, Kristina Kevel, Rauno Jaaska
About this project
The aim of this project is to create an application that generates a heightmap. The heightmap is later imported into Unreal Engine 4 where landscape is created. We are applying a custom material which applies textures depending on the world position. Later riverbeds and props will be added.
Video demo of the result
Link to repository
The progress so far (15.11.2020)
- A GUI based on TKinter improves usability for less advanced users.
- The first algorithm, "Thousand needles", produces alien landscapes.
- Acquaintance with Unreal Engine 4
- Material for the landscape created. Once applied, the material shows grass, gravel and basalt on the landscape, depending on the world position.
Result of importing the heightmap generated by our application into Unreal Engine and applying the material
The result (03.01.2021)
- A easy to use GUI makes using the heightmap generation algorithms simple.
- An algorithm that uses two layers of Perlin noise to create a realistic landscape.
- An algorithm that creates very tall pillars, suitable for a fictonial/sci-fi landscape.
- An algorithm that a very smooth terrain, suitable for grasslands or level forests.
- The GUI also allows to preview the generated image with functionalities such as zooming, panning and resetting.
- Further acquaintance with Unreal Engine 4 (materials, grass technology, first person character movement, brand new water technology).
- Project migrated from 4.25.4 to 4.26.0 to try the new water technology.
- Material for the landscape improved.
- Trees and rocks are now procedurally generated using UE4 grass technology.
- Water spawner created. Once added to the scene, will spawn water once Play mode is entered.
- Levels optimized (more LODs added to trees, disabled dynamic shadows of trees).
Who did what
- Rauno Jaaska made the GUI and the Diamond-Square heightmap algorithm.
- Martin Munck made the Thousand Needles and Perlin heightmap algorithms.
- Kristina Kevel made the Unreal Engine 4 material and worked on getting water unto the landscape.
In October and November we started playing around with the necessary technologies, seeing how landscapes work in Unreal Engine 4. We came to the conclusion, that the heightmap that can be imported into UE4 is very simple, and could be easily made with solutions we already know, namely Python. We outlined the plan for our project, which consisted of 3 parts: a GUI that chooses and configures algorithms written in Python, that creates a PNG file to be imported into UE4 and finally a material that will be applied to the Landscape.
In November and December we developed the necessary solutions. In these months we also met with our coach Ats Kurvet, who introduced and showed a lot of good solutions in Unreal Engine 4, showing what the software is capable of, this gave us even more ambition and showed us, that a lot can be done, we just need to find the way to do it.
In the beginning, the algorithms we made on our own for creating the heightmap were very basic and didn't create anything lifelike, and we decided to use the Perlin noise library, as it has pretty good results in general. In late December, all of the final components were at a stage, where they only needed a bit of polishing and in the end, we had achieved our goals, namely the GUI, heightmap generation algorithms with different applications and the necessary UE4 material to make the heightmap look like an actual landscape. We were not able to automate the process of creating bodies of water, but manually creating them is quite easy.
Unreal Engine part
Unreal Engine already has a great in-built tool for generating landscapes from heighmaps, so we decided to concentrate on creating materials for populating the landscape with grass, rocks and water.
In order to cover the ground with grass and stone materials, an auto material was created. The material takes into account elevations of the surface and puts a stone texture on the steep slopes, leaving other surfaces covered with grass. Stone and grass materials were taken from the Unreal Engine's Starter Pack.
Next step was adding trees and rocks to the grass surfaces. In order to do so, the above mentioned auto material was changed to spawn trees and rocks using the Unreal Engine's Grass technology. This lead to a huge performance hit as at first all of the trees had only 1 LOD setting for all distances and were using dynamic shadows. Since our landscapes are of substantial sizes, the dynamic shadows of the trees had to be turned off.
Lastly, the water bodies had to be added. Our initial plan was to try and make the generation of water bodies also automatic (possibly by adding it to the same magic auto material) but we did not find a way to do so. Instead, we were advised by our coach to have a look at the brand new water technology introduced in version 4.26.0 of Unreal Engine. While being a fascinating technology, it did not seem like the right fit for our project so we proceeded with another advice from our coach - creating a flat water surface.
For that a water material was created and applied to a flat surface. Next, to make it easier for the user, a water spawner was created. Once added into a level to coordinates (0, 0, 0), the spawner will add water to level on pressing Play button.
One of the hurdles was limiting generation of trees so they do not appear under water. The issue was fixed by allowing the trees to spawn only above the water level specified in the auto material instance as a parameter. In the process the auto material was also changed to apply a dirt material to the underwater area.
Another thing that took a considerable amount of time was figuring out how to create a first person character that could fly in the levels. The Unreal Engine FirstPersonCharacter was taken as the base and changed according to our needs.
Through the whole process a lot of Unreal Engine basics were learned and while it took some time to figure them out due to a steep learning curve, the process was enjoyable and we came out at the end with plenty of new knowledge about Unreal Engine's capabilities (even though we did not take advantage of all of them).
What was challenging
- None of the team members were familiar with UE4, so we had to learn on the go :)
- UE4 blueprint system has a steep learning curve, was very overwhelming at times.
- Making something without further research that could make a viable terrain was difficult, good landscape needed research and external libraries, this also reduced the required computational resources.
- As the things we were doing were mostly new, it was hard to understand what the other teammates had done and were doing.
What was cool
- Seeing how great the finished landscape looked.
- Learning how these processes work.
- Learning new powerful technology