Wednesday, May 03, 2006

High Level or Low Level

In considering how we design new scenery features, we have to choose between a high level or a low level approach.
  • In a high level approach, we describe the data abstractly as possible. "Taxiway light" is a pretty high level description.
  • In a low level approach, we describe the data as specifically as possible. "Light whose RGB value is 0.1,0.1,0.9, with a halo, 0.4 meters above the ground, with texture coordinates..." is a very low level description.
In favor of a high level approach is performance and ease-of-use. For some catagories of usage, it's easier to work with high level primitives because the description is less tedious. It's easier to plot taxiway lights than to describe one. High level primitives also make performance easier: it gives X-Plane the freedom to draw taxiway lights in the fastest technique possible.

Low level approaches offer flexibility. Authors can make up lights we've never heard of before. It also means less code; there are perhaps a few dozen distinct types of lights in the airport area, all of which must be programmed, but code to handle a generic light of a given color can be written once.

The danger of a low level approach is that we could allow a scenery construction that is difficult to support in the future, and then have to choose between sacrificing performance and breaking backward compatibility. Neither option is much fun, which gives me pause in considering such design decisions.

At this particular instant for lights I am looking at a two-tiered approach:
  • Simple mode lights will provide only the most basic lighting "tricks" (flashing or turning on at a certain time of day) and will be very fast. Because these lights are not very flexible, X-Plane has a lot of room to optimize how they work.
  • Complex mode lights will do almost anything but be relatively slow (meaning the same speed as textured lights now). This will let us do the really tricky lights like airport beacons, which are complex but fortunately don't have to be fast because they are relatively rare.
So to answer the general question "why don't you let us customize XXX", the answer is often: if we let you do whatever you want with the scenery itself, then we can't do whatever we want with the rendering engine, and that could mean slower performance on future hardware. The design decisions are a compromise of flexibility and performance.

No comments: