Texel's Technical Tribulations Pt. 2


There's a couple of pieces of tech that I will discussing in my next posts. The first is how we're creating the world in our game. Pixel mentioned this before, when he referred to other RPG games using a tile based system to lay down the boundaries of the various areas. The problem with this approach is you get a lot of tiling. Various pieces of grass, dirt, or rock repeat. So when we were first discussing this game, we of course looked at Legend of Zelda: A Link to the Past. I noticed from various fan sites that the main world was about 4096x4096 pixels. After seeing that number I decided to run some calculations to see what the feasibility of just having an image that size would be. So assuming the image is a full 32-bit we have:

(4096*4096*4)/(1024*1024) = 64 MB

Now, that's a rather large image, but it's not unworkable. The next thing to consider is the various forms on texture compression (We have about half the map done for tests).

  • Jpeg - I could simply convert the image to a 24-bit image and run jpeg compression on it. This would probably yield the best results. However, since I can't have that entire image in memory I would need to cut it up and page it in. And I worry about seams in the various pieces (Might be usable if I ensure I cut it up on screen boundaries). High quality and we're at like 12 MB I can get the size lower, but I'm already not thrilled with the look.

  • Png - This wouldn't have the problems of Seams but the compression ratio wouldn't be nearly as good. At this point we have about half the map painted and we're already at 16.6MB

  • PVR - This is a fixed compression ratio of exactly 8 to 1. So we're looking at exactly 8 MB. This also doesn't seem to suffer from any noticeable seams, so cutting the image up is acceptable. Plus the image can remain compressed on device, allowing for more room for the other textures.

So, currently I've chosen the PVR approach because leaving the data compressed in memory is too nice to pass up. Plus it will be faster when paging between the various screens (I won't have to decompress the png/jpg images).

Recently, I added support for zlib compression on the packaged assets and I noticed I got another 10-20% savings on the pvr images.

I have a few rants about PVR though:

  • The tools aren't open source.

  • They don't have a 64-bit version of their library

  • I doubt it supports multiple threads for batch PVR conversion.

So, this is the approach we're taking to create the world. This will be nice because Pixel can literally take a brush and Paint the entire map. I affectionately refer to this as the "Kilo-Texture" (Reference to Carmack's Mega-Texture).