Friday, September 23, 2011

LL3DLGLD – 4 – Poke

The saga continues! This time we’ll enhance the existing system in order to bring the engine closer to being able to render a floor layer. For starters, we’ll consider a single object and poke some holes in it:

The holes behave correctly, as we can see by investigating both sides:

This is the perfect opportunity to enable strip color coding and see how we created these holes:

So we have one object consisting out of a set of stripes that fill the surface between holes. The number of vertexes has increased to 1392. And we have 696 triangles. I’ll leave as homework the determination of the relationship between the number of triangles and the number of vertices. Now we can experiment with random patterns:

I’ll enable wireframe mode so you can see the triangles in action:

The most intensive object can be created by alternating between full and empty cells. It is sufficient to only do it on the horizontal axis since strips are only created horizontally. Using this method, we determine that the maximum number of vertices is 3600 for the 30 cell section:

Using this pattern and keeping the number of objects constant, we can see the worst case scenario FPS:

Te number of vertices has grown so much that we only get 60 FPS. This scenario is almost impossible in practice. Sure, a player might try and poke holes in a pattern specially created to reduce framerate, but during normal play you won’t encounter this scenario. And if you do try it, your reward will be reduced framerate.

For the final touches, we add a small rectangle on the south side:

And we continue to add the rest of the sides. I messed up a few texture coordinates or what not and some textured are flipped around, but I won’t worry about that:

Here is the end result, with all borders filled:

Using the worst case scenario, the polygon count is now up to 7320. The generation of sides is not optimized yet and probably it can be reduced. The worst case scenario is also down to 33 FPS. So I optimized it a little and now it is between 7200 and 7260. Random hole maps have worst case 43 FPS and up to 100 (with around 5000 vertices).  And maps without holes have around worst case 400 FPS.


  1. Your texture look very highres. maybe you can gain FPS by reducing them. Or you use the dds Fileformat which can be stored in the graphiccard RAM

  2. Yes, the textures are intentionally too high res (1024x1024). I want to create an engine that works well even with high res textures and then reduce the texture resolution to appropriate sizes.

    I'm hopping that even now the textures are kept in video memory. I wonder how I could make sure?