Wave Engine
Project information
- Engine: OpenGL custom-built engine
- Team: Mario Galan Sobrino
- Features: 3D Wave Function Collapse algorithm, multi-threading
- Project date: September 2023 - December 2023
Wave Engine is an OpenGL custom-built engine developed for my Bachelor dissertation built upon Puzzles Engine, an engine built during the final year of my Computing HND
The topic I choose for my dissertation was procedural terrain generation. To implement this feature I chose to go with an algorithm called Wave Function Collapse or WFC for short. I decided to use this algorithm because it has been quite trendy lately and also because there are not many 3D implementations of the algorithm out there. The algorithm works by establishing certain rules and limits and then giving the algorithm inputs that will be converted into cohesive outputs. The algorithm is fully customizable allowing for grid size customization and the addition or removal of both rules and elements from the algorithm. The biggest drawback of WFC is that it can be very time consuming given the rules and grid size. To leverage this issue I decided to implement multiple optimization techniques that massively improved the performance of the algorithm. The first approach I took was to change the data containers I used for the algorithm from high level standard container to more faster and low level ones. Secondly I changed how the algorithm was iterated, from all in one go to chunks of data that can be iterated separately. Finally I implemented multi-threading in combination with the previously mentioned optimizations. I added multi-threading to multiple parts of the code being the following: in the initialization of the algorithm to iterate every element faster, to the main algorithm loop in combination with the previously mentioned chunks I was able to iterate multiple parts of the algorithm separately increasing the speed by a lot and, finally, I added multi-threading to the drawing stage in order to make the rendering faster.
Working on this project was very exciting for me since I always wanted to worked with multi-threading and I also wanted to implement a 3D version of this algorithm given how little documentation was on the internet. It was quite challenging but the result was very rewarding.