Hey everyone, I’ve wondered for a long time on how Blizzard implemented Warcraft 3’s Terrain Editor. I have some guesses on how it was done, but I’d like your input on if its…
- The right approach to doing this.
- What are things that I got wrong or are missing.
- What are considerations I should take in account, if I wanted to implement this as well.
- Any info on newer techniques or improvements.
Warcraft 3 Terrain Editor Example (Youtube Video)
P.S. - This does predicate on having a 2D Pathfinding system implemented. I’ve been testing UE’s default Pathfinding and while its been okay for some early prototyping. It’s not the same as Warcraft3’s smoother pathfinding that I like.
This is a separate challenge that I will be looking into the future, but these 2 systems will have to work together.
Warcraft3’s Implementation
I assume they used the Wave Function Collapse algorithm for creating the Terrain or at-least one inspired by WFC. I can’t find any explicit material describing it, but it feels very close to it. (Youtube Example of another person’s implementation of WFC in 3D)
Instead of randomly generating procedural worlds, they use it to inform the Terrain Editor on what to fill the world with. Your cursor is constrained by the grid in the world and does stuff based on the tile you select and the surrounding tiles. For example in the video above, if you place a Wall that is one unit higher than the surrounding tiles, then all 8 sides will create geo to form a Wall.
They even have multiple geo variations of the Wall, so their is variety in the Terrain.
Something to consider is the Height elevation that gives advantages/disadvantages for units. For example, you cannot see units at a higher elevation than yourself and they serve as natural path blockers.
One way around this, is to create Ramps that allow you to traverse different Elevations. I would need some way to inform the pathfinding that a Unit is at a certain elevation based on their position and allow a seamless transition between the two.
This will be fed later into a Fog of War (Shader implemented) system.
The Apply Height: shown in the video is purely cosmetic. Even if I raise terrain to be higher than an actual Wall. I would still treat that raised Terrain as being lower than the Wall. It’s one less thing to be worried about and how I would want the Terrain to work.
For simplicity/performance sake, the WFC will only work in 2D. Although its data will be translated for the 3D world, its behind the scenes logic is only aware of a 2D world. I have no plans of implementing multiple floors of Grid based path-finding. Allowing for units to walk over each-other, but at different heights.
I think a brute force implementation would be doing all of this on the CPU. But should eventually be moved over to the GPU to take advantage of the massive parallel processing.
Other performance improvements, would be implementing a BVH. So when I update the terrain, it only updates the bare minimum required. Instead of the entire Terrain.
Lastly, I would need to create a custom Editor in Unreal Engine. It would be an exact replica of the “Terrain Palette” in the video. Where I create a custom Widget, that lets you choose between Applying Textures, Increasing/Lowering Walls, Creating Ramps and doing cosmetic Terrain height changes.
I don’t know how I would go about starting this. But something that comes to mind, is how this would work with the existing UE Vanilla Terrain Editor. Being able to use the already existing features (e.g - Instanced meshes) would be great to use.