Ace Combat levels
Posted: 2022-Jul-03, 21:26
I had an idea during my quest to give TFXplorer a decent modding API: I have a few levels from old Ace Combat games readily extracted, so why not use them?
So I spent last week’s evenings writing an extension that imports the levels from Ace Combat 3: Electrosphere (AC3) into TFXplorer.
I haven’t pushed the extension to our repository (yet?) because the code is not really production-ready, but this experiment gave me some really interesting insights and was well worth it!
Starting
I wrote a new extension from scratch. This reminded me that the current workflow is a mess beyond words, but there is little chance to improve it until I finished my work on the sound/rendering API ¯\_(ツ)_/¯
Jumping through hoops
I was pretty quick at listing a new scenario on our scenario selection screen. But I had to do some work before the level would actually load: Define placeholders for rendering, physics, in-game maps, and so on. It felt like drag at the time, but it paid off later.
I left everything blank except the rendering part. I copied some code for loading AC3 data from other projects of mine, and alas I was able to draw their triangle data! AC3 terrain is tile-based just like EF2000/TAW’s, so I could let TFXplorer manage visibility for me and saturate its callbacks perfectly.
(The weird color is intentional – if you don’t define sky colors, TFXplorer will force the most annoying preset onto you, so you never forget to fix it.)
Adding textures took me some more time because of the weird quirks of the PlayStation GPU, and it was not really related to TFXplorer or its API. It all went pretty smooth!
Brightness
I had a level now and I was very proud, but it looked way too dark. This was due to the way the PlayStation GPU performed blending of textures and vertex colors.
Just hard-coding a different brightness would break the EF2000/TAW levels, so this was not an option. After all, I did this to figure out what my API was still missing! So I added a new brightness control to the renderer. This quickly broke rendering of HUD and text in a testament to TFXplorer’s insane rendering complexity, but I figured it out.
We would have needed a way to control brightness anyway to get a handle on day/night cycles. The fact that the stars are currently visible at day is a consequence of everything being drawn always in the same brightness. I did feel the urge to add a way of controlling white point, shutter time, and tone mapping; but this would have had me sidetracked for weeks, so I stopped.
AC3 has beautiful levels of varying brightness. Day, dusk, night and even indoor (more on that later). This showed another bug – temperature and humidity from the scenario not being honored! Compared to the EF2000/TAW graphics I normally see in TFXplorer, this is really something to look at. Getting the sky colors into the engine (readily provided by AC3) required a little rewiring of parameters, but went otherwise smoothly.
Physics
This was really nice to look at, but now I felt an itch. There’s these beautiful levels (40+ of them) with runways, highways, bridges, skyscrapers, mountains, canyons. But all I could do was look at them. Meh. I wanted to actually fly through the cities! I wanted to land on the bridges so badly!
So I filled my physics callbacks with a ray-triangle collision function I found on the internet and just iterated the same triangles I used for rendering. It worked remarkably well, and I would now crash into mountains and buildings instead of just passing through them. I could even land in the weirdest places!
There was a problem, though. My plane would explode with no apparent reason, and it was worst in the tunnel level. (Did I mention that Ace Combat is obsessed with tunnels? Every iteration has a tunnel level. AC3 even has a whole underground city level.) I ultimately tracked it down to a bug in TFXplorer’s handling of objects transitioning between terrain tiles.
These things never showed in EF2000/TAW because their terrain is, in direct comparison, extremely boring and feature-less.
Map
AC3 provides textures with overview maps of the levels. They are not nearly as sophisticated as TAW’s, but whatever! I was able to add them in no time.
Carrier landing
This afternoon, I found an aircraft carrier in one of the levels. It doesn’t render properly, but with some imagination it’s enough to hit it. I tried carrier landings for some time, and I even succeeded once! I also managed to take off again (with spinning up the engines while the tire brakes were still on). So the F-22 is officially carrier-capable …
Conclusion
This experiment showed a few places where the level API needed polishing, and it also lead to the discovery of a few bugs that would otherwise have been impossible to find (like all the places where the engine still calculates TFX units instead of meters). It showed me all the things I had mocked up long ago but never really bothered connecting with the rest. I will not pursue it with much energy, but I will keep it running until it becomes too costly to maintain.
Gotta take a few videos when I get that carrier render properly …
So I spent last week’s evenings writing an extension that imports the levels from Ace Combat 3: Electrosphere (AC3) into TFXplorer.
I haven’t pushed the extension to our repository (yet?) because the code is not really production-ready, but this experiment gave me some really interesting insights and was well worth it!
Starting
I wrote a new extension from scratch. This reminded me that the current workflow is a mess beyond words, but there is little chance to improve it until I finished my work on the sound/rendering API ¯\_(ツ)_/¯
Jumping through hoops
I was pretty quick at listing a new scenario on our scenario selection screen. But I had to do some work before the level would actually load: Define placeholders for rendering, physics, in-game maps, and so on. It felt like drag at the time, but it paid off later.
I left everything blank except the rendering part. I copied some code for loading AC3 data from other projects of mine, and alas I was able to draw their triangle data! AC3 terrain is tile-based just like EF2000/TAW’s, so I could let TFXplorer manage visibility for me and saturate its callbacks perfectly.
(The weird color is intentional – if you don’t define sky colors, TFXplorer will force the most annoying preset onto you, so you never forget to fix it.)
Adding textures took me some more time because of the weird quirks of the PlayStation GPU, and it was not really related to TFXplorer or its API. It all went pretty smooth!
Brightness
I had a level now and I was very proud, but it looked way too dark. This was due to the way the PlayStation GPU performed blending of textures and vertex colors.
Just hard-coding a different brightness would break the EF2000/TAW levels, so this was not an option. After all, I did this to figure out what my API was still missing! So I added a new brightness control to the renderer. This quickly broke rendering of HUD and text in a testament to TFXplorer’s insane rendering complexity, but I figured it out.
We would have needed a way to control brightness anyway to get a handle on day/night cycles. The fact that the stars are currently visible at day is a consequence of everything being drawn always in the same brightness. I did feel the urge to add a way of controlling white point, shutter time, and tone mapping; but this would have had me sidetracked for weeks, so I stopped.
AC3 has beautiful levels of varying brightness. Day, dusk, night and even indoor (more on that later). This showed another bug – temperature and humidity from the scenario not being honored! Compared to the EF2000/TAW graphics I normally see in TFXplorer, this is really something to look at. Getting the sky colors into the engine (readily provided by AC3) required a little rewiring of parameters, but went otherwise smoothly.
Physics
This was really nice to look at, but now I felt an itch. There’s these beautiful levels (40+ of them) with runways, highways, bridges, skyscrapers, mountains, canyons. But all I could do was look at them. Meh. I wanted to actually fly through the cities! I wanted to land on the bridges so badly!
So I filled my physics callbacks with a ray-triangle collision function I found on the internet and just iterated the same triangles I used for rendering. It worked remarkably well, and I would now crash into mountains and buildings instead of just passing through them. I could even land in the weirdest places!
There was a problem, though. My plane would explode with no apparent reason, and it was worst in the tunnel level. (Did I mention that Ace Combat is obsessed with tunnels? Every iteration has a tunnel level. AC3 even has a whole underground city level.) I ultimately tracked it down to a bug in TFXplorer’s handling of objects transitioning between terrain tiles.
These things never showed in EF2000/TAW because their terrain is, in direct comparison, extremely boring and feature-less.
Map
AC3 provides textures with overview maps of the levels. They are not nearly as sophisticated as TAW’s, but whatever! I was able to add them in no time.
Carrier landing
This afternoon, I found an aircraft carrier in one of the levels. It doesn’t render properly, but with some imagination it’s enough to hit it. I tried carrier landings for some time, and I even succeeded once! I also managed to take off again (with spinning up the engines while the tire brakes were still on). So the F-22 is officially carrier-capable …
Conclusion
This experiment showed a few places where the level API needed polishing, and it also lead to the discovery of a few bugs that would otherwise have been impossible to find (like all the places where the engine still calculates TFX units instead of meters). It showed me all the things I had mocked up long ago but never really bothered connecting with the rest. I will not pursue it with much energy, but I will keep it running until it becomes too costly to maintain.
Gotta take a few videos when I get that carrier render properly …