Or, in other words:
Map and Map-Object drawing optimizations
I learned some more Direct3D today, as I once again was forced to delve into the depths of this library I'm using ("Omega") to check out how exactly it was handling things. Open-source rocks. The more I go through the source and see how they did things, the more I'm learning. Which is uber.
Anyways, I noticed that the drawing method that was being used currently is:
1) Bind texture
2) Set vertex/texture coords
3) Lock vertices into a vertex buffer
Eeee. Now I realize why I was getting such low framerates in Arctic Outpost. This method seemed to be good enough for the maps that didn't have many heavily-tiled areas or large object counts, but as the maps get bigger and more complex, the framerate nose-dives from 60 to 30 on my computer. Gah. And I've got a fairly nice card, too! :P
Rather than trying to learn what the 'pros' at Microsoft's DirectX team already know, I decided to defer to the enigmatic power of the ID3DXSprite interface, which is a(n awesome!) helper library for drawing 2D sprites in D3D.
I converted my tile-drawing and map-object-drawing routines to use this, and WOW. I mean it, really. Wow. Now I'm back up to 60 FPS on the Arctic Outpost map and things are going smoothly again. Fantastic. I'll have to get some other FPS readings from other testers on lesser hardware tomorrow night when we do another testing session. [smile]
For ages now latency has been really crappy. Well, sort of. After I implemented the 'ping' feature under the game listings on the master server, I realized that it's not my connection -- it's my code! Using a pure back-and-forth ping on my own system with no fancy game code going on in the background yields under 10ms every time. Hmmm. This is especially odd since when I run two clients on my computer and connect them both to a game, I get around ~100ms on average. Doh?
I don't have it perfect yet, but it's a great deal better than before. What I did was subtract the time it takes to render the game from ping calculations. Since in many situations where the framerate drops, rendering time goes up, and packets that arrive during that slow render time (or other lengthy game logic) has to sit there and wait, thus accumulating an increasingly incorrect timestamp.
Short story short, now I'm getting way more reasonable numbers on my end. I'm looking forward to stress-testing it out on tomorrow night's test.
The layering issues I mentioned in my last entry are now fixed up. Healthbars/names appear OVER all objects, while under the HUD. Also, shadows all appear UNDER all objects, while over the map tiles/ground. It both looks and feels significantly better. And people with short names can't hide beside crates anymore, either. [grin]
Also 'fixed' a handful of various bugs. Hopefully they'll stay fixed. Tomorrow night's test should be very decisive in a lot of things, it would seem. [smile]
(Oh, and I'm working on getting all/most of the text with a nice black outline so it's not vanishing on conflicting background colours like this:)