Saturday, October 14, 2006

Pixel Shaders and Scenery

X-Plane 850 was the first version of X-Plane to start employing pixel shaders -- they make the new hardware-accelerated lights possible. Our next step will be to start converting existing OpenGL code over to pixel shaders.

DISCLAIMER: these are my predictions for the future of X-Plane, not promises or guarantees. Do not base your purchasing decisions on what I say, and do not come back quoting this blog saying "you promised X". This is a statement of our intentions, but we cannot predict what limitations we could hit in the future, such as graphics problems we did not anticipate!

Right now X-Plane works based on individual selection of features - that is, each separate part of X-Plane examines our summary of a driver's capabilities and does what it can based on those capabilities. The result is good for users in that X-Plane's visual features turn off one-by-one as a card becomes less capable, leaving as much eye candy as possible.

What's bad about this technique is that there are huge combinations of possible configurations, more than we can test individually, so we sometimes have bugs that show up only with a peculiar combination. Since most of the code that uses this driver spec has been relatively stable we haven't seen a lot of bugs due to this in 830-850, but I definitely fixed a lot of configuration-related OpenGL bugs in the early v8 run when the rendering engine was new.

Pixel shaders (we use GLSL for the OpenGL nerds out there) will change that; the OpenGL shader spec is powerful enough that if we have it, we can do everything we want. So the new world of shaders will make X-Plane's visuals be either "you have it" or "you don't". This definitely helps us for testing - we can test the shader version, the legacy version, and that's it.

Remember the dark old days of X-Plane 6 when GeForce 4 MX's had two pixel shaders, but GeForce 4 Ti's had 4, and ATI cards had 2,3,4 or 6? Fortunately we're past that. The last three generations of video cards have pixel shaders and every card with shaders has 16 texture units, which is more tha enough for us.

Here are the cards that will support shaders, at leaset I think from the specs posted on the web (all suffixes have equal pixel shader capabilities - the suffix usually is about the speed of the card):
  • ATI Radeon 9500-9800.
  • ATI Radeon X300-x850.
  • ATI Radeon X1000-X1900.
  • nVidia GeForce 5200-7900.
  • Any card that hasn't been released yet will surely support shaders.
Here are the cards that X-Plane will run on but don't support shaders:
  • ATI Radeon 7000-8500.
  • GeForce 2,3, and 4.
  • Intel GMA950 (and probably a few other Intel chipsets I don't know abot).
I don't know about the old Rage 128 or original GeForce 256 - technically they probably meet minimum requirement, but they're so underpowered you wouldn't want to run X-Plane 8 on them. Also I don't think they ever came in 16 MB variants. I don't know about Matrox's compatibility.

To use pixel shaders you will also need reasonably new and modern drivers. Both ATI and nVidia ship modern drivers that support shaders fully, but very often what you get on your machine or with Windows XP does not. So if you have a card that supports shaders but don't see them, it might be time to check the vendor website.

For Mac users Apple shipped full pixel shader support in 10.4. So: if you have a card with pixel shaders and you use 10.3.9 you should upgrade to either 10.4 now or 10.5 when it comes out! Otherwise x-Plane will not have the right driver to utilize your hardware! An X850 or 7300 on OS 9 is definitely a waste of potential. (X-Plane 8.50 already has features that are only available to pixel-shader users on 10.4!)

I am excited about pixel shaders because we'll be able to finally fix some of the bugs we just couldn't fix before. For example, when you turn on the landing light, X-Plane's ambient lighting levels drop to pitch black. With pixel shaders we will finally have the capability to fix this!


Anonymous said...

Unless you're specifically targeting shader model 2.0 cards, the GeForce 3 definitely supports pixel shaders. I believe it was actually the first card with programmable pixel shaders (PS 1.1). The Radeon 8500 even has support for PS 1.4. That sure ain't a lot of power by today's standards, but with a bit of tweaking and compromise, you can run Oblivion on it!

Benjamin Supnik said...

kaminari, you are 100% right about ps 1.1 and ps 1.4, but yes, we are targeting Pixel shaders 2.0, or as I call them, "real pixel shaders". :-)

When comparing OpenGL vs DirectX, what you'll see is that PS 1.1 and PS 1.4 aren't treated as "programmable" shaders in OpenGL, but rather as various versions of texture combining. We currently utilize the ARB tex-env combine extension, becuase it's ubiquitous, but we do not try to utilize things like the nVidia register combiners or any other vendor-specific older shader power.

So what we need is Direct X's "shader model 2", or GLSL...the same cards run both.