Thursday, September 21, 2006

Another Planet Framerate Improvement

I just realized that the planet-wide rendering was running at 65 fps on my G5 with clear skies but less than 20 fps with a single cirrus layer! Ooops! With X-Plane 850 we use the same OpenGL code to draw terrain whether it's close-up (DSF) or far away (the planet render). This seemed like a good idea because it helped the two mesh. Well, it turns out cloud shadows are way too slow when applied over a huge area.

So...I simply killed them. This will be in the next beta. If you look hard you'll be able to see a slight color change (well, worse than before) where the cloud shadows disappear at the DSF->planet transtion, but the fps are worth it. The G5 went from less than 20 fps looking at the planet to 65 fps, and the MacBook Pro went from 36 fps to 100 fps.

This was never an issue in 840, where the planet had the simplest OpenGL code you can imagine and looked like, well, just compare the planet in 840 vs 850!

Anyway, this explains why I thought I'd fixed the planet code and users cried bloody murder: my standard framerate test has no weather, because that's Austin's code. (Hence I shut it off to check the performance of only my code.) But sure enough it was the weather that affected the "cost" of the planet render.

There is a moral here for programmers: always test performance under real-world conditions! Often a system can have interdependencies that don't appear in "lab" conditions. (Another example: you can't test the speed of airpor build-up without scenery because one of the slowest parts is "draping" the airports over the scenery. When there is no scenery the ocean terrain triangles are very large and so the draping happens much faster than it can with real ground.)

2 comments:

DK said...

Ben,

Did this optimization make it into RC1? Because running at near-identical settings to 8.40, 8.50 seems considerably slower on my Mac...

Benjamin Supnik said...

Hi Dhruv,

Please file a bug, and include uncompressed PNG screenshots of the sim (840 and 850) at the same viewpoint with camera location, plane lat/lon and framerate datarefs, and also a picture of the rendering settings and weather for each...given all six I can do a detailed analysis of the performance problem!