Thursday, December 14, 2006

A Change in Settings - 3-d Lights

For X-Plane 860 beta 6 I think we may change the way the airport lights setting works. Since
(despite my previous rantings) there is a lot of discussion of performance based on settings (e.g. "I used to get 40 fps with this menu pick, now I need this other menu pick") as opposed to based on what the sim is actually doing, allow me to go off in some detail about what's going on under the hood.

During X-Plane 850 and 860, I tried to fix a number of long-standing "quality" issues, where the sim had small artifacts. There is a fps penalty to fixing these artifacts that I thought was small, but the message is clear:
  • Some users are flying X-Plane on lower-end systems and can't spare a single fp.
  • A lot of users really don't care about the quality issues and would gladly trade back the visual "improvement" (which doesn't seem like an improvement after living with the issue for 4 years) for those few fps that mean the difference between clear skies and fog.
So...with that in mind, let me explain runway lights for 3 versions of X-Plane.

X-Plane 840 and earlier
In X-Plane 840, lights could be textured or untextured. This was controlled by a simple checkbox "draw textured lights". A few lights (on the airplane, for example) were always textured because we thought they were few in number and important visually. The rest was decided by the checkbox.

No airport light ever had a 3-d "structure" (e.g. you couldn't see the light housing and support rod).

No light was ever drawn using hardware acceleration, even if the graphic card had pixel shaders; we simply didn't have the code. Therefore textured lights ate up a lot of CPU power and thus ate up a lot of framerate. But life was simple!

X-Plane 850
With X-Plane 850 things got a lot weirder.
  • We rewrote the lighting engine to optionally use pixel shaders if present. This improves performance of textured lights a lot. In fact, on a given machine with pixel shaders, textured lights with hardware acceleration are faster than non-textured lights without hardware acceleration. (For hardware accelerated lights, the texturing doesn't cost anything compared to hardware accelerated untextured lights.) It's important to note this performance fact!
  • Sergio created a bunch of 3-d object lighting fixtures for the runway environment. They have a low LOD, but up close you can see the actual lighting structure.
So what to do about that setting? Well, basically with the check box on we did the nicest looking thing, and with the check box off, we did the fastest thing. (The check box's label doesn't do a good job of representing this.) We thus have four possibilites:
  1. Checkbox off, no pixel shaders: we draw untextured lights using software, no objects.
  2. Checkbox off, with pixel shaders: we draw textured lights using hardware, no objects.
  3. Checkbox on, no pixel shaders: we draw textured lights using software, with objects.
  4. Checkbox on, with pixel shaders: we draw textured ilghts using hardware, with objects.
This is plenty confusing if you ask yourself "what is this checkbox going to do" - it depends on your hardware. But the rule is quite simple if you consider the intent: we either give you the fastest (off) or nicest (on) rendering we can.

X-Plane 860
With the next X-Plane 860, we're going to use this checkbox to control multiple aspects of the sim, but always with two choices: either prioritizing visual quality, or prioritizing framerate.

So this option will not only pick the fastest (or nicest) light code and turn the objects on and off, but it will also, for example, turn on or off per-pixel fog (something that looks nice but is slower than the old per-vertex fog).

I'm not sure everyone will like this, but I think it will meet some important needs:
  • It will make it obvious how to set the checkbox. Either you want speed, or quality.
  • It keeps the config interface simple for new users.
  • It gives us a way to tie in a number of small optimizations that add up when taken in concert.
It seems to me that we're seeing the haves and have-nots. If you've got a Core 2 CPU and a 7000-serise GPU, things like per-pixel fog are chump change. If you've got a G4 with a Radeon 9200, you need any speed you can get. So hopefully this change will make the UI clearer and help us meet everyone's needs.

2 comments:

Anonymous said...

I don't think X-Plane has a built-in fps test like Unreal Tournament or Quake have. Perhaps add a built-in fps test to x-plane, so all users can test different hardwares under same simulation conditions. We should then get a fair comparision hardware test. This test should go through both easy and heavy load areas and do exactly the same thing (same angle, environment etc.) at each test operation.

Benjamin Supnik said...

I don't know if X-Plane's fps test is like Unreal or Quake, but it definitely has a fps test. See my post on 10/6/06:

http://xplanescenery.blogspot.com/2006/10/x-plane-850-framerate-test.html

It goes through either ah heavy or lightly loaded area by adjusting settings - the testes are numbered.