Blog

Reflective Airplanes

I woke up this morning to one of those funny coincidences that defines the experience of working on X-Plane: two users had emailed me. One was asking whether we’d be extending water reflection technology to airplane fuselages (like some other programs have) and the other made the case that such an extension was not necessary. The two emails arrived in sequence! (Perhaps there was a forum debate on the subject somewhere.)

First, I can tell you that if we ever have reflective airplanes, it won’t be that soon. I have a number of features for version 9 that are in progress and need to be finished off before I can start anything new.

Reflective airplanes are on my “investigation list”…that is, a feature where we want to do the initial research to see if it could be implemented in a way that makes sense (for X-Plane this means: would it look good and not kill fps too badly for at least some segment of our users).

I believe the X-Plane 9 version run will start to contain more features for serious 3-d modeling of airplanes. Version 9 already features 3-d lighting in the 3-d cockpit, key frames for animation, and a ton of new datarefs to drive that animation. We’re going in the direction of being able to model the plane in absurd detail.

We’re also looking at the lighting model in X-Plane. We’ve only started this work for version 9, but consider pixel-shader-based water. Even in the “no reflections” case, the pixel-shader based water is a reflection of the real sky (as rendered) with a procedural texture to create waves. When you compare this to the version 8 water, you can see how having really close alignment of the coloring scheme for all parts of the sim creates more of a sense of realism.

So reflective airplanes are at least on my list of things to try. I have seen users do wonderful amazing “metal” textures on airplanes, but the one thing that I think holds them back is that all metal airplanes have some kind of tinting assumption to them based on the reflection used…typically these are “blue-based” (meaning they look right on a sunny day) or “gray based” (meaning they look right on a cloudy day). But if you put the plane in the other environment the texture looks a lot less convincing. Reflective textures would let authors really use the real sky color on the plane, for consistent lighting (especially when the plane’s orientation changes and the blue side isn’t up anymore).

On the other hand, reflections are expensive. Planes reflect light from all sides, so we would need to take reflections from all angles (the water always reflects up, which is a huge savings). For low-quality settings for water, we drop the terrain, and since the terrain only reflects at the water’s edge, this is a pretty tolerable omission. An airplane reflection with “sky on the bottom” would look absurd. (Similarly, the water tends to only reflect things that aren’t on camera, so the total rendering load of water + the world tends to be static. The plane would pick up a lot of 3-d objects even in orientations where they don’t do much good, so plane reflections would become expensive.) And the plane reflection isn’t usable for any other plane…do we build them for all planes or just the user’s plane?

Certainly right now it’s still too soon to tell. Not only have I not done the research into this feature, but we still don’t have comprehensive performance data on the water across lots of hardware. A number of users are reporting huge framerate loss on the lowest water settings. This implies that our “render-to-texture” code is slow on some hardware but not others. (The fps loss on my laptop with the lowest water setting is less than 4%.) Render-to-texture is new to v9 and used heavily, so we need to understand how it scales for all users before we go further.

Finally, there is a whole area of 3-d techniques that X-Plane does not yet use that could make sense for airplane modeling: artist controlled fake lighting.

For example, imagine if the airplane contained a single “reflection” texture – this texture would contain a fake ground texture and alpha transparency where the sky color goes. X-Plane could then fill in the sky color (where there is transparency) only when the weather conditions change, and then apply the texture keeping the plane’s orientation in mind. Such a proposal would give the plausibility of reflections (correct coloring on all parts of the plane across lighting, orientation and weather conditions) for a fraction of the cost of “real” reflections. I’m not saying this is the best idea, just that there’s a lot of intermediate ground between “full reflections” and “make a static texture”.

Posted in Development, Scenery by | 12 Comments

Dr. House

Lori and I are hooked on the TV show “House”, where Hugh Laurie plays a really grumpy doctor who solves bizarre medical cases more or less by ESP. The characters are well written, but the medical plot line is somewhat predictable: there are four quarters to the show – in each one House except the last, House will make the wrong diagnosis and the patient will get worse right before the commercial break. (Usually this involves massive bleeding or cardiac arrest going into the long commecial block at 0:30.) None of the symptoms fit until the very end when House finds the simple right explanation they just couldn’t see.

This set of nvidia crash bugs felt a lot like that – we had multiple attempted fixes, some of which didn’t help at all, until finally after multiple tries I found a bug that explained all of the otherwise completely weird behavior we were seeing.

But I must admit – I have brought shame on the house of X-Plane…the buggy code was mine and the mistake was really stupid. Why nVidia on Windows? As far as I can tell the optimizers present in most OpenGL engines can change whether (and how) the bug manifests itself – different OS/driver pair: different engine with different optimizers.

Now that (at risk of massively jinxing ourselves) we have the crash bug fixed, I will resume performance work. Once we get a build done with all of the immediate performance items I want to cover, we’ll start collecting user reports on in-field performance. So I should have more specific instructions on what you can do to help us isolate performance problems in the next few days.

Posted in Development by | 1 Comment

What is a panel region?

X-Plane 9 introduces a new OBJ feature: panel regions. The basic idea is this:

In X-Plane 8 you could use the 2-d panel as a texture in your 3-d cockpit. This allows a plane to have a moving map or glass display in the 3-d cockpit. However, the panel texture is expensive, particularly in v9 for a few reasons:

  • You have to take the entire panel, even if you don’t use it all. For example, consider all of the “wasted space” from the windows.
  • The real texture is rounded up to a power of 2 (and in x-plane 9 that could mean 2048×2048 for a a 1600×1600 panel.
  • The texture has an alpha channel, which probably isn’t usfeul (model your 3-d cockpit windows in 3-d, not using transparency). The alpha channel increases VRAM use by 33% and requires some pixel shader gymnastic in v9 that slow things down.
  • In X-Plane 9 this is all twice as painful since we have a panel day and and lit texture.

Panel regions address all of these problems. Here’s how they work:

  • A panel region is a rectangle within your 2-d panel. It can be placed in any location as long as it is (1) fully within the 2-d panel and (2) its dimensions are a power of 2.
  • The cockpit object declares up to four panel regions it wants to use.
  • A new attribute lets you use each of the four panel regions as a texture (alpha is not provided – the regions act opaque).

This does exactly what you might expect: it creates between one and four smaller power of 2 textures rather than one huge one and manages those smaller textures. We do have more textures, which is usually bad but we get some big wins:

  • Better VRAM use. The panel texture, being a dynamic texture, puts a lot more pressure on VRAM than regular scenery textures. Without this optimization, we could be paying 25 MB of permanent VRAM use just for the 3-d cockpit. Now we don’t have to pay to round up to a power of 2.
  • Faster updates of the 2-d panel into the 3-d texture, since we have to process a lot fewer pixels.
  • Efficiency – a clever author can cut down the panel use to only the parts that really matter, which might only be the EFIS at 256×256 pixels.

I will try to provide detailed documentation on this in the near future. There will be a new ac3d plugin coming out (hopefully in the next week) that will provide both editing capabilities for key frames and for panel regions.

Posted in File Formats, Scenery by | Comments Off on What is a panel region?

Better Bug Reports

(Probably I’ll be blogging a lot today…the load/change-planes/crash/recompile cycle I am going through while working on the crash bug is a slow one – my old Dell is long in the tooth…it leaves me a lot of time to post.)

Beta can be frustrating for both users (why don’t they fix the bugs I reported) and programmers (I need more details in my bug report). Here are a few thoughts on what makes an initial bug report useful:

  • Precision of reproduction. This is probably the most important thing – we get a lot of “open an airplane”-type instructions. Which airplane? It turns out that a lot of bugs depend on the particular content being used. So if you know how to make a bug happen, please describe it in the most painfully precise steps possible!
  • Short is beautiful. We must know precisely how to reproduce a bug, but a procedure that takes two hours kills our productivity. So please try to determine how to reproduce the bug with the minimum number of precise steps.
  • Clean system. Bugs that involve only the default content shipped with the sim are more useful for us because they’re quicker to find and more likely to be due to a bug in the sim itself.
  • Nuke the prefs. Bug reports that start with “delete your preferences” are good because it means the bug procedure starts from a known state (the sim defaults). We get bugs that we can’t reproduce because something is subtly different in our system. Killing prefs is the quickest way to eliminate this case.

As an example, the cleanest, simplest version of the nvidia crash bug would be:
1. Delete prefs.
2. Start the sim.
3. Open the C172 using the “open aircraft” dialog box.
Result: unexpected program termination before the terrain is visible.

Posted in Development by | Comments Off on Better Bug Reports

Now I have a 6200

We still haven’t fixed the crash bug in X-Plane 9 yet, but we have narrowed it down to:

  • Windows only
  • nVidia only
  • Pixel shaders only

We actually know partly what happens, but we don’t know why, and we don’t know how to fix it yet (short of disabling VBOs or pixel shaders, both of which are unacceptable workarounds). Austin’s shipped b4 with shaders off, just to get people running while we work on this.

So I went to BestBuy last night and bought a 6200 (out of desparation) – I can now see the crash bug for myself. My framerates are also terrible. My guess is I can tweak the drivers, but having experience now with the 5200, 6200 and 7300, I can safely say: avoid the lowest end nVidia cards. In particular:

//en.wikipedia.org/wiki/Comparison_of_NVIDIA_Graphics_Processing_Units

The important thing to look at here is “core config” (although bus width and clock speeds will always be higher in the higher end models). For the last four generations, nvidia has made three levels of cards: a hig end card (with a number like x700, x800 or x900), a mid-range card (usually x600) and a low end card (x200, x300). So for the GeForce 6 series, the 6800 was the flagship card, the 6600 was the mid-range card and the 6200 is the “budget” card.

Each time they go down a level, the number of shaders and other parallel hardware resources gets cut down. This translates directly into lower framerate, particularly in X-Plane 9 where we’re shader-bound when you use the shader features. I often recommend the mid-range cards as a good value, but the low end cards aren’t worth it – they’re too stripped down for not much price savings.

Comments Off on Now I have a 6200

How Framerate Dies – Glitching

Back in the good old days (that would be X-Plane 6), X-Plane’s framerate would suffer in two ways as you cranked up the rendering options:

  1. For most features (more visibility, more autogen) as the CPU and GPU became more heavily loaded, the framerate would gradually decrease.
  2. If you ran out of VRAM (that is, the working set of textures needed per frame was more than your card’s VRAM) framerate would really die fast – think 2 fps.

The reason for this second behavior was that computers couldn’t shuffle textures between main memory and VRAM fast enough to render a frame in a 30th of a second.

As computers have gotten faster, this second behavior has gone away – modern cards, with fast PCIe 16x busses, can transfer textures from system memory to VRAM pretty fast – fast enough to have the working set be (slightly) larger than VRAM and still fly. So as texture memory increases, framerate decreases more gradually.

However, a new behavior has emerged: “glitching”. You may have noticed that when you’ve got your computer set to the ragged edge of the rendering settings, as you turn the camera, the framerate will stutter for a few frames, then return to a relatively high rate (40-50 fps).

What’s happening is: the working set of textures and geometry needed by X-Plane just barely fit in VRAM. But when you turn your head, a different set of textures and geometry are needed. While the card sorts out what is needed and what isn’t, it spends some time needlessly shuffling textures, and eventually reaches stability, with only what’s needed in VRAM, and framerate stays high.

Glitching has emerged as a mode of performance degredation because over time we’ve cut down the amount of “stuff” (textures and geometry) x-plane needs to draw a frame to only what’s really absolutely needed. This means there is less intersection between the working set in one view and another, and it also means you can get closer to the edge of your hardware.

So my view on glitching is basically “too bad”. If the working set weren’t as carefully trimmed, you wouldn’t have glitches, but the framerate would be entirely low, not entirely high. The only solution is to turn down settings that increase the working set (object density, world LOD, tex res, forests…) until the computer can run without glitches.

An even stranger variant of this: users sometimes report framerate getting “stuck” at 19 fps and then coming back when they change apps. The problem is that the driver doesn’t know exactly what the best order of textures to keep in VRAM vs. shuffle is…as the view changes, sometimes the driver ends up with a non-optimal decision about what stays in VRAM and what goes, causing framerate to drop. Changing which app is in the foreground fixes this by temporarily pushing a lot of items out of VRAM, at which point the driver makes a different decision by luck.

Again, the solution is simple: turn down rendering settings to get the working set smaller than VRAM.

Basically, if the working set is smaller than your amount of VRAM, you should have even framerates, proportional to rendering load.

If the working set is greater than VRAM, the driver may find an optimal way to shuffle things and only decrease fps a little, or it may find a non-optimal way to shuffle and you’ll get terrible fps, and that shuffle can change on the fly, causing framerate to fluctuate all over the place.

Posted in Development by | Comments Off on How Framerate Dies – Glitching

Two Truths of Hardware

I would have to say my track-record at predicting hardware developments in the sim world has been pretty poor. But these two factors seem like they won’t change for a bit:

  1. The amount of working data a system can crank through in one frame keeps increasing while the total amount of virtual address space stays the same (3 GB).
  2. The gap between the fastest and slowest systems from a finite time period keeps widening.

To elaborate on this first point, as video cards get faster (both GPU and internal bus/RAM speeds), system RAM and buses get faster (graphics slot changes are rare, but with enough VRAM this is relatively moot) the amount of texture and geometry data that X-Plane can tell the card to draw in a 30th of a second keeps going up. So users are running with more trees, roads, 3-d, etc. than in the past.

But all of this stuff lives in memory, and even if a user has 8 GB, X-Plane can’t load more than 3. Imagine what will happen when a graphics card can draw 3 GB of data in one frame? X-Plane will have to use all of its available memory for things you see right now or it will waste graphics power. This would mean purging from memory anything that isn’t on screen!

On the second point, video card power doubles every, um, six to twelve months (perhaps more like 18, now that the card makers are hitting the same fabrication and power limits that the CPU makers have already hit, but this is all seat of my pants). So even if we only supported the last three generations of cards (we support at least seven!!) that gap in performance doubles!

This means that every year it requires a more flexible rendering engine to make a sim with decent frame-rates for old computers and up-to-date graphics on new ones.

Posted in Development by | 9 Comments

Obects and Liveries

In X-Plane 9 betas 2, you can use the livery system to provide alternate textures for misc objects attached to your plane, but not the cockpit objects. Beta 3 will address this, allowing cockpit objects to reference the livery system too. We’ll get some examples posted for how this all works soon.

Austin and I were discussing this last night – here’s a few thoughts on the difference between the misc. objects and the cockpit object:

  • Because you can have multiple misc. objects, you can effectively use more than one texture for your airplane. These days plane designers want a lot more than one texture.
  • We’re working on optimizations for attached objects – basically by breaking your plane carefully into a few objects, you may be able to optimize frame-rate. A lot of this code is not in the sim yet, but will go into a later beta.
  • Using multiple objects with different LODs is a much more efficient way to improve fps than simply having multiple LODs of the entire plane.

For example, make an interior object with a low LOD (0-500 meters) and an interior texture. Attach it. Then make an exterior object with an exterior texture and a longer LOD (0-50000 meters). When you back away from the plane, X-Plane can entirely skip the interior object, which means that neither the geometry nor texture have to be moved to VRAM. That’s a big performance win.

The cockpit object is also different:

  • The cockpit object induces the sim to make a texture out of the 2-d panel. (And it is the only object where the panel texture is legal.)
  • Mouse-click analysis is only done on the cockpit object. If you load up the cockpit object with all of the animation for your landing gear, X-Plane has to wade through all of that animation to update the mouse cursor in the 3-d cockpit.
  • The cockpit object can be swapped for an alternate object in the exterior view (we’ll provide more control of this for misc objects soon).

So my general advice is: use the cockpit object only for the real panel itself!

However, we have provided livery support. You can’t livery the 2-d panel, and the livery system is not meant to reskin cockpits, but there are probably some planes out there that used the cockpit objet to model exterior plane features (from before we had misc objects). The livery system in beta 4 will let you reskin these planes without changing how your obects work.

Posted in Cockpits, Scenery by | Comments Off on Obects and Liveries

A wide range of performance

One trend I’m seeing in the forums is a wide range of reports on X-Plane 9 framerate. I see both “X-Plane 9 runs faster than 8” and “it’s so slow I can’t fly at all.”

In my experience this kind of situation is often due to hardware-specific performance issues…that is, X-Plane is doing something that is fast on one kind of GPU but slow on another. Once we figure out what the problematic operation is, we can replace it with something that’s fast for everyone.

If you’ve got all of the eye candy turned off, everything on minimal, and are still getting 20 fps, that’s not X-Plane 9 being a pig, that’s something wrong with X-Plane 9 on your particular system. Please…try beta 3 when it comes out, then if it’s still slow, report a detailed performance bug and we’ll investigate.

Comments Off on A wide range of performance

Beta 3 – Don’t Panic

X-Plane 9 is currently in beta 2. Long-time X-Plane users know that a lot of bugs get fixed between early and late betas, and they also know that a good number of bugs get added between the early betas.*

If all goes well, X-Plane 9 beta 3 will be out in a few days. My advice is: don’t panic. X-Plane beta 2 crashes for a number of users, so our top priority is to fix the crash and get the fix out ASAP. If your bug doesn’t get fixed in beta 3, it’s probably because we’re still working on it but didn’t want to delay getting the crash fix to users.

Similarly, beta 3 will include some performance improvements, but more are coming. Beta 3 doesn’t represent the end of our performance tuning, it represents the first beta that we can do serious analysis with. We only have a fraction of all of the supported video cards within the company, so if your computer is having performance problems, well, we’ll figure out what’s going on in beta 3 and then fix it.

* Our approach to bug fixing is: if a piece of code is buggy because it’s subsystem has a design problem, we go in and fix the design problem, even if we’re in beta. Other companies might say “no fixing design problems (which changes more code) during beta.” But the way I look at it, badly designed code is just going to cause problems all the time until it’s fixed, and it has to be fixed some day, so why wait.

(Why would there be badly designed code in X-Plane, or any computer program? Computer programs change over time, and the functionality they perform changes and grows. As this happens, the designs of the past no longer make sense for future requirements. In my experience most design problems come from code “outgrowing” its framework.

So our approach is to upgrade the framework as soon as it shows signs of growing pains, rather than jamming as many features into the existing framework as possible until it becomes so overcrowded that we can’t get anything done.)

Posted in Development by | Comments Off on Beta 3 – Don’t Panic