Friday, September 29, 2006

Anisotropic Filtering

I'll hold off most of my comments until RC2 comes out; we thought it would be out a while ago but Austin had to go on a business trip. (So really this is RC3, because we've put more bug fixes in since RC2 almost came out but didn't. Heck I have no idea what number Austin will give this build!) Anyway, new build should be out soon and then I'll discuss some of the new features.

One thing I've looked at a lot over the last few days is anisotropic filtering. Basically anisotropic filtering is when the graphics card looks at more of a texture to make it look better when it is sloping away from the viewer.

X-Plane provides the graphics card with several versions of each texture in different sizes; depending on how far away the polygon is, the graphics card picks the right size for the best look. This is called mipmapping. It allows the graphics card to draw a very small version of a texture without having to do the work of scaling it down. Essentially the textures are pre-scaled to every possible size we could need. (But never bigger than the original size, modified by your texture resolution settings.)

The problem comes when a texture is sloping away from us. Consider when we are sitting on the runway at KSBD. The close part of the runway is just huge and requires the biggest version of the texture we have. The far end requires the smallest version. Anisotropic filtering allows the graphics card to look at extra data to preserve the details as the size it needs gets smaller. (I realize that that is probably the worst explanation of anisotropic filtering ever written, but I don't want to get into the math...Google or Wikipedia to the rescue.)

Basically there are three things a user must know about anisotropic filtering:
  • Anisotropic filtering makes a texture that is sloping away from us less blurry.
  • The graphics card uses more texels (pixels from a texture) to render when it is on - 8x anisotropic filtering means the card can use 8x as many texels. That can really hurt framerate.
  • What the card actually does is up to the hardware maker and driver writers. X-Plane just says "give me 4x" and hopes for the best.
Before X-Plane 850RC2 X-Plane only had a check-box...on or off. If anisotropic filtering was on, it was on maximum, which is an outrageous 16x for some cards! This gave you two options: a blurry world or a huge frame-rate hit.

Austin is working on complete anisotropic filtering control - that is, you can select the level of filtering from 1x to 16x, but with all the intermediate levels. The sim will default to 4x, which I've found is a good compromise of speed and image quality. So hopefully this will allow some users who had to leave anisotropic filtering off to get a little bit of filtering without a big frame-rate hit. I suggest you try changing the level on your computer and see what looks good and what is fast.

One thing I must admit: we've always had anisotropic filtering on the runways, and we will continue to always leave this on. It simply makes a huge visual difference in this one situation where we know that you will see our textures at a horrible viewing angle. X-Plane 850 RC2 is a little bit more polite than RC1 was; whereas RC1 and all previous versions maxed out anisotropic filtering on runways, RC2 will not increase it beyond 4x unless you set the rendering settings to do so.

One last mostly unrelated note: the high resolution earth orbit textures make the sim look nicer but hurt framerate. But they hurt framerate more if anisotropic filtering is higher. So this is a reason to carefully pick the amount of anisotropic filtering you want.

4 comments:

Anonymous said...

Excellent news. Thanks a lot for this much needed option. 16x is indeed overkill when even 2x can give very satisfying results on a modest hardware.

Anonymous said...

I used to de-activate AF inside X-Plane, and then force 4x AF via video-card control panel.

I guess it gives the same results?

Also, I read that forcing AA or AF via video card drivers rather than activating it inside an application can give better performance. Don't know if it's true though.

Marco

Anonymous said...

It's definitely true for anti-aliasing. Not sure why, but XP's AA is awfully slow compared to the driver's AA.

Benjamin Supnik said...

It's not really "X-Plane's" FSAA or AF. It's a question of whether we tell the driver to do it (via an OpenGL call) or you do (via a control panel). Either way the driver is doing the FSAA and AA.

The driver can take short cuts in the way it does FSAA or AA, often based on a series of heuristics from OpenGL API calls (e.g. guessing what we want) or from special control panel settings. So if it's faster, it's probably lower quality, but that may not matter...the fps may be more important.

So...I'd say if the driver setting looks good to you and is faster, use it!