Prototype code…

Today I’ve decided that code written for prototypes should ALWAYS be thrown away. No questions asked.



This morning I was changing a few vertex and pixel programs to support some of the new environmental effects I’ve been working on. This led me to remove some data from the terrain that used to be used for coloration. The color data is now stored in a compressed texture instead.



While cleaning up the C++ side of things, I noticed the terrain rendering data was laid out in almost the worst way possible – both for performance and memory. I can’t think of too many worse ways to do it.



I wrote that code while I was prototyping Banished – way back sometime in 2011. I probably wrote it in less than a day, and it worked for the prototype so I never looked at it again. Why would I? It never caused any problems and never required any additional features.



The terrain was using something awful, like 28 megabytes of memory. After fixing things up properly, it now uses 4.25 megabytes for rendering the exact same thing. As a happy side note, I got an immediate 10 FPS frame rate increase when i reduced the memory usage.



However, the first time I ran the game after reducing the memory I got a good graphics explosion. I mentioned this occuring previously – Graphics Explosion.



This was a particularly fine example of sorta awesome terrible graphics errors. At leat it was easily fixable.



As a side note, I’m somewhat amazed at my memory usage level. Two weeks ago, I saw the DX9 renderer using 310Meg on a fresh map. Today my DX11 renderer using 74Meg. Woo.



Maybe I should skim the rest of the code for remnants of the prototype…