Swarm World Post 1
Swarm World is a third person class based PvE looter shooter with procedurally generated terrain and a crashed spaceship players must repair to escape the planet.
Date - August 23 to current | Role - Designer and Developer| Team Size - 1 | Engine - Unreal Engine 5.2
I have decided to begin with an aspect of the project I have never attempted in the past: procedural generation. First off we need some variable and method declarations in the header file:
Now I set up some default values and call the prerequisite functions in the constructor:
Next the implementation of the CreateVertices() and CreateTriangles() functions:
These loops create vertices in a grid that is XSize wide, YSize high and has a distance of Scale between each point. The height of each point uses a Perlin noise function to create smooth transitions between points, as random numbers between -1 and 1 create harsh, jagged peaks and troughs:
This function creates an array of triangles, "organising" the vertices into a sort of library for the CreateMeshSection function to reference. How the triangles are added is diagrammed below:
The red triangle is triangle 1 and the green is triangle 2. The x and y axes are flipped for ease of explanation.
Once I used a more realistic texture for the mesh I noticed that the tiling was quite obvious, especially over longer distances, so although advanced material creation isn't something that particularly interests me I found a tutorial online for how to make this less noticeable and how to blend the tiles together:
Before
After
The process involves micro and macro variations of textures within the material:
A macro variation layer with controllable parameters
Micro variation is added for far from the camera and near to the camera
A smooth gradient is created by finding out how far away each pixel is from the camera, dividing that by a controllable parameter and clamping it between 0 and 1. This can then be plugged into a lerp to move smoothly between the two near and far microvariations. Then we can multiply the two outputs to produce the base colour of the material.
The final hilly, smooth landscape with randomly generated geometry