Wat Arun: Breakdown

Published: October 29, 2024

Last Edited: October 31, 2024

Background

I’ve actually been hesitant to make a wonder for Civilization VI for a while now. This may come as a surprise given that at a glance, it seems that I’ve made a couple of mods that probably appear more ambitious: mods that significantly change gameplay, or that add leader/characters with brand new voice lines and animations for instance.

But the thing is, I’m something of a perfectionist, and if I want to do something, I’d like to do it well. So, if I wanted to make a wonder, I’d have to make a construction animation building it up brick-by-brick for said wonder, so it wouldn’t stand out from the official wonders (like St. Basil’s below).

St. Basil's Cathedral - Construction Animation - by Firaxis

It’s been a somewhat daunting proposition for a couple of reasons. One is the animation itself. Building up a wonder brick-by-brick like that seems like a lot of work. How many keyframes would you need for what might be hundreds of bricks? Doing that manually sounds nigh impossible to manage!

Thankfully, Houdini exists. So I could use a procedural workflow to semi-automate this rather intimidating task. I do have prior experience rigging and animating in Houdini as well! So I was hoping this would be an opportunity to flex my Houdini chops a bit with something a little more complex!

The second reason for my hesitation was that I already knew the modding workflow for this was somewhat deficient. The tools provided to modders are slightly different from what the developers at Firaxis use, and those tools are unable to import animations for objects and cameras simultaneously, so you couldn’t import both a custom construction animation and the animation that makes the camera orbit the building. My thoughts going into this was to bypass the issue by editing the UI1

Getting Started

The model of Wat Arun with reference diagrams in Blender
The model of Wat Arun with reference diagrams in Blender

Wat Arun - Trim Sheet
Wat Arun - Trim Sheet

Nothing too special to start off. The model was made in Blender and textured in Substance Painter. Normal maps and the like were baked in Marmoset Toolbag. I did heavily reference photos and architectural diagrams to make the model, but I also did take a lot of liberties to stylise the model and render it more readable in the game.

In-Construction

In-construction mesh with scaffolding
In-construction mesh with scaffolding

The interesting bits really came when I started making the in-construction phases. I started off by making a tool in Houdini to generate scaffolding: which you can see in action here. While making a whole tool for scaffolding is slightly overkill, I felt it was worth the effort. I already had a good idea as to how to go about implementing it, and it would be useful for things beyond making wonders (and beyond modding Civilization for that matter. It should be helpful to generate scaffolding in any top-down strategy game context, with slight modification).2

I had thought to make a tool to generate bricks as well, But I ultimately felt it wasn’t really worth the effort, and instead pieced the walls together manually from existing parts using deform and lattice modifiers to match the silhouette of the building.

Wall pieces used to build up the structure, from assets provided by Firaxis
Wall pieces used to build up the structure, from assets provided by Firaxis

Animation

Animating the actual construction procedurally isn’t as complicated as it sounds.

I begin by preprocessing the pieces for rigging. In Houdini, via a custom node I made, I assign each piece a “threshold” value based on their height, with pieces at the bottom having a lower threshold value3 Then for the frame range, I check each frame for a “progress” parameter. If this progress goes above or below the threshold, then I mark the piece as having toggled that frame, and record the frame number as an attribute on the brick.

At the end of this, you basically have a record of what frames each piece should toggle between invisible and visible!

Preprocessing

I can then take the output from multiple of these pre-processing nodes and just merge them together for rigging! All I really need to create the rig is just that record of frames on every piece. This is actually a fairly important point because it means I can separate the structure into multiple sections and keyframe them separately. So I can ensure certain bits get built in a particular order by separating them out. Automation is great and all, but oftentimes, a human touch is still very much needed.

The rigging node collates a list of unique frame combinations and creates a bone for each, then binds all relevant pieces to that bone. Then it just scales that bone up or down on the specified frames to show or hide it. Voila! Fully rigged and animated construction animation!

Output from the rigging/animating node

In this instance I only needed two dozen or so keyframes to control a total of 994 separate bones! So that’s neat!

Final animation graph for the construction animation
Final animation graph for the construction animation

I think it is worth pointing out, that while I used a rigged animation here, the way this is set up, this could easily be adapted to output a vertex animation texture. Or, if you’re okay with limiting the number of toggles, you probably could store the information as vertex colour data and toggle the visibility of the pieces with a masked shader. I’m using a rig here because of limitations imposed by modding Civilization VI. 4

Running into Issues

While I would have loved to be able to say it was smooth sailing from here, just importing the model and animation into the game engine, that was unfortunately not the case. While I have previously imported animations into Civilization 6 (both for buildings and for characters) I had never imported animations that required essentially stepped interpolation. So on importing, I encountered some issues, as you can see below.

Animation Error

The exported file from Houdini imported fine into Blender, Unreal Engine, and back into Houdini, so I identified the error as having something to do specifically with the process of importing into Civilization VI. Unfortunately, given the tools available to me, there was very little I could do about it. I did try increasing the frame rate of the exported file (first to 60 FPS then to 120 FPS), but this did not seem to affect the imported animation. The best I could tell the importer samples the animation at a specific FPS then eases between them to produce additional frames, causing the weird errors seen in the video. I was back to square one on getting the animation into the game.

So I ended up being forced to revert to a tried and tested method. I’m not the first modder to make a custom-animated wonder. Albro is perhaps the most notable modder to have done this. The animations are done by essentially reusing existing rigs and animations from the game. A custom model is rigged to an existing rig, in such a way that the pieces appear in the correct order. Other modders did this manually, so they tend to not be as detailed as what I wanted, with the structure appearing in stages rather than brick by brick. But it’s a method I already knew worked.

Empire State Building - Construction Animation - by Albro

I ended up exporting an existing rig, then using Houdini to generate a grid of cubes to analyse the animation. I couldn’t examine the animation outside the engine directly unfortunately, as the visibility toggle in-engine relies on hiding the object parented each bone, which does not export. 5

Cubes rigged to the Hermitage Wonder animation for analysis

I ended up having to manually log the times each bone toggled visibility in a spreadsheet. I think it ought to be possible to automate the process with OpenCV, the points are laid out in a grid so they should be easy enough to identify and track. But that’s a project for another time.

Snippet of the spreadsheet
Snippet of the spreadsheet

With the bones logged I could export the bone names and times into a CSV, and using only the bones that ever toggled on, I modified my rigging/animating node to reuse the rig and data from the provided CSV instead! Doing this procedurally meant I could get much more granular than what other have done using the same process, and allowed me to adjust timing and make changes to the model much more quickly.

The result isn’t quite as granular or as smooth as my fully custom rig/animation, and there are some moments with little action due to the fact that there are no usable keyframes in that section. But it was the only way to get the animation into the game at all, which was what mattered.

The final in-game animation

  1. Essentially I was planning to hijack the same method used to play animations when you encounter a natural wonder. ↩︎

  2. If I ever get around to making that roguelike/deckbuilding 4X game I keep telling myself I’m going to make, I’m definitely using this! ↩︎

  3. It’s a little more complex in practice. I have two separate methods of assigning this threshold value that look slightly different (I call these two methods Height First and Natural). One essentially just sorts by height and horizontal position naïvely, while the other adds a slight curve based on the horizontal position to make the animation look more dramatic, with the pieces in the back being built up faster. Additionally, there’s some randomness added, as well as additional checks to minimise the amount of floating bricks that might result from the added randomness. ↩︎

  4. Again, very tempted to adapt this if I ever do that 4X game! ↩︎

  5. You just get a bunch of bones that sit there and do nothing. Hardly exciting stuff. ↩︎