UE4 Mech Game Update #9: Terrain, UVs, Lighting and AI

TL;DR: Worked with UE4’s terrain sculpting tools. After creating the geometry for the walled city level, I learned about the necessity of proper UV unwrapping and lighting/exposure. Also experimented a bit with AI characters.

1.) Terrain. I wanted at least 3 layers of visual depth: a good skybox, some background terrain and the series of buildings at the forefront. The terrain also functioned to constrict the player and obstruct the view of anything outside the playable area. Fun fact: UE4 can downscale the poly resolution of terrain based on the LOD setting.

2.) UV Unwrapping. After generating the buildings, streets and wall with Houdini, I imported it into Blender to perform some manual corrections. When building the lighting in UE4, it kept throwing an error about overlapping UVs, which was being caused by thin faces + Blender’s automatic “Smart UV Project”. The biggest ROI was from splitting the buildings, sidewalks, roads and wall into separate meshes. I wasn’t going to give up on the automatic unwrapping, so I instead fixed the geometry by removing the thin faces so that all the faces were somewhat consistently sized. Surprisingly, UE4 didn’t complain anymore.

3.) Lighting. I made the difficult-but-potentially-awesome choice of going for a nighttime lighting setup rather than daytime. There are many ways to go wrong, but if you go right, it can look impressive.

Rather than tweaking the default lighting setup, I deleted the skybox and all the lights to start from scratch, then created a new skybox with a handy tool called Spacescape. TIP: In order for the exported skybox to work, I needed to export for the SOURCE engine, not UNREAL- even though it was to be imported into UE4.

Afterwards, there was a beautiful skybox, but the world was pitch black. I then added a skylight for the underlying ambient lighting so that the darkest values would at least be somewhat visible. Then added a directional light for some slight shadows being cast by the buildings via a nebula in the sky. The end result is something that looks pleasant on the eye, leaving room for the many city lights that will be added later.

Then the last piece of the puzzle was exposure. Auto-exposure is on by default and it’s annoying because you never know for sure how bright the environment is. Ultimately, auto-exposure sucks in the game for the same reason it sucks in real life: it doesn’t know what pixels should be balanced and which can be overexposed or underexposed. So I disabled it, then tweaked the fixed exposure to something bright enough to bring out the shadows a tad bit.

To get the right look, it’s honestly not a single knob that needs to be tweaked, but many of them. The skybox needed to be darkened a bunch. The materials needed to be tweaked because material pixel color * lightmap value = resulting pixel. Dark materials don’t even show up. Then exposure, bloom and atmospheric fog all have a bearing on overall brightness too. BTW: bloom is awesome, but it blurs the edges a bit, and in VR, modern headsets are blurry enough already.

4.) AI. Enough with the eye candy. Now it’s time to get back to the gameplay mechanics. After successfully creating a pedestrian AI character that runs to random navigation points on the level, I’m now working on an enemy AI character that flies and shoots lasers or projectiles at the player. Currently learning more about Behavior Trees, which are pretty straightforward from a programmer perspective.