Saturday, December 01, 2007

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 2048x2048 for a a 1600x1600 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 256x256 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.

No comments: