Friday, May 15, 2009

Per Pixel Lighting Isn't Free

I've had a little bit of time to look at X-Plane 930 performance. The data isn't 100% conclusive yet, but one performance issue sticks out like a sore thumb: per-pixel lighting hurts fps.

Now, part of this is that the per-pixel lighting shaders are not yet optimized (and perhaps are not terribly well written). I need to take some time to see if I can get some more performance out of them.

But...per-pixel lighting isn't free - when per-pixel lighting is on, the video card is simply doing a lot more work than it used to. Consider: a typical X-Plane scene might have 250,000 vertices on screen at once.  At a minimum, you have at least 750,000 pixels on screen*.  Make your window bigger and that number goes up - fast!  Turn on 16x FSAA and watch the pixel count get even larger.  So the number of lighting calculations done by your graphics card are at least 3x higher with per-pixel lighting and potentially 50x higher.  Even if your graphics card has a lot of power, that's going to cost a bit.

So one option I am considering is making per-pixel lighting a rendering option. This would allow users who want 922-level fps to simply turn it off. In my tests so far, turning off per-pixel lighting gets fps to within a few percent of 922.

(The only reason to have shaders on but per-pixel lighting off would be to have a cheap version of the reflective water. In the long term I want to limit the number of a la carte rendering settings, but for now it seems reasonable to support v9.00 base configurations through the entire version run.)

* In practice, not every pixel on screen requires full shading, e.g. the sky does not require complex shading.  But some parts of the screen may be shaded multiple times.  This is called "overdraw".  For example, with a runway we pay for our shaders twice - first with the ground underneath the runway, then with the runway itself.

5 comments:

Bukan Lagi said...

I very much encourage the adding of as many "ala carte" rendering settings as you can...including this one. The more control you put into the users' hands the better, right? The huge caveat, of course, remains: *As long as the effects of each setting are EXPLAINED CLEARLY in the docs.*

Dennis said...

Another approach would be the MSFS one:

Normal users have simple settings in the menu.

Advanced users however could open the preference file with a texteditor and have much more options to choose from.

Then you have everything for both parties.

AWC said...

I agree with Daveduck, I think more options is always better t fine tune for a specific situation

Murmur said...

I second Dannis, simple and advanced settings could be an optimal solution.

BobWhitt said...

I think having multiple options are a good thing. Some scenery requires you turn down settings, while others you can crank up some settings.