Adrian states that often they (MS) are blamed for the poor performance of 3rd party content, as in the past they have not written in the SDK documents how to gain the best performance out of 3rd party wares. He’s venturing out to reverse this by passing along better techniques and advice, and this is a great start.
Adrian explains that for each change in a material, such as glass or chrome, a different draw call has to be issued. His explaination of how 11 1024 bitmaps for a single FS object can quickly become 330 draw calls in some situations, a third of the total ideal budget for draw calls, is a huge wake-up call for me. I know that I have been guilty of sub-optimizing the whole by optimizing the part, and I have been working to be more mindful of how performance will be affected by what I’m doing at the development level, the art level. Now I have some rhyme to the reason.
The take home message is best stated by Adrian himself:"…as often as possible, use the textures to change the shader values as opposed to using the shader constants themselves. If you control reflection in the diffuse alpha and specular in the specular color and specular alpha, then you should be able to set the reflection and specular power term constants at max and use the texture values to adjust accordingly. You should be able to get rubber, metal, plastic and other surfaces in a single draw call just by adjusting the various portions of the textures. The only thing you should need new material constants for is something like glass, chrome or an object that is transparent or glows." Here Adrian is exploiting the awesome flexibility of the new shaders in FSX. Instead of having a material set at one specular level for a particular texture, and having another material with a slightly different specular level for the same texture, now consolidation of these specular levels onto a single material is possible. So the name of the game is to have an absolute minimum number of individual materials per project, period. That is the secret to good performance.
"Also, make sure that all of the material textures are grouped. Put all the chrome on one sheet, because then you can have a single chrome material and a single chrome draw call. Do the same with glass, metal, etc. If you have 11 1024×1024 textures, and each of them has a chrome section, then you are forcing 11 new draw calls when you could have one." This is some of the best advice I have seen in a long time, and the explaination is right on the money. Many thanks for passing this knowledge on, Adrian. I’m anxious to see what else you plan on revealing in the coming weeks.