Ace Combat levels

Eggheads talking about bytes and stuff.
Post Reply
User avatar
Krishty
Site Admin
Posts: 455

Post by Krishty »

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.

2022-06-27 ac3 fixed polys.png
2022-06-27 ac3 fixed polys.png (83.31 KiB) Viewed 839 times
(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!

2022-06-30 Expo City 1.png
2022-06-30 Expo City 1.png (1.21 MiB) Viewed 839 times

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.

2022-06-30 Expo City 3.png
2022-06-30 Expo City 3.png (1.33 MiB) Viewed 839 times

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.

2022-06-30 Megafloat 1.png
2022-06-30 Megafloat 1.png (1.35 MiB) Viewed 839 times

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.

2022-07-01 AC3 moving map.png
2022-07-01 AC3 moving map.png (1.92 MiB) Viewed 839 times

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 …

2022-07-03 carrier approach.png
2022-07-03 carrier approach.png (383.51 KiB) Viewed 824 times

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 …
mikew
Data Genius
Posts: 242

Post by mikew »

Wonderful!..IIRC that AC data was saved in VRML format, so you have a common renderer that can handle VRML and TFX's bytecode?
mikew
Data Genius
Posts: 242

Post by mikew »

...and now I remember trying to take a tile from that AC data, and convert it to TFX's format.
https://community.combatsim.com/topic/2 ... nt=5195654
I didn't take it further, but that exercise gave me some small insight into the effort involved.
Those screenshots are stunning!
User avatar
Krishty
Site Admin
Posts: 455

Post by Krishty »

mikew wrote: 2022-Jul-03, 21:46IIRC that AC data was saved in VRML format
Indeed! And I had completely forgotten your conversion exercise … it’s all back now, and I will answer a few open questions from that thread!
mikew wrote: 2022-Jul-03, 21:46so you have a common renderer that can handle VRML and TFX's bytecode?
I did not render the VRML data here. I grabbed right into AC3’s game files (like we did with TAW) and read them from their native format.

I do, however, have a renderer that supports any kind of simple (textured and colored) triangle. You basically write the triangles to some kind of memory file and the engine will bring them to the screen. Very flexible approach that will also work well for VRML 🙂
User avatar
Krishty
Site Admin
Posts: 455

Post by Krishty »

Going underground

Some Ace Combat levels have underground structures. Not only is the Tunnel Vision level completely underground; Expo City famously has an underground airport. Here, underground does not only mean “below surface”, but actually “below sea level”.

Expo City underground airport
Expo City underground airport
2022-07-01 Expo City underground.png (1.47 MiB) Viewed 800 times

The TFX games have no elements below MSL, so this uncovered another range of bugs related to negative coordinates. Most importantly, any object below MSL was immediately deleted as part of a clean-up pass: If an object or bullet falls through the ground – by numerical error or by gap in the level data, of which both AC3 and TAW have plenty – it will fall forever. Many such objects could saturate the CPU easily. So we clean up such lost objects by deleting anything below a certain minimal height.

The minimal height is now a central compile-time constant. I set it to -1024 m – this is easily enough for the lowest point on Earth’s surface (Dead Sea, -430 m) and in AC3 (-1000 m).

I won’t go deeper because air pressure grows exponentially the deeper you go, and funny things happen to jet engines and aerodynamics :)

Found another bug – the F-22 HUD has no minus sign in its altitude display.
Found another bug – the F-22 HUD has no minus sign in its altitude display.
2022-07-13 pixel filter Tunnel Vision 1.png (1.74 MiB) Viewed 800 times

Anyway, with my next repo update we can
  • land on surfaces below MSL;
  • shoot bullets below MSL;
  • hit targets below MSL.
mikew
Data Genius
Posts: 242

Post by mikew »

Looks great! Look forward to flying around the AC3 world without having 10 seconds to get get somewhere or destroy something. :D
I already have AC7, so there's presumably also AC1,2,4,5 & 6.
User avatar
Krishty
Site Admin
Posts: 455

Post by Krishty »

Don’t forget AC0, which was arguably the best of them all. I missed it back then and only got if for my birthday this year. Haven’t played more than a few missions yet.

Post Reply